[Ocfs2-tools-devel] [PATCH 1/1] Mount.ocfs2: Append heartbeat mount option string only if it is not present on mo.xtra_opts

Jeff Liu jeff.liu at oracle.com
Fri Mar 12 07:15:30 PST 2010


The heartbeat=xxxx will present twice at /etc/mtab if the user specified heartbeat mount
option via mount or /etc/fstab, this patch fix it by pre-check the extra_option_string whether it
was already there or not.

Signed-off-by: Jie Liu <jeff.liu at oracle.com>
---
 mount.ocfs2/mount.ocfs2.c |   10 +++++++---
 1 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/mount.ocfs2/mount.ocfs2.c b/mount.ocfs2/mount.ocfs2.c
index f820a30..5ed1638 100644
--- a/mount.ocfs2/mount.ocfs2.c
+++ b/mount.ocfs2/mount.ocfs2.c
@@ -367,9 +367,13 @@ int main(int argc, char **argv)
 		hbstr = OCFS2_HB_LOCAL;
 
 	if (mo.xtra_opts && *mo.xtra_opts) {
-		extra = xstrndup(mo.xtra_opts,
-				 strlen(mo.xtra_opts) + strlen(hbstr) + 1);
-		extra = xstrconcat3(extra, ",", hbstr);
+		if (!strstr(mo.xtra_opts, hbstr)) {
+			extra = xstrndup(mo.xtra_opts,
+					strlen(mo.xtra_opts) + strlen(hbstr)
+					+ 1);
+			extra = xstrconcat3(extra, ",", hbstr);
+		} else
+			extra = xstrndup(mo.xtra_opts, strlen(mo.xtra_opts));
 	} else
 		extra = xstrndup(hbstr, strlen(hbstr));
 
-- 
1.5.4.3




More information about the Ocfs2-tools-devel mailing list