From patchwork Tue Sep 8 03:55:52 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Sandeen X-Patchwork-Id: 33111 Return-Path: X-Original-To: patchwork-incoming@bilbo.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from ozlabs.org (ozlabs.org [203.10.76.45]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "mx.ozlabs.org", Issuer "CA Cert Signing Authority" (verified OK)) by bilbo.ozlabs.org (Postfix) with ESMTPS id 3E73FB708C for ; Tue, 8 Sep 2009 13:56:19 +1000 (EST) Received: by ozlabs.org (Postfix) id 32C3ADDD0B; Tue, 8 Sep 2009 13:56:19 +1000 (EST) Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by ozlabs.org (Postfix) with ESMTP id B8039DDD04 for ; Tue, 8 Sep 2009 13:56:18 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753388AbZIHDzu (ORCPT ); Mon, 7 Sep 2009 23:55:50 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1753420AbZIHDzu (ORCPT ); Mon, 7 Sep 2009 23:55:50 -0400 Received: from sandeen.net ([209.173.210.139]:27208 "EHLO mail.sandeen.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753388AbZIHDzu (ORCPT ); Mon, 7 Sep 2009 23:55:50 -0400 Received: from liberator.sandeen.net (liberator.sandeen.net [10.0.0.4]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.sandeen.net (Postfix) with ESMTP id 09307AAE393; Mon, 7 Sep 2009 22:55:48 -0500 (CDT) Message-ID: <4AA5D5C8.2010304@redhat.com> Date: Mon, 07 Sep 2009 22:55:52 -0500 From: Eric Sandeen User-Agent: Thunderbird 2.0.0.23 (Macintosh/20090812) MIME-Version: 1.0 To: Ravi Pinjala CC: linux-ext4@vger.kernel.org Subject: Re: e4defrag doesn't work on root filesystem References: <4AA52B31.5090205@p-static.net> In-Reply-To: <4AA52B31.5090205@p-static.net> Sender: linux-ext4-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org Ravi Pinjala wrote: > 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 > -- > 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? --- To unsubscribe from this list: send the line "unsubscribe linux-ext4" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html ========= Skip "rootfs" entry when checking for ext4 filesystem. Signed-off-by: Eric Sandeen --- diff --git a/misc/e4defrag.c b/misc/e4defrag.c index 82e3868..0d04df9 100644 --- a/misc/e4defrag.c +++ b/misc/e4defrag.c @@ -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)