Changes by: cha0smaster
Update of /cvsroot/linux-ntfs/ntfsprogs/ntfsprogs
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26124/ntfsprogs
Modified Files:
Makefile.am Makefile.in ntfsmount.8.in ntfsmount.c
Log Message:
ntfsmount:
* use mount function from utils.[ch]
* remove fsname option (need to support if volume already mounted)
* add force option to support mount from utils
* update manual page
* fix tiny memleak
Index: Makefile.am
===================================================================
RCS file: /cvsroot/linux-ntfs/ntfsprogs/ntfsprogs/Makefile.am,v
retrieving revision 1.36
retrieving revision 1.37
diff -u -p -r1.36 -r1.37
--- Makefile.am 10 Jul 2005 12:38:50 -0000 1.36
+++ Makefile.am 15 Jul 2005 15:53:29 -0000 1.37
@@ -79,7 +79,7 @@ ntfscp_LDADD = $(AM_LIBS)
ntfscp_LDFLAGS = $(AM_LFLAGS)
if ENABLE_FUSE_MODULE
-ntfsmount_SOURCES = ntfsmount.c
+ntfsmount_SOURCES = ntfsmount.c utils.c utils.h
ntfsmount_LDADD = $(AM_LIBS) $(FUSE_MODULE_LIBS)
ntfsmount_LDFLAGS = $(AM_LFLAGS)
ntfsmount_CFLAGS = $(FUSE_MODULE_CFLAGS) -DFUSE_USE_VERSION=22
Index: Makefile.in
===================================================================
RCS file: /cvsroot/linux-ntfs/ntfsprogs/ntfsprogs/Makefile.in,v
retrieving revision 1.76
retrieving revision 1.77
diff -u -p -r1.76 -r1.77
--- Makefile.in 10 Jul 2005 21:42:44 -0000 1.76
+++ Makefile.in 15 Jul 2005 15:53:29 -0000 1.77
@@ -111,9 +111,10 @@ ntfsls_DEPENDENCIES = $(am__DEPENDENCIES
am_ntfsmftalloc_OBJECTS = ntfsmftalloc.$(OBJEXT) utils.$(OBJEXT)
ntfsmftalloc_OBJECTS = $(am_ntfsmftalloc_OBJECTS)
ntfsmftalloc_DEPENDENCIES = $(am__DEPENDENCIES_1)
-am__ntfsmount_SOURCES_DIST = ntfsmount.c
+am__ntfsmount_SOURCES_DIST = ntfsmount.c utils.c utils.h
@ENABLE_FUSE_MODULE_TRUE@am_ntfsmount_OBJECTS = \
-@ENABLE_FUSE_MODULE_TRUE@ ntfsmount-ntfsmount.$(OBJEXT)
+@ENABLE_FUSE_MODULE_TRUE@ ntfsmount-ntfsmount.$(OBJEXT) \
+@ENABLE_FUSE_MODULE_TRUE@ ntfsmount-utils.$(OBJEXT)
ntfsmount_OBJECTS = $(am_ntfsmount_OBJECTS)
am__DEPENDENCIES_2 =
@ENABLE_FUSE_MODULE_TRUE@ntfsmount_DEPENDENCIES = \
@@ -240,6 +241,7 @@ ac_ct_CXX = @ac_ct_CXX@
ac_ct_F77 = @ac_ct_F77@
ac_ct_RANLIB = @ac_ct_RANLIB@
ac_ct_STRIP = @ac_ct_STRIP@
+ac_pt_PKG_CONFIG = @ac_pt_PKG_CONFIG@
all_includes = @all_includes@
all_libraries = @all_libraries@
am__fastdepCC_FALSE = @am__fastdepCC_FALSE@
@@ -336,7 +338,7 @@ ntfscat_LDFLAGS = $(AM_LFLAGS)
ntfscp_SOURCES = ntfscp.c utils.c utils.h
ntfscp_LDADD = $(AM_LIBS)
ntfscp_LDFLAGS = $(AM_LFLAGS)
-@ENABLE_FUSE_MODULE_TRUE@ntfsmount_SOURCES = ntfsmount.c
+@ENABLE_FUSE_MODULE_TRUE@ntfsmount_SOURCES = ntfsmount.c utils.c utils.h
@ENABLE_FUSE_MODULE_TRUE@ntfsmount_LDADD = $(AM_LIBS) $(FUSE_MODULE_LIBS)
@ENABLE_FUSE_MODULE_TRUE@ntfsmount_LDFLAGS = $(AM_LFLAGS)
@ENABLE_FUSE_MODULE_TRUE@ntfsmount_CFLAGS = $(FUSE_MODULE_CFLAGS) -DFUSE_USE_VERSION=22
@@ -551,6 +553,7 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ntfsls.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ntfsmftalloc.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ntfsmount-ntfsmount.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ntfsmount-utils.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ntfsmove.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ntfsresize.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ntfsrm.Po@am__quote@
@@ -596,6 +599,20 @@ ntfsmount-ntfsmount.obj: ntfsmount.c
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(ntfsmount_CFLAGS) $(CFLAGS) -c -o ntfsmount-ntfsmount.obj `if test -f 'ntfsmount.c'; then $(CYGPATH_W) 'ntfsmount.c'; else $(CYGPATH_W) '$(srcdir)/ntfsmount.c'; fi`
+ntfsmount-utils.o: utils.c
+@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(ntfsmount_CFLAGS) $(CFLAGS) -MT ntfsmount-utils.o -MD -MP -MF "$(DEPDIR)/ntfsmount-utils.Tpo" -c -o ntfsmount-utils.o `test -f 'utils.c' || echo '$(srcdir)/'`utils.c; \
+@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/ntfsmount-utils.Tpo" "$(DEPDIR)/ntfsmount-utils.Po"; else rm -f "$(DEPDIR)/ntfsmount-utils.Tpo"; exit 1; fi
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='utils.c' object='ntfsmount-utils.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(ntfsmount_CFLAGS) $(CFLAGS) -c -o ntfsmount-utils.o `test -f 'utils.c' || echo '$(srcdir)/'`utils.c
+
+ntfsmount-utils.obj: utils.c
+@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(ntfsmount_CFLAGS) $(CFLAGS) -MT ntfsmount-utils.obj -MD -MP -MF "$(DEPDIR)/ntfsmount-utils.Tpo" -c -o ntfsmount-utils.obj `if test -f 'utils.c'; then $(CYGPATH_W) 'utils.c'; else $(CYGPATH_W) '$(srcdir)/utils.c'; fi`; \
+@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/ntfsmount-utils.Tpo" "$(DEPDIR)/ntfsmount-utils.Po"; else rm -f "$(DEPDIR)/ntfsmount-utils.Tpo"; exit 1; fi
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='utils.c' object='ntfsmount-utils.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(ntfsmount_CFLAGS) $(CFLAGS) -c -o ntfsmount-utils.obj `if test -f 'utils.c'; then $(CYGPATH_W) 'utils.c'; else $(CYGPATH_W) '$(srcdir)/utils.c'; fi`
+
mostlyclean-libtool:
-rm -f *.lo
Index: ntfsmount.8.in
===================================================================
RCS file: /cvsroot/linux-ntfs/ntfsprogs/ntfsprogs/ntfsmount.8.in,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -p -r1.2 -r1.3
--- ntfsmount.8.in 5 Jul 2005 04:54:28 -0000 1.2
+++ ntfsmount.8.in 15 Jul 2005 15:53:29 -0000 1.3
@@ -121,8 +121,8 @@ The default is infinite. Note that the
limited anyway to 32 pages (which is 128kbyte on i386).
.TP
-.B fsname=
-Sets the filesystem name. The default is the program name.
+.B force=
+Force mount even if errors occured. Use this option only if you know what are you doing and don't cry about data loss.
.TP
.B ro
@@ -130,7 +130,7 @@ Mount filesystem read-only.
.TP
.B no_def_opts
-By default ntfsmount acts as "default_permissions,kernel_cache,allow_other,fsname=ntfs#device" was passed to it, this option cancel this behaviour.
+By default ntfsmount acts as "default_permissions,kernel_cache,allow_other" was passed to it, this option cancel this behaviour.
.TP
.B succeed_chmod
Index: ntfsmount.c
===================================================================
RCS file: /cvsroot/linux-ntfs/ntfsprogs/ntfsprogs/ntfsmount.c,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -p -r1.10 -r1.11
--- ntfsmount.c 9 Jul 2005 01:11:46 -0000 1.10
+++ ntfsmount.c 15 Jul 2005 15:53:29 -0000 1.11
@@ -43,6 +43,7 @@
#include "dir.h"
#include "unistr.h"
#include "layout.h"
+#include "utils.h"
typedef struct {
fuse_fill_dir_t filler;
@@ -61,6 +62,7 @@ typedef struct {
BOOL ro;
BOOL show_sys_files;
BOOL succeed_chmod;
+ BOOL force;
} ntfs_fuse_context_t;
typedef enum {
@@ -74,7 +76,9 @@ static const char *EXEC_NAME = "ntfsmoun
static char def_opts[] = "default_permissions,kernel_cache,allow_other,";
static ntfs_fuse_context_t *ctx;
-#define Eprintf(arg...) fprintf(stderr, ##arg)
+GEN_PRINTF(Eprintf, stderr, NULL, FALSE)
+GEN_PRINTF(Vprintf, stderr, NULL, TRUE)
+GEN_PRINTF(Qprintf, stderr, NULL, FALSE)
static long ntfs_fuse_get_nr_free_mft_records(ntfs_volume *vol)
{
@@ -870,9 +874,9 @@ static int ntfs_fuse_mount(const char *d
{
ntfs_volume *vol;
- vol = ntfs_mount(device, (ctx->ro) ? MS_RDONLY : 0);
+ vol = utils_mount_volume(device, (ctx->ro) ? MS_RDONLY : 0, ctx->force);
if (!vol) {
- perror("Mount failed");
+ Eprintf("Mount failed.\n");
return -1;
}
ctx->vol = vol;
@@ -897,16 +901,16 @@ static void signal_handler(int arg __att
static char *parse_options(char *options, char **device)
{
char *opts, *s, *opt, *val, *ret;
- BOOL no_def_opts = FALSE, no_fsname = FALSE;
+ BOOL no_def_opts = FALSE;
*device = NULL;
/*
- * +8 for different in length of "fsname=ntfs#..." and "dev=...".
+ * +3 for different in length of "fsname=..." and "dev=...".
* +1 for comma
* +1 for null-terminator.
- * Total: +10
+ * Total: +5
*/
- ret = malloc(strlen(def_opts) + strlen(options) + 10);
+ ret = malloc(strlen(def_opts) + strlen(options) + 5);
if (!ret) {
perror("malloc failed");
return NULL;
@@ -935,14 +939,12 @@ static char *parse_options(char *options
ctx->ro =TRUE;
strcat(ret, "ro,");
} else if (!strcmp(opt, "fsname")) { /* Filesystem name. */
- if (!val) {
- Eprintf("fsname option should have value.\n");
- goto err_exit;
- }
- no_fsname = TRUE;
- strcat(ret, "fsname=");
- strcat(ret, val);
- strcat(ret, ",");
+ /*
+ * We need this to be able to check whether filesystem
+ * mounted or not.
+ */
+ Eprintf("fsname is unsupported option.\n");
+ goto err_exit;
} else if (!strcmp(opt, "no_def_opts")) {
if (val) {
Eprintf("no_def_opts option should not have "
@@ -995,6 +997,13 @@ static char *parse_options(char *options
goto err_exit;
}
ctx->succeed_chmod = TRUE;
+ } else if (!strcmp(opt, "force")) {
+ if (val) {
+ Eprintf("force option should not "
+ "have value.\n");
+ goto err_exit;
+ }
+ ctx->force = TRUE;
} else { /* Probably FUSE option. */
strcat(ret, opt);
if (val) {
@@ -1006,13 +1015,10 @@ static char *parse_options(char *options
}
if (!*device)
goto err_exit;
- if (!no_def_opts) {
+ if (!no_def_opts)
strcat(ret, def_opts);
- if (!no_fsname) {
- strcat(ret, "fsname=ntfs#");
- strcat(ret, *device);
- }
- }
+ strcat(ret, "fsname=");
+ strcat(ret, *device);
exit:
free(opts);
return ret;
@@ -1031,9 +1037,9 @@ static void usage(void)
EXEC_NAME);
Eprintf("Possible options are:\n\tdefault_permissions\n\tallow_other\n"
"\tkernel_cache\n\tlarge_read\n\tdirect_io\n\tmax_read\n\t"
- "fsname\n\tro\n\tno_def_opts\n\tumask\n\tfmask\n\tdmask\n\t"
+ "force\n\tro\n\tno_def_opts\n\tumask\n\tfmask\n\tdmask\n\t"
"uid\n\tgid\n\tshow_sys_files\n\tsucceed_chmod\n\tdev\n\n");
- Eprintf("Default options are: \"%sfsname=ntfs#device\".\n", def_opts);
+ Eprintf("Default options are: \"%s\".\n", def_opts);
}
int main(int argc, char *argv[])
@@ -1067,18 +1073,27 @@ int main(int argc, char *argv[])
if (!device) {
Eprintf("dev option is mandatory.\n");
ntfs_fuse_destroy();
- return 5;
+ return 2;
}
if (!parsed_options) {
+ free(device);
ntfs_fuse_destroy();
- return 6;
+ return 3;
}
+ /* Mount volume. */
+ if (ntfs_fuse_mount(device)) {
+ free(device);
+ ntfs_fuse_destroy();
+ return 4;
+ }
+ free(device);
/* Create filesystem. */
ffd = fuse_mount(mnt_point, parsed_options);
if (ffd == -1) {
Eprintf("fuse_mount failed.\n");
- return 2;
+ ntfs_fuse_destroy();
+ return 5;
}
free(parsed_options);
#ifndef DEBUG
@@ -1091,14 +1106,8 @@ int main(int argc, char *argv[])
Eprintf("fuse_new failed.\n");
close(ffd);
fuse_unmount(mnt_point);
- return 3;
- }
- /* Mount volume. */
- if (ntfs_fuse_mount(device)) {
- fuse_destroy(fh);
- close(ffd);
- fuse_unmount(mnt_point);
- return 4;
+ ntfs_fuse_destroy();
+ return 6;
}
#ifndef DEBUG
if (daemon(0, 0))
|