mirror of https://github.com/vitalif/e2fsprogs
tune2fs: Fix "tune2fs -j <dev>" for extent-enabled filesystems
For filesystms that have the extent feature enabled, we need to grab the use EXT2_IOC_GETFLAGS so that we don't accidentally end up trying to request clearing the EXT2_EXTENT_FL, which is not supported and causes the tune2fs -j error out. Also fix the error returning in ext2fs_add_journal_inode() so it returns a proper error code if the fstat() or ioctl() calls fail. Addresses-Launchpad-bug: #416648 Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>bitmap-optimize
parent
31b5a2b961
commit
8bafedbf4a
|
@ -494,21 +494,33 @@ errcode_t ext2fs_add_journal_inode(ext2_filsys fs, blk_t size, int flags)
|
||||||
goto errout;
|
goto errout;
|
||||||
|
|
||||||
/* Get inode number of the journal file */
|
/* Get inode number of the journal file */
|
||||||
if (fstat(fd, &st) < 0)
|
if (fstat(fd, &st) < 0) {
|
||||||
|
retval = errno;
|
||||||
goto errout;
|
goto errout;
|
||||||
|
}
|
||||||
|
|
||||||
#if defined(HAVE_CHFLAGS) && defined(UF_NODUMP)
|
#if defined(HAVE_CHFLAGS) && defined(UF_NODUMP)
|
||||||
retval = fchflags (fd, UF_NODUMP|UF_IMMUTABLE);
|
retval = fchflags (fd, UF_NODUMP|UF_IMMUTABLE);
|
||||||
#else
|
#else
|
||||||
#if HAVE_EXT2_IOCTLS
|
#if HAVE_EXT2_IOCTLS
|
||||||
f = EXT2_NODUMP_FL | EXT2_IMMUTABLE_FL;
|
if (ioctl(fd, EXT2_IOC_GETFLAGS, &f) < 0) {
|
||||||
|
retval = errno;
|
||||||
|
goto errout;
|
||||||
|
}
|
||||||
|
f |= EXT2_NODUMP_FL | EXT2_IMMUTABLE_FL;
|
||||||
retval = ioctl(fd, EXT2_IOC_SETFLAGS, &f);
|
retval = ioctl(fd, EXT2_IOC_SETFLAGS, &f);
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
if (retval)
|
if (retval) {
|
||||||
|
retval = errno;
|
||||||
goto errout;
|
goto errout;
|
||||||
|
}
|
||||||
|
|
||||||
close(fd);
|
if (close(fd) < 0) {
|
||||||
|
retval = errno;
|
||||||
|
fd = -1;
|
||||||
|
goto errout;
|
||||||
|
}
|
||||||
journal_ino = st.st_ino;
|
journal_ino = st.st_ino;
|
||||||
} else {
|
} else {
|
||||||
if ((mount_flags & EXT2_MF_BUSY) &&
|
if ((mount_flags & EXT2_MF_BUSY) &&
|
||||||
|
|
Loading…
Reference in New Issue