From: Theodore Ts'o Date: Sat, 4 May 2013 23:07:18 +0000 (-0400) Subject: e2fsck: don't use IO_FLAG_EXCLUSIVE for read-only root file systems X-Git-Tag: v1.42.8~20 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=26991d026e4b555229a4466ae4d003420321bbd2;p=thirdparty%2Fe2fsprogs.git e2fsck: don't use IO_FLAG_EXCLUSIVE for read-only root file systems When opening the external journal, use the same logic to decide whether or not to open the file system with EXT2_FLAG_EXCLUSIVE found in main(). Otherwise, it's not posible to use e2fsck when the root file system is using an external journal. Reported-by: Calvin Owens Signed-off-by: "Theodore Ts'o" --- diff --git a/e2fsck/journal.c b/e2fsck/journal.c index 767ea105f..69771da6f 100644 --- a/e2fsck/journal.c +++ b/e2fsck/journal.c @@ -372,9 +372,19 @@ static errcode_t e2fsck_get_journal(e2fsck_t ctx, journal_t **ret_journal) #ifndef USE_INODE_IO if (ext_journal) #endif - retval = io_ptr->open(journal_name, - IO_FLAG_RW | IO_FLAG_EXCLUSIVE, + { + int flags = IO_FLAG_RW; + if (!(ctx->mount_flags & EXT2_MF_ISROOT && + ctx->mount_flags & EXT2_MF_READONLY)) + flags |= IO_FLAG_EXCLUSIVE; + if ((ctx->mount_flags & EXT2_MF_READONLY) && + (ctx->options & E2F_OPT_FORCE)) + flags &= ~IO_FLAG_EXCLUSIVE; + + + retval = io_ptr->open(journal_name, flags, &ctx->journal_io); + } if (retval) goto errout;