[Ocfs2-tools-devel] [PATCH 27/27] mount.ocfs2: Validate mount path before mount
Sunil Mushran
sunil.mushran at oracle.com
Thu Jul 1 17:35:05 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 | 32 +++++++++++++++++---------------
1 files changed, 17 insertions(+), 15 deletions(-)
diff --git a/mount.ocfs2/mount.ocfs2.c b/mount.ocfs2/mount.ocfs2.c
index 6e15363..5d97b6b 100644
--- a/mount.ocfs2/mount.ocfs2.c
+++ b/mount.ocfs2/mount.ocfs2.c
@@ -405,6 +405,21 @@ 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);
+ goto bail;
+ } else if (stat(mo.dir, &statbuf)) {
+ com_err(progname, 0, "mount directory %s is a broken symbolic "
+ "link", mo.dir);
+ goto bail;
+ } else if (!S_ISDIR(statbuf.st_mode)) {
+ com_err(progname, 0, "mount directory %s is not a directory",
+ mo.dir);
+ goto bail;
+ }
+
block_signals (SIG_BLOCK);
if (!(mo.flags & MS_REMOUNT) && !dev_ro && clustered) {
@@ -429,21 +444,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