e4defrag doesn't work on root filesystem
Hi,
I'm playing with e4defrag from e2frprogs git, and I've run into a bug. When I try to defragment files on my root filesystem, it refuses to acknowledge that the filesystem is ext4. I believe the problem is that it checks the filesystem type by parsing /etc/mtab, but the root filesystem shows up there like this:
rootfs on / type rootfs (rw)/dev/root on / type ext4 (rw,noatime,barrier=1,data=ordered)
so it gets confused by the bogus first entry. It works just fine on other ext4 filesystems I have.
(If this is the wrong mailing list, I apologize; I couldn't find one for e2fsprogs, so I thought this was the next best thing.)
--Ravi
Quoted 11 lines · Ravi Pinjala
Hi,
I'm playing with e4defrag from e2frprogs git, and I've run into a bug. When I try to defragment files on my root filesystem, it refuses to acknowledge that the filesystem is ext4. I believe the problem is that it checks the filesystem type by parsing
/etc/mtab, but the root filesystem shows up there like this:rootfs on / type rootfs (rw)
/dev/rooton / type ext4 (rw,noatime,barrier=1,data=ordered)
Quoted 9 lines
so it gets confused by the bogus first entry. It works just fine on other ext4 filesystems I have.
(If this is the wrong mailing list, I apologize; I couldn't find one for e2fsprogs, so I thought this was the next best thing.)
--Ravi
--
This list is a fine place to report it, thanks.
In is_ext4() it does a statfs on the file, and checks that the magic is EXT4, but then that's the same as ext2 and ext3 unfortunately ....
It later does getmntent for the actual fs type, but fails, as you said.
Does this fix it for you?
=========
Skip "rootfs" entry when checking for ext4 filesystem.
---
misc/e4defrag.c +0 -0
@@ -430,6 +430,8 @@ static int is_ext4(const char *file)
}
while ((mnt = getmntent(fp)) != NULL) {
+ if (mnt->mnt_fsname[0] != '/')
+ continue;
len = strlen(mnt->mnt_dir);
ret = memcmp(file_path, mnt->mnt_dir, len);
if (ret != 0)Quoted 23 lines · Eric Sandeen
Quoted 11 lines · Ravi Pinjala
Hi,
I'm playing with e4defrag from e2frprogs git, and I've run into a bug. When I try to defragment files on my root filesystem, it refuses to acknowledge that the filesystem is ext4. I believe the problem is that it checks the filesystem type by parsing
/etc/mtab, but the root filesystem shows up there like this:rootfs on / type rootfs (rw)
/dev/rooton / type ext4 (rw,noatime,barrier=1,data=ordered)Quoted 9 lines
so it gets confused by the bogus first entry. It works just fine on other ext4 filesystems I have.
(If this is the wrong mailing list, I apologize; I couldn't find one for e2fsprogs, so I thought this was the next best thing.)
--Ravi
This list is a fine place to report it, thanks.
Quoted 7 lines
In
is_ext4()it does a statfs on the file, and checks that the magic is EXT4,
but then that's the same as ext2 and ext3 unfortunately ....It later does getmntent for the actual fs type, but fails, as you said.
Does this fix it for you?
Yeah, that works great. Thanks!
--Ravi
Quoted 28 lines
=========
Skip "rootfs" entry when checking for ext4 filesystem.
Signed-off-by Eric Sandeen <[email protected]>---
misc/e4defrag.c +2
-0@@ -430,6 +430,8 @@ static int is_ext4(const char *file) }while ((mnt =getmntent (fp)) !=NULL ) { +if (mnt->mnt_fsname[0 ] !='/' ) +continue ; len =strlen (mnt->mnt_dir); ret =memcmp (file_path, mnt->mnt_dir, len);if (ret !=0 )Signature · 4 lines
-- To unsubscribe from this list: send the line "unsubscribe linux-ext4" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html