summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTheodore Ts'o <tytso@mit.edu>2006-03-18 20:01:09 -0500
committerTheodore Ts'o <tytso@mit.edu>2006-03-18 20:01:09 -0500
commit2e14e0c8cc5bc61ffacd380a981808194e9c7f84 (patch)
tree2c648ed6624ac3b6cbddb09718f9e3214373072e
parent98eb44bdb5749f323a858d71bf5e7f0eddb61191 (diff)
downloade2fsprogs-2e14e0c8cc5bc61ffacd380a981808194e9c7f84.tar.gz
Change e2fsck to open non-mounted filesystems in exclusive mode
Thanks to Andreas Dilger for this idea. If the filesystem is not mounted, e2fsck will open it in exclusive mode to prevent the a confused/careless system administrator from mounting the filesystem while the filesystem check is taking place, which could cause all sorts of problems. Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
-rw-r--r--e2fsck/ChangeLog6
-rw-r--r--e2fsck/unix.c5
2 files changed, 11 insertions, 0 deletions
diff --git a/e2fsck/ChangeLog b/e2fsck/ChangeLog
index 7facefa8..dee29924 100644
--- a/e2fsck/ChangeLog
+++ b/e2fsck/ChangeLog
@@ -1,3 +1,9 @@
+2006-03-18 Theodore Ts'o <tytso@mit.edu>
+
+ * unix.c (main): If the filesystem is not mounted, open the
+ filesystem in exclusive mode (to prevent 2.6 kernels from
+ mounting the filesystem while it is being checked).
+
2006-03-10 Theodore Ts'o <tytso@mit.edu>
* e2fsck.h, journal.c (e2fsck_fix_ext3_journal_hint),
diff --git a/e2fsck/unix.c b/e2fsck/unix.c
index b3db14c9..d2bc5945 100644
--- a/e2fsck/unix.c
+++ b/e2fsck/unix.c
@@ -910,6 +910,8 @@ restart:
flags = 0;
if ((ctx->options & E2F_OPT_READONLY) == 0)
flags |= EXT2_FLAG_RW;
+ if ((ctx->mount_flags & EXT2_MF_MOUNTED) == 0)
+ flags |= EXT2_FLAG_EXCLUSIVE;
if (ctx->superblock && ctx->blocksize) {
retval = ext2fs_open2(ctx->filesystem_name, ctx->io_options,
@@ -961,6 +963,9 @@ restart:
"r/o" : "r/w");
else if (retval == ENXIO)
printf(_("Possibly non-existent or swap device?\n"));
+ else if (retval == EBUSY)
+ printf(_("Filesystem mounted or opened exclusively "
+ "by another program?\n"));
#ifdef EROFS
else if (retval == EROFS)
printf(_("Disk write-protected; use the -n option "