[Ocfs2-tools-commits] smushran commits r795 - in trunk: libocfs2
mount.ocfs2
svn-commits at oss.oracle.com
svn-commits at oss.oracle.com
Mon Apr 11 20:10:26 CDT 2005
Author: smushran
Date: 2005-04-11 20:10:24 -0500 (Mon, 11 Apr 2005)
New Revision: 795
Modified:
trunk/libocfs2/ocfs2_err.et
trunk/mount.ocfs2/mount.ocfs2.c
trunk/mount.ocfs2/opts.c
trunk/mount.ocfs2/opts.h
Log:
Fixes bugzilla#342 in ocfs2-tools
able to mount from mount.ocfs2 directly
Signed-Off: mfasheh
Modified: trunk/libocfs2/ocfs2_err.et
===================================================================
--- trunk/libocfs2/ocfs2_err.et 2005-04-12 01:08:31 UTC (rev 794)
+++ trunk/libocfs2/ocfs2_err.et 2005-04-12 01:10:24 UTC (rev 795)
@@ -150,4 +150,7 @@
ec OCFS2_ET_BAD_HEARTBEAT_FILE,
"Invalid heartbeat file"
+ec OCFS2_ET_UNKNOWN_FILESYSTEM,
+ "Unknown filesystem"
+
end
Modified: trunk/mount.ocfs2/mount.ocfs2.c
===================================================================
--- trunk/mount.ocfs2/mount.ocfs2.c 2005-04-12 01:08:31 UTC (rev 794)
+++ trunk/mount.ocfs2/mount.ocfs2.c 2005-04-12 01:10:24 UTC (rev 795)
@@ -23,6 +23,8 @@
#include "mount.ocfs2.h"
#include "o2cb.h"
+#define OCFS2_FS_NAME "ocfs2"
+
int verbose = 0;
int mount_quiet = 0;
char *progname = NULL;
@@ -35,6 +37,7 @@
char *opts;
int flags;
char *xtra_opts;
+ char *type;
};
static void read_options(int argc, char **argv, struct mount_options *mo)
@@ -47,7 +50,7 @@
goto bail;
while(1) {
- c = getopt(argc, argv, "vno:");
+ c = getopt(argc, argv, "vno:t:");
if (c == -1)
break;
@@ -65,6 +68,11 @@
mo->opts = xstrdup(optarg);
break;
+ case 't':
+ if (optarg)
+ mo->type = xstrdup(optarg);
+ break;
+
default:
break;
}
@@ -171,6 +179,11 @@
return -1;
}
+ if (mo->type && strcmp(mo->type, OCFS2_FS_NAME)) {
+ com_err(progname, OCFS2_ET_UNKNOWN_FILESYSTEM, mo->type);
+ return -1;
+ }
+
if (mo->opts)
parse_opts(mo->opts, &mo->flags, &mo->xtra_opts);
@@ -263,27 +276,43 @@
if (verbose)
printf("device=%s\n", mo.dev);
+ block_signals (SIG_BLOCK);
+
ret = start_heartbeat(hb_ctl_path, mo.dev);
if (ret) {
+ block_signals (SIG_UNBLOCK);
com_err(progname, 0, "Error when attempting to run %s: "
"\"%s\"\n", hb_ctl_path, strerror(ret));
goto bail;
}
- ret = mount(mo.dev, mo.dir, "ocfs2", mo.flags & ~MS_NOSYS, mo.xtra_opts);
+ ret = mount(mo.dev, mo.dir, OCFS2_FS_NAME, mo.flags & ~MS_NOSYS,
+ mo.xtra_opts);
if (ret) {
+ block_signals (SIG_UNBLOCK);
fprintf(stderr, "error %d while mounting %s on %s", errno,
mo.dev, mo.dir);
goto bail;
}
- update_mtab_entry(mo.dev, mo.dir, "ocfs2", mo.opts, mo.flags, 0, 0);
+ update_mtab_entry(mo.dev, mo.dir, OCFS2_FS_NAME,
+ fix_opts_string (mo.flags & ~MS_NOMTAB,
+ mo.xtra_opts, NULL),
+ mo.flags, 0, 0);
+ block_signals (SIG_UNBLOCK);
+
bail:
- free(mo.dev);
- free(mo.dir);
- free(mo.opts);
- free(mo.xtra_opts);
+ if (mo.dev)
+ free(mo.dev);
+ if (mo.dir)
+ free(mo.dir);
+ if (mo.opts)
+ free(mo.opts);
+ if (mo.xtra_opts)
+ free(mo.xtra_opts);
+ if (mo.type)
+ free(mo.type);
return ret ? 1 : 0;
}
Modified: trunk/mount.ocfs2/opts.c
===================================================================
--- trunk/mount.ocfs2/opts.c 2005-04-12 01:08:31 UTC (rev 794)
+++ trunk/mount.ocfs2/opts.c 2005-04-12 01:10:24 UTC (rev 795)
@@ -229,3 +229,33 @@
*flags |= mounttype;
#endif
}
+
+/* Try to build a canonical options string. */
+char *fix_opts_string (int flags, const char *extra_opts, const char *user)
+{
+ const struct opt_map *om;
+ const struct string_opt_map *m;
+ char *new_opts;
+
+ new_opts = (flags & MS_RDONLY) ? "ro" : "rw";
+ for (om = opt_map; om->opt != NULL; om++) {
+ if (om->skip)
+ continue;
+ if (om->inv || !om->mask || (flags & om->mask) != om->mask)
+ continue;
+ new_opts = xstrconcat3(new_opts, ",", om->opt);
+ flags &= ~om->mask;
+ }
+ for (m = &string_opt_map[0]; m->tag; m++) {
+ if (!m->skip && *(m->valptr))
+ new_opts = xstrconcat4(new_opts, ",",
+ m->tag, *(m->valptr));
+ }
+ if (extra_opts && *extra_opts) {
+ new_opts = xstrconcat3(new_opts, ",", extra_opts);
+ }
+ if (user) {
+ new_opts = xstrconcat3(new_opts, ",user=", user);
+ }
+ return new_opts;
+}
Modified: trunk/mount.ocfs2/opts.h
===================================================================
--- trunk/mount.ocfs2/opts.h 2005-04-12 01:08:31 UTC (rev 794)
+++ trunk/mount.ocfs2/opts.h 2005-04-12 01:10:24 UTC (rev 795)
@@ -44,3 +44,4 @@
#define MS_OWNERSECURE (MS_NOSUID|MS_NODEV)
void parse_opts (char *options, int *flags, char **extra_opts);
+char *fix_opts_string (int flags, const char *extra_opts, const char *user);
More information about the Ocfs2-tools-commits
mailing list