[Ocfs2-tools-commits] smushran commits r826 - in trunk: libo2cb
libo2cb/include mount.ocfs2
svn-commits at oss.oracle.com
svn-commits at oss.oracle.com
Tue Apr 19 13:39:38 CDT 2005
Author: smushran
Signed-off-by: mfasheh
Date: 2005-04-19 13:39:36 -0500 (Tue, 19 Apr 2005)
New Revision: 826
Modified:
trunk/libo2cb/include/o2cb.h
trunk/libo2cb/o2cb_abi.c
trunk/mount.ocfs2/mount.ocfs2.c
Log:
mount.ocfs2 reads path to ocfs2_hb_ctl from sysfs
Signed-off-by: mfasheh
Modified: trunk/libo2cb/include/o2cb.h
===================================================================
--- trunk/libo2cb/include/o2cb.h 2005-04-19 09:45:38 UTC (rev 825)
+++ trunk/libo2cb/include/o2cb.h 2005-04-19 18:39:36 UTC (rev 826)
@@ -72,4 +72,6 @@
const char *node_name,
uint16_t *node_num);
+errcode_t o2cb_get_hb_ctl_path(char *buf, int count);
+
#endif /* _O2CB_H */
Modified: trunk/libo2cb/o2cb_abi.c
===================================================================
--- trunk/libo2cb/o2cb_abi.c 2005-04-19 09:45:38 UTC (rev 825)
+++ trunk/libo2cb/o2cb_abi.c 2005-04-19 18:39:36 UTC (rev 826)
@@ -732,3 +732,43 @@
return 0;
}
+
+errcode_t o2cb_get_hb_ctl_path(char *buf, int count)
+{
+ int fd;
+ int total = 0;
+ int ret;
+
+#define HB_CTL_PATH "/proc/sys/fs/ocfs2/nm/hb_ctl_path"
+
+ fd = open(HB_CTL_PATH, O_RDONLY);
+ if (fd == -1)
+ return errno;
+
+ while (total < count) {
+ ret = read(fd, buf + total, count - total);
+ if (ret < 0) {
+ ret = -errno;
+ if ((ret == -EAGAIN) || (ret == -EINTR))
+ continue;
+ total = ret;
+ break;
+ }
+ if (ret == 0)
+ break;
+ total += ret;
+ }
+
+ if (total < 0) {
+ close(fd);
+ return total;
+ }
+
+ buf[total] = '\0';
+ if (buf[total - 1] == '\n')
+ buf[total - 1] = '\0';
+
+ close(fd);
+
+ return 0;
+}
Modified: trunk/mount.ocfs2/mount.ocfs2.c
===================================================================
--- trunk/mount.ocfs2/mount.ocfs2.c 2005-04-19 09:45:38 UTC (rev 825)
+++ trunk/mount.ocfs2/mount.ocfs2.c 2005-04-19 18:39:36 UTC (rev 826)
@@ -260,7 +260,7 @@
{
errcode_t ret = 0;
struct mount_options mo;
- const char *hb_ctl_path = "/sbin/ocfs2_hb_ctl";
+ char hb_ctl_path[PATH_MAX];
initialize_ocfs_error_table();
initialize_o2dl_error_table();
@@ -276,6 +276,13 @@
if (verbose)
printf("device=%s\n", mo.dev);
+ 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));
+ goto bail;
+ }
+
block_signals (SIG_BLOCK);
ret = start_heartbeat(hb_ctl_path, mo.dev);
@@ -290,8 +297,8 @@
mo.xtra_opts);
if (ret) {
block_signals (SIG_UNBLOCK);
- fprintf(stderr, "error %d while mounting %s on %s", errno,
- mo.dev, mo.dir);
+ fprintf(stderr, "\"%s\" while mounting %s on %s",
+ strerror(errno), mo.dev, mo.dir);
goto bail;
}
More information about the Ocfs2-tools-commits
mailing list