Skip to contentSkip to conversation

ocfs2-tools: add error message to mount.ocfs2 when mount point is invalid.

PATCH New Coly Li 3 participants 4 messages Jul 31, 2008 – Aug 1, 2008 OCFS2

lore
Share & tools
lore

Coly Li

author
#0 lore raw

PATCH 1/1 ocfs2-tools: add error message to mount.ocfs2 when mount point is invalid.

Adds error messages to mount.ocfs2 when mount point is invalid in three conditions:
1) mount point does not exist.
2) mount point is a symbolic link.
3) mount point is not a directory.
Adding these error messages can help ocfs2console provides more helpful feedback information to end use. Similar information can be found when mounting ext[234] file systems.

Patch is generated against upstream ocfs2-tools.

Cc Joel Becker <[email protected]>
Cc Tao Ma <[email protected]>
Cc Tiger Yang <[email protected]>

---

mount.ocfs2/mount.ocfs2.c +15 -3
index a97b4cb..eb8e336 100644
@@ -382,9 +382,21 @@ int main(int argc, char **argv)
  			o2cb_complete_group_join(&cluster, &desc, errno);
  		}
  		block_signals (SIG_UNBLOCK);
-		com_err(progname, ret, "while mounting %s on %s. "
-			"Check 'dmesg' for more information on this error.",
-			mo.dev, mo.dir);
+
+		/* complain mount failure */
+		if (lstat(mo.dir, &statbuf))
+			com_err(progname, 0, "mount point %s does not "
+				"exist", mo.dir);
+		else if (stat(mo.dir, &statbuf))
+			com_err(progname, 0, "mount point %s is a "
+				"symbolic link to nowhere", mo.dir);
+		else if (stat(mo.dir, &statbuf) || !S_ISDIR(statbuf.st_mode))
+			com_err(progname, 0, "mount point %s is not "
+				"a directory", mo.dir);
+		else
+			com_err(progname, ret, "while mounting %s on %s. "
+				"Check 'dmesg' for more information on this "
+				"error.", mo.dev, mo.dir);
  		goto bail;
  	}
  	if (hb_started) {
Signature · 2 lines
Coly Li
SuSE PRC Labs
#1 lore raw

PATCH 1/1 ocfs2-tools: add error message to mount.ocfs2 when mount point is invalid.

Maybe change "symbolic link to nowhere" to "broken symbolic link".

Looks good otherwise.

Quoted 45 lines · Coly Li

Adds error messages to mount.ocfs2 when mount point is invalid in three conditions:
1) mount point does not exist.
2) mount point is a symbolic link.
3) mount point is not a directory.
Adding these error messages can help ocfs2console provides more helpful feedback information to end use. Similar information can be found when mounting ext[234] file systems.

Patch is generated against upstream ocfs2-tools.

Cc Joel Becker <[email protected]>
Cc Tao Ma <[email protected]>
Cc Tiger Yang <[email protected]>

---

mount.ocfs2/mount.ocfs2.c +15 -3
index a97b4cb..eb8e336 100644
@@ -382,9 +382,21 @@ int main(int argc, char **argv)
  			o2cb_complete_group_join(&cluster, &desc, errno);
  		}
  		block_signals (SIG_UNBLOCK);
-		com_err(progname, ret, "while mounting %s on %s. "
-			"Check 'dmesg' for more information on this error.",
-			mo.dev, mo.dir);
+
+		/* complain mount failure */
+		if (lstat(mo.dir, &statbuf))
+			com_err(progname, 0, "mount point %s does not "
+				"exist", mo.dir);
+		else if (stat(mo.dir, &statbuf))
+			com_err(progname, 0, "mount point %s is a "
+				"symbolic link to nowhere", mo.dir);
+		else if (stat(mo.dir, &statbuf) || !S_ISDIR(statbuf.st_mode))
+			com_err(progname, 0, "mount point %s is not "
+				"a directory", mo.dir);
+		else
+			com_err(progname, ret, "while mounting %s on %s. "
+				"Check 'dmesg' for more information on this "
+				"error.", mo.dev, mo.dir);
  		goto bail;
  	}
  	if (hb_started) {
#2 lore raw

PATCH 1/1 ocfs2-tools: add error message to mount.ocfs2 when mount point is invalid.

In reply to Coly Li
Quoted 10 lines · Coly Li
mount.ocfs2/mount.ocfs2.c +0 -2
index a97b4cb..eb8e336 100644
@@ -382,9 +382,21 @@ int main(int argc, char **argv)
  			o2cb_complete_group_join(&cluster, &desc, errno);
  		}
  		block_signals (SIG_UNBLOCK);
-		com_err(progname, ret, "while mounting %s on %s. "
-			"Check 'dmesg' for more information on this error.",

mount.ocfs2/mount.ocfs2.c int main(int argc, char **argv) · line 393

Quoted 10 lines
mount.ocfs2/mount.ocfs2.c +9 -1
-			mo.dev, mo.dir);
+
+		/* complain mount failure */
+		if (lstat(mo.dir, &statbuf))
+			com_err(progname, 0, "mount point %s does not "
+				"exist", mo.dir);
+		else if (stat(mo.dir, &statbuf))
+			com_err(progname, 0, "mount point %s is a "
+				"symbolic link to nowhere", mo.dir);
+		else if (stat(mo.dir, &statbuf) || !S_ISDIR(statbuf.st_mode))

+ else if (!S_ISDIR(statbuf.st_mode))

You successfully called stat in the previous "else if" clause.

mount.ocfs2/mount.ocfs2.c int main(int argc, char **argv) · line 399

Quoted 6 lines
mount.ocfs2/mount.ocfs2.c +6 -0
+			com_err(progname, 0, "mount point %s is not "
+				"a directory", mo.dir);
+		else
+			com_err(progname, ret, "while mounting %s on %s. "
+				"Check 'dmesg' for more information on this "
+				"error.", mo.dev, mo.dir);

Also, I agree with sunil's "broken symbolic link" text.

Joel

Signature · 8 lines
"I have never let my schooling interfere with my education."
        - Mark Twain

Joel Becker
Principal Software Developer
Oracle
E-mail: joel.becker at oracle.com
Phone: (650) 506-8127
author
#3 lore raw

PATCH 1/1 ocfs2-tools: add error message to mount.ocfs2 when mount point is invalid.

Joel Becker Wrote:

Quoted 23 lines · Coly Li
Quoted 10 lines
mount.ocfs2/mount.ocfs2.c +0 -2
index a97b4cb..eb8e336 100644
@@ -382,9 +382,21 @@ int main(int argc, char **argv)
  			o2cb_complete_group_join(&cluster, &desc, errno);
  		}
  		block_signals (SIG_UNBLOCK);
-		com_err(progname, ret, "while mounting %s on %s. "
-			"Check 'dmesg' for more information on this error.",

mount.ocfs2/mount.ocfs2.c int main(int argc, char **argv) · line 393

Quoted 10 lines
mount.ocfs2/mount.ocfs2.c +9 -1
-			mo.dev, mo.dir);
+
+		/* complain mount failure */
+		if (lstat(mo.dir, &statbuf))
+			com_err(progname, 0, "mount point %s does not "
+				"exist", mo.dir);
+		else if (stat(mo.dir, &statbuf))
+			com_err(progname, 0, "mount point %s is a "
+				"symbolic link to nowhere", mo.dir);
+		else if (stat(mo.dir, &statbuf) || !S_ISDIR(statbuf.st_mode))

+ else if (!S_ISDIR(statbuf.st_mode))

Quoted 1 line

You successfully called stat in the previous "else if" clause.

wow, thanks for catching this :)

Quoted 9 lines

mount.ocfs2/mount.ocfs2.c int main(int argc, char **argv) · line 399

Quoted 7 lines
mount.ocfs2/mount.ocfs2.c +6 -0
+			com_err(progname, 0, "mount point %s is not "
+				"a directory", mo.dir);
+		else
+			com_err(progname, ret, "while mounting %s on %s. "
+				"Check 'dmesg' for more information on this "
+				"error.", mo.dev, mo.dir);

Also, I agree with sunil's "broken symbolic link" text.

patch modified and resend to ocfs2-tools-devel again.

Signature · 2 lines
Coly Li
SuSE PRC Labs