[Ocfs2-tools-commits] smushran commits r831 - in trunk: libocfs2
libocfs2/include mount.ocfs2
svn-commits at oss.oracle.com
svn-commits at oss.oracle.com
Wed Apr 20 13:26:27 CDT 2005
Author: smushran
Signed-off-by: mfasheh
Date: 2005-04-20 13:26:25 -0500 (Wed, 20 Apr 2005)
New Revision: 831
Modified:
trunk/libocfs2/Cscope.make
trunk/libocfs2/include/ocfs2_fs.h
trunk/mount.ocfs2/mount.ocfs2.c
trunk/mount.ocfs2/opts.c
Log:
dummy param hbok passed to module during mount
on failed mount hb is stopped
Signed-off-by: mfasheh
Modified: trunk/libocfs2/Cscope.make
===================================================================
--- trunk/libocfs2/Cscope.make 2005-04-20 01:24:13 UTC (rev 830)
+++ trunk/libocfs2/Cscope.make 2005-04-20 18:26:25 UTC (rev 831)
@@ -7,4 +7,6 @@
find . -maxdepth 2 -name '*.h' -print >>cscope.files
find ../libo2dlm -name '*.c' >>cscope.files
find ../libo2dlm -name '*.h' >>cscope.files
+ find ../libo2cb -name '*.c' >>cscope.files
+ find ../libo2cb -name '*.h' >>cscope.files
cscope -b
Modified: trunk/libocfs2/include/ocfs2_fs.h
===================================================================
--- trunk/libocfs2/include/ocfs2_fs.h 2005-04-20 01:24:13 UTC (rev 830)
+++ trunk/libocfs2/include/ocfs2_fs.h 2005-04-20 18:26:25 UTC (rev 831)
@@ -174,6 +174,8 @@
[LOCAL_ALLOC_SYSTEM_INODE] { "local_alloc:%04d", OCFS2_BITMAP_FL | OCFS2_LOCAL_ALLOC_FL, S_IFREG | 0644 }
};
+/* Parameter passed from mount.ocfs2 to module */
+#define OCFS2_HB_OK "hbok"
/*
* OCFS2 directory file types. Only the low 3 bits are used. The
Modified: trunk/mount.ocfs2/mount.ocfs2.c
===================================================================
--- trunk/mount.ocfs2/mount.ocfs2.c 2005-04-20 01:24:13 UTC (rev 830)
+++ trunk/mount.ocfs2/mount.ocfs2.c 2005-04-20 18:26:25 UTC (rev 831)
@@ -40,6 +40,16 @@
char *type;
};
+static void handle_signal(int sig)
+{
+ switch (sig) {
+ case SIGTERM:
+ case SIGINT:
+ printf("\nmount interrupted\n");
+ exit(1);
+ }
+}
+
static void read_options(int argc, char **argv, struct mount_options *mo)
{
int c;
@@ -204,7 +214,7 @@
}
static int run_hb_ctl(const char *hb_ctl_path,
- const char *device)
+ const char *device, const char *arg)
{
int ret = 0;
int child_status;
@@ -219,7 +229,7 @@
if (!child) {
argv[0] = (char *) hb_ctl_path;
- argv[1] = "-S";
+ argv[1] = (char *) arg;
argv[2] = "-d";
argv[3] = (char *) device;
argv[4] = NULL;
@@ -251,21 +261,41 @@
if (ret)
return ret;
- ret = run_hb_ctl(hb_ctl_path, device);
+ ret = run_hb_ctl(hb_ctl_path, device, "-S");
return ret;
}
+static int stop_heartbeat(const char *hb_ctl_path,
+ const char *device)
+{
+ return run_hb_ctl(hb_ctl_path, device, "-K");
+}
+
int main(int argc, char **argv)
{
errcode_t ret = 0;
struct mount_options mo;
char hb_ctl_path[PATH_MAX];
+ char *extra = NULL;
initialize_ocfs_error_table();
initialize_o2dl_error_table();
initialize_o2cb_error_table();
+ setbuf(stdout, NULL);
+ setbuf(stderr, NULL);
+
+ if (signal(SIGTERM, handle_signal) == SIG_ERR) {
+ fprintf(stderr, "Could not set SIGTERM\n");
+ exit(1);
+ }
+
+ if (signal(SIGINT, handle_signal) == SIG_ERR) {
+ fprintf(stderr, "Could not set SIGINT\n");
+ exit(1);
+ }
+
memset(&mo, 0, sizeof(mo));
read_options (argc, argv, &mo);
@@ -278,8 +308,8 @@
ret = o2cb_get_hb_ctl_path(hb_ctl_path, sizeof(hb_ctl_path));
if (ret) {
- com_err(progname, 0, "\"%s\" probably because o2cb service not started",
- strerror(ret));
+ com_err(progname, ret,
+ "probably because o2cb service not started");
goto bail;
}
@@ -293,12 +323,19 @@
goto bail;
}
- ret = mount(mo.dev, mo.dir, OCFS2_FS_NAME, mo.flags & ~MS_NOSYS,
- mo.xtra_opts);
+ if (mo.xtra_opts && *mo.xtra_opts) {
+ extra = xstrndup(mo.xtra_opts,
+ strlen(mo.xtra_opts) + strlen(OCFS2_HB_OK) + 1);
+ extra = xstrconcat3(extra, ",", OCFS2_HB_OK);
+ } else
+ extra = xstrndup(OCFS2_HB_OK, strlen(OCFS2_HB_OK));
+
+ ret = mount(mo.dev, mo.dir, OCFS2_FS_NAME, mo.flags & ~MS_NOSYS, extra);
if (ret) {
+ stop_heartbeat(hb_ctl_path, mo.dev);
block_signals (SIG_UNBLOCK);
- fprintf(stderr, "\"%s\" while mounting %s on %s",
- strerror(errno), mo.dev, mo.dir);
+ com_err(progname, errno, "while mounting %s on %s",
+ mo.dev, mo.dir);
goto bail;
}
@@ -310,6 +347,8 @@
block_signals (SIG_UNBLOCK);
bail:
+ if (extra)
+ free(extra);
if (mo.dev)
free(mo.dev);
if (mo.dir)
Modified: trunk/mount.ocfs2/opts.c
===================================================================
--- trunk/mount.ocfs2/opts.c 2005-04-20 01:24:13 UTC (rev 830)
+++ trunk/mount.ocfs2/opts.c 2005-04-20 18:26:25 UTC (rev 831)
@@ -237,7 +237,7 @@
const struct string_opt_map *m;
char *new_opts;
- new_opts = (flags & MS_RDONLY) ? "ro" : "rw";
+ new_opts = (flags & MS_RDONLY) ? xstrndup("ro", 2) : xstrndup("rw", 2);
for (om = opt_map; om->opt != NULL; om++) {
if (om->skip)
continue;
More information about the Ocfs2-tools-commits
mailing list