[Ocfs2-tools-devel] [PATCH 25/25] mount.ocfs2: Validate mount path before mount
Sunil Mushran
sunil.mushran at oracle.com
Wed Jun 23 11:44:35 PDT 2010
Check the validity of the mount dir before calling mount(2).
Signed-off-by: Sunil Mushran <sunil.mushran at oracle.com>
---
mount.ocfs2/mount.ocfs2.c | 28 +++++++++++++---------------
1 files changed, 13 insertions(+), 15 deletions(-)
diff --git a/mount.ocfs2/mount.ocfs2.c b/mount.ocfs2/mount.ocfs2.c
index c104172..98dc54e 100644
--- a/mount.ocfs2/mount.ocfs2.c
+++ b/mount.ocfs2/mount.ocfs2.c
@@ -393,6 +393,17 @@ int main(int argc, char **argv)
goto bail;
}
+ /* validate mount dir */
+ if (lstat(mo.dir, &statbuf))
+ com_err(progname, 0, "mount directory %s does not exist",
+ mo.dir);
+ else if (stat(mo.dir, &statbuf))
+ com_err(progname, 0, "mount directory %s is a broken symbolic "
+ "link", mo.dir);
+ else if (!S_ISDIR(statbuf.st_mode))
+ com_err(progname, 0, "mount directory %s is not a directory",
+ mo.dir);
+
block_signals (SIG_BLOCK);
if (!(mo.flags & MS_REMOUNT) && !dev_ro && clustered) {
@@ -417,21 +428,8 @@ int main(int argc, char **argv)
o2cb_complete_group_join(&cluster, &desc, errno);
}
block_signals (SIG_UNBLOCK);
-
- /* 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 "
- "broken symbolic link", mo.dir);
- else if (!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);
+ com_err(progname, ret, "while mounting %s on %s. Check 'dmesg' "
+ "for more information on this error.", mo.dev, mo.dir);
goto bail;
}
if (group_join) {
--
1.7.0.4
More information about the Ocfs2-tools-devel
mailing list