From: Theodore Ts'o Date: Tue, 19 Jul 2005 20:04:22 +0000 (-0500) Subject: Check for a busy device when creating a journal. X-Git-Tag: E2FSPROGS-1.39-WIP-1210~45 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=29af314d3fd4cb907a4f474645e04bd26ba66f5f;p=thirdparty%2Fe2fsprogs.git Check for a busy device when creating a journal. In ext2fs_add_journal_inode() check for the case where the filesystem appears to be unmounted, but the device is still apparently busy. This can happen when the luser doesn't bother to mount /proc and has a bogus /etc/mtab, but still wants to mount the filesystem before using tune2fs(?!?). Add a safety check to save him from his own stupidity, at least on 2.6 kernels. (Addresses Debian Bug #319002) Signed-off-by: "Theodore Ts'o" --- diff --git a/lib/ext2fs/ChangeLog b/lib/ext2fs/ChangeLog index 58e29a9b3..b586a6b26 100644 --- a/lib/ext2fs/ChangeLog +++ b/lib/ext2fs/ChangeLog @@ -1,3 +1,12 @@ +2005-07-19 Theodore Ts'o + + * mkjournal.c (ext2fs_add_journal_inode): Check for the case where + the filesystem is apparently not mounted, but the device + is still busy. This can happy when the luser doesn't + bother to mount /proc and has a bogus /etc/mtab. Add a + safety check to save him from his own stupidity, at least + on 2.6 kernels. (Addresses Debian Bug #319002) + 2005-07-09 Andreas Dilger * getsize.c (ext2fs_get_device_size): Use fstat/fstat64 to get diff --git a/lib/ext2fs/mkjournal.c b/lib/ext2fs/mkjournal.c index 427a08e72..76ed5cbbe 100644 --- a/lib/ext2fs/mkjournal.c +++ b/lib/ext2fs/mkjournal.c @@ -369,6 +369,10 @@ errcode_t ext2fs_add_journal_inode(ext2_filsys fs, blk_t size, int flags) close(fd); journal_ino = st.st_ino; } else { + if (mount_flags & EXT2_MF_BUSY) { + retval = EBUSY; + goto errout; + } journal_ino = EXT2_JOURNAL_INO; if ((retval = write_journal_inode(fs, journal_ino, size, flags)))