From unknown Thu Jun 19 12:19:43 2025 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-Mailer: MIME-tools 5.509 (Entity 5.509) Content-Type: text/plain; charset=utf-8 From: bug#16539 <16539@debbugs.gnu.org> To: bug#16539 <16539@debbugs.gnu.org> Subject: Status: df command, possible bug? Reply-To: bug#16539 <16539@debbugs.gnu.org> Date: Thu, 19 Jun 2025 19:19:43 +0000 retitle 16539 df command, possible bug? reassign 16539 coreutils submitter 16539 crubel@compro.net severity 16539 normal thanks From debbugs-submit-bounces@debbugs.gnu.org Fri Jan 24 15:38:55 2014 Received: (at submit) by debbugs.gnu.org; 24 Jan 2014 20:38:55 +0000 Received: from localhost ([127.0.0.1]:34878 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1W6nWh-0002Bm-8B for submit@debbugs.gnu.org; Fri, 24 Jan 2014 15:38:55 -0500 Received: from eggs.gnu.org ([208.118.235.92]:38982) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1W6nOL-0001xi-Bs for submit@debbugs.gnu.org; Fri, 24 Jan 2014 15:30:17 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1W6nOC-0002dW-Fl for submit@debbugs.gnu.org; Fri, 24 Jan 2014 15:30:16 -0500 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=0.8 required=5.0 tests=BAYES_50 autolearn=disabled version=3.3.2 Received: from lists.gnu.org ([2001:4830:134:3::11]:47079) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W6nOC-0002aO-DQ for submit@debbugs.gnu.org; Fri, 24 Jan 2014 15:30:08 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38569) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W6nHU-0007Yp-TZ for bug-coreutils@gnu.org; Fri, 24 Jan 2014 15:23:17 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1W6nHO-0000P9-7B for bug-coreutils@gnu.org; Fri, 24 Jan 2014 15:23:12 -0500 Received: from admin.comprocs.com ([12.186.155.30]:64505 helo=mx2.compro.net) by eggs.gnu.org with smtp (Exim 4.71) (envelope-from ) id 1W6nHO-0000Oi-3G for bug-coreutils@gnu.org; Fri, 24 Jan 2014 15:23:06 -0500 X-BYPSHEADER: 35740729 X-SMScore: -250 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Date: Fri, 24 Jan 2014 15:23:02 -0500 From: Curtis Rubel To: Subject: df command, possible =?UTF-8?Q?bug=3F?= Organization: Compro Computer Services, Inc. Mail-Reply-To: Message-ID: <67f0ced2351b31a6ac4523659f306b25@msmail.compro.net> X-Sender: crubel@compro.net User-Agent: Roundcube Webmail/0.8.4 X-detected-operating-system: by eggs.gnu.org: iOS iPhone or iPad X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2001:4830:134:3::11 X-Spam-Score: -4.1 (----) X-Debbugs-Envelope-To: submit X-Mailman-Approved-At: Fri, 24 Jan 2014 15:38:53 -0500 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list Reply-To: crubel@compro.net List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -4.1 (----) The df command as distributed with OpenSuSE 13.1 -- package coreutils-8.21-7.8.1.x86_64 does not return all currently mounted nfs mounts when specifying the command with no command line arguments. Specifying the df command: df -at nfs works perfectly and returns the data for all mounted nfs filesystems. uname -a output for your reference: Linux otw-l0 3.11.6-4-desktop #1 SMP PREEMPT Wed Oct 30 18:04:56 UTC 2013 (e6d4a27) x86_64 x86_64 x86_64 GNU/Linux If you need further information please let me know. Thank you, Curtis -- Curtis Rubel Senior Development Engineer Compro Computer Services, Inc. 105 East Drive - Melbourne, Florida, 32904 Phone: 321-727-2211 email: crubel@compro.net Web: http://www.compro.net "An ISO 9001:2008 Registered Company" From debbugs-submit-bounces@debbugs.gnu.org Fri Jan 24 15:47:19 2014 Received: (at 16539) by debbugs.gnu.org; 24 Jan 2014 20:47:19 +0000 Received: from localhost ([127.0.0.1]:34892 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1W6nep-0002Qh-7q for submit@debbugs.gnu.org; Fri, 24 Jan 2014 15:47:19 -0500 Received: from admin.compro.net ([12.186.155.30]:64861 helo=mx2.compro.net) by debbugs.gnu.org with smtp (Exim 4.80) (envelope-from ) id 1W6nem-0002QY-Nc for 16539@debbugs.gnu.org; Fri, 24 Jan 2014 15:47:17 -0500 X-BYPSHEADER: 26185162 X-SMScore: -250 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Date: Fri, 24 Jan 2014 15:47:14 -0500 From: Curtis Rubel To: <16539@debbugs.gnu.org> Subject: More details on df command output for you Organization: Compro Computer Services, Inc. Mail-Reply-To: Message-ID: <3ce9319232fc3427c2ecefb1d68df226@msmail.compro.net> X-Sender: crubel@compro.net User-Agent: Roundcube Webmail/0.8.4 X-Spam-Score: -0.6 (/) X-Debbugs-Envelope-To: 16539 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list Reply-To: crubel@compro.net List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.6 (/) df command output with no args: only 1 nfs mount is listed amx@otw-l0:~> df Filesystem 1K-blocks Used Available Use% Mounted on /dev/sda3 173232952 44850568 127310032 27% / devtmpfs 4049732 32 4049700 1% /dev tmpfs 4095336 76 4095260 1% /dev/shm tmpfs 4095336 4688 4090648 1% /run tmpfs 4095336 0 4095336 0% /sys/fs/cgroup tmpfs 4095336 4688 4090648 1% /var/run tmpfs 4095336 4688 4090648 1% /var/lock /dev/sda1 1035084 45272 920848 5% /boot host:/usr/local/bin 110217536 40202928 68990448 37% /usr/local/muse amx@otw-l0:~> df command with options to show nfs mounted filesystems showing all nfs mounts. amx@otw-l0:~> df -at nfs Filesystem 1K-blocks Used Available Use% Mounted on host:/usr/local/muse 110217536 40203472 68989896 37% /usr/local/muse host:/usr/local/LINUX_FILES 110217536 40203472 68989896 37% /usr/local/LINUX_FILES host:/usr/local/3rdparty 110217536 40203472 68989896 37% /usr/local/3rdparty amx@otw-l0:~> Thank you. -- Curtis Rubel Senior Development Engineer Compro Computer Services, Inc. 105 East Drive - Melbourne, Florida, 32904 Phone: 321-727-2211 email: crubel@compro.net Web: http://www.compro.net "An ISO 9001:2008 Registered Company" --------------------------------------------------------------------------- CONFIDENTIALITY NOTICE: This email transmission, and any documents, files or previous email messages attached to it may contain confidential information that is legally privileged. If you are not the intended recipient or a person responsible for delivering it to the intended recipient, you are hereby notified that any disclosure, copying, distribution, or use of any of the information contained in or attached to this transmission is STRICTLY PROHIBITED. If you have received this transmission in error, please immediately notify the sender by email or call 321-727-2211. Please destroy the original transmission and its attachments without reading or saving it in any manner. From debbugs-submit-bounces@debbugs.gnu.org Fri Jan 24 17:27:23 2014 Received: (at 16539-done) by debbugs.gnu.org; 24 Jan 2014 22:27:23 +0000 Received: from localhost ([127.0.0.1]:34945 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1W6pDe-0006MX-UD for submit@debbugs.gnu.org; Fri, 24 Jan 2014 17:27:23 -0500 Received: from moutng.kundenserver.de ([212.227.126.187]:53717) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1W6pDc-0006ML-Ah for 16539-done@debbugs.gnu.org; Fri, 24 Jan 2014 17:27:21 -0500 Received: from [192.168.1.11] (p5499CDA4.dip0.t-ipconnect.de [84.153.205.164]) by mrelayeu.kundenserver.de (node=mreu2) with ESMTP (Nemesis) id 0MEaVh-1W4sKM2POL-00FrSx; Fri, 24 Jan 2014 23:27:11 +0100 Message-ID: <52E2E8BF.1000700@bernhard-voelker.de> Date: Fri, 24 Jan 2014 23:27:11 +0100 From: Bernhard Voelker User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.2.0 MIME-Version: 1.0 To: crubel@compro.net, 16539-done@debbugs.gnu.org Subject: Re: bug#16539: More details on df command output for you References: <67f0ced2351b31a6ac4523659f306b25@msmail.compro.net> <3ce9319232fc3427c2ecefb1d68df226@msmail.compro.net> In-Reply-To: <3ce9319232fc3427c2ecefb1d68df226@msmail.compro.net> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Provags-ID: V02:K0:BSaiibixKieEIS45KBOAjMe3+c4pDW4xuApueIWW08s Vi41rtKBYxCUGXdB7/PH/+R1z0rzifeC3AMYe2nosnjIpsr/aJ lwFPOlCFDSUBYQkIkbIAnTEvHM4RcVcWJ7r/VIMUz5yrwdvgPE idutyrRAhAlM/kbWtqWxsbhNUoEwBUt6oZJOApzhUYKd8inWAs 0/xtAyGRkU6Rr6rtO2gFdvBTCVbNi/9dURf9GSMTXMGyutf2dL 9cMunPT7g+DCkXZDtaawjFeIjaTShUJFVjyTrtJvEuGFeZYATE bs+4YcWaKsHItM5I03DTaey95xXzSRi5y6AI81XmWUk+ip2Xfp UWu5VtxP0D4lnJTSPyi2w19PUaN/U5tsNnu5xEW9J X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 16539-done X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.0 (/) tag 16539 notabug close thanks On 01/24/2014 09:47 PM, Curtis Rubel wrote: > > df command output with no args: > > only 1 nfs mount is listed > > amx@otw-l0:~> df > Filesystem 1K-blocks Used Available Use% Mounted on > /dev/sda3 173232952 44850568 127310032 27% / > devtmpfs 4049732 32 4049700 1% /dev > tmpfs 4095336 76 4095260 1% /dev/shm > tmpfs 4095336 4688 4090648 1% /run > tmpfs 4095336 0 4095336 0% /sys/fs/cgroup > tmpfs 4095336 4688 4090648 1% /var/run > tmpfs 4095336 4688 4090648 1% /var/lock > /dev/sda1 1035084 45272 920848 5% /boot > host:/usr/local/bin 110217536 40202928 68990448 37% /usr/local/muse > amx@otw-l0:~> > > > df command with options to show nfs mounted filesystems > showing all nfs mounts. > > amx@otw-l0:~> df -at nfs > Filesystem 1K-blocks Used Available Use% Mounted > on > host:/usr/local/muse 110217536 40203472 68989896 37% > /usr/local/muse > host:/usr/local/LINUX_FILES 110217536 40203472 68989896 37% > /usr/local/LINUX_FILES > host:/usr/local/3rdparty 110217536 40203472 68989896 37% > /usr/local/3rdparty > amx@otw-l0:~> Just for info: df in openSUSE-13.1 is currently identical to that in coreutils-v8.21. The above is the result of df suppressing duplicate entries like bind mounts. This filtering is done based on the device number. As this example shows, a few exports of directories of the same file system from "host" are mounted - yet it's the same file system. We already had a few discussions about this filtering of duplicate mount entries. For me, this example shows that the current implementation is not that bad because df's job is to show block and inode usage statistics about mounted file systems. When it comes to information about mount points, then I think findmnt(1) from util-linux is the right tool. I'm therefore tagging this bug as "notabug" and mark it as done. If you or someone else wants to continue this discussion, then this can of course be done in this thread. And if someone has the *golden* idea how to solve this problem, then just stand up and let use know. Have a nice day, Berny From debbugs-submit-bounces@debbugs.gnu.org Fri Jan 24 22:20:22 2014 Received: (at 16539) by debbugs.gnu.org; 25 Jan 2014 03:20:22 +0000 Received: from localhost ([127.0.0.1]:35009 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1W6tnA-0008PY-Kx for submit@debbugs.gnu.org; Fri, 24 Jan 2014 22:20:21 -0500 Received: from mail2.vodafone.ie ([213.233.128.44]:31655) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1W6tn5-0008PJ-1p for 16539@debbugs.gnu.org; Fri, 24 Jan 2014 22:20:17 -0500 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: ApQBAGMs41JtTPUT/2dsb2JhbAANTYNEg1O5SIEfgxkBAQEDASMEVwsLDQQDAQIBCRYLAgIJAwIBAgE9CAcMBgIBARYEh18NqyN2nQEXjkM4DAyCb4FJAQOQPY5ZjlyBaQ Received: from unknown (HELO [192.168.1.79]) ([109.76.245.19]) by mail2.vodafone.ie with ESMTP; 25 Jan 2014 03:20:13 +0000 Message-ID: <52E32D5D.2030900@draigBrady.com> Date: Sat, 25 Jan 2014 03:19:57 +0000 From: =?UTF-8?B?UMOhZHJhaWcgQnJhZHk=?= User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130110 Thunderbird/17.0.2 MIME-Version: 1.0 To: 16539@debbugs.gnu.org, mail@bernhard-voelker.de, crubel@compro.net Subject: Re: bug#16539: More details on df command output for you References: <67f0ced2351b31a6ac4523659f306b25@msmail.compro.net> <3ce9319232fc3427c2ecefb1d68df226@msmail.compro.net> <52E2E8BF.1000700@bernhard-voelker.de> In-Reply-To: <52E2E8BF.1000700@bernhard-voelker.de> X-Enigmail-Version: 1.6 Content-Type: multipart/mixed; boundary="------------020905060000010807090909" X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 16539 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 0.0 (/) This is a multi-part message in MIME format. --------------020905060000010807090909 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit On 01/24/2014 10:27 PM, Bernhard Voelker wrote: > tag 16539 notabug > close > thanks > > On 01/24/2014 09:47 PM, Curtis Rubel wrote: >> >> df command output with no args: >> >> only 1 nfs mount is listed > Just for info: df in openSUSE-13.1 is currently identical to that > in coreutils-v8.21. > > The above is the result of df suppressing duplicate entries like > bind mounts. This filtering is done based on the device number. > As this example shows, a few exports of directories of the same file > system from "host" are mounted - yet it's the same file system. Right. Essentially df is showing storage for available file systems. Noting that df also has a --total option, it makes sense by default to not repeat file systems. This can be overridden easily with the -a option as noted above. Actually we should in fact be merging more entries! Notice the following: >> tmpfs 4095336 4688 4090648 1% /run >> tmpfs 4095336 4688 4090648 1% /var/run >> tmpfs 4095336 4688 4090648 1% /var/lock Hopefully the attached patch addresses this (and a couple of other test issues). thanks, Pádraig. --------------020905060000010807090909 Content-Type: text/x-patch; name="df-tmpfs-merge.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="df-tmpfs-merge.patch" >From 5991616451187db13ea9731ac06101081af8ccda Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C3=A1draig=20Brady?= Date: Sat, 25 Jan 2014 01:14:29 +0000 Subject: [PATCH] df: also deduplicate virtual file systems * src/df.c (filter_mountlist): Remove the constraint that a '/' needs to be in the device name for a mount entry to be considered for deduplication. Virtual file systems also have storage associated with them (like tmpfs for example), and thus need to be deduplicated since they will be shown in the default df output and subject to --total processing also. * test/df/skip-duplicates.sh: Add a test to ensure we deduplicate all entries, even for virtual file systems. Also avoid possible length operations on many remote file systems in the initial check of df operation. Also avoid the assumption that "/root" is on the same file system as "/". * NEWS: Mention the change in behavior. --- NEWS | 5 ++++ src/df.c | 31 +++++++++++++---------------- tests/df/skip-duplicates.sh | 45 ++++++++++++++++++++++++++++++------------ 3 files changed, 51 insertions(+), 30 deletions(-) diff --git a/NEWS b/NEWS index 88a4154..2bf110a 100644 --- a/NEWS +++ b/NEWS @@ -18,6 +18,11 @@ GNU coreutils NEWS -*- outline -*- it would display an error, requiring --no-dereference to avoid the issue. [bug introduced in coreutils-5.3.0] +** Changes in behavior + + df now properly outputs file system information for virtual file systems + like tmpfs, by skipping duplicate entries (identified by the device number). + * Noteworthy changes in release 8.22 (2013-12-13) [stable] diff --git a/src/df.c b/src/df.c index e4fafb9..23b5156 100644 --- a/src/df.c +++ b/src/df.c @@ -630,26 +630,23 @@ filter_mount_list (void) } else { - /* If the device name is a real path name ... */ - if (strchr (me->me_devname, '/')) + /* If we've already seen this device... */ + for (devlist = devlist_head; devlist; devlist = devlist->next) + if (devlist->dev_num == buf.st_dev) + break; + + if (devlist) { - /* ... try to find its device number in the devlist. */ - for (devlist = devlist_head; devlist; devlist = devlist->next) - if (devlist->dev_num == buf.st_dev) - break; + discard_me = me; - if (devlist) + /* ...let the shorter mountdir win. */ + if ((strchr (me->me_devname, '/') + && ! strchr (devlist->me->me_devname, '/')) + || (strlen (devlist->me->me_mountdir) + > strlen (me->me_mountdir))) { - discard_me = me; - - /* Let the shorter mountdir win. */ - if (! strchr (devlist->me->me_devname, '/') - || (strlen (devlist->me->me_mountdir) - > strlen (me->me_mountdir))) - { - discard_me = devlist->me; - devlist->me = me; - } + discard_me = devlist->me; + devlist->me = me; } } } diff --git a/tests/df/skip-duplicates.sh b/tests/df/skip-duplicates.sh index 266520a..b41623f 100755 --- a/tests/df/skip-duplicates.sh +++ b/tests/df/skip-duplicates.sh @@ -21,19 +21,26 @@ print_ver_ df require_gcc_shared_ -df || skip_ "df fails" +# We use --local here so as to not activate +# potentially very many remote mounts. +df --local || skip_ "df fails" -# Simulate an mtab file with two entries of the same device number. -# Also add entries with unstatable mount dirs to ensure that's handled. +export CU_NONROOT_FS=$(df --local --output=target 2>&1 | grep /. | head -n1) +test -z "$CU_NONROOT_FS" && unique_entries=1 || unique_entries=2 + +# Simulate an mtab file to test various cases. cat > k.c <<'EOF' || framework_failure_ #include #include +#include #include struct mntent *getmntent (FILE *fp) { + static char *nonroot_fs; + static int done; + /* Prove that LD_PRELOAD works. */ - static int done = 0; if (!done) { fclose (fopen ("x", "w")); @@ -43,18 +50,30 @@ struct mntent *getmntent (FILE *fp) static struct mntent mntents[] = { {.mnt_fsname="/short", .mnt_dir="/invalid/mount/dir"}, {.mnt_fsname="fsname", .mnt_dir="/",}, - {.mnt_fsname="/fsname", .mnt_dir="/root"}, + {.mnt_fsname="/fsname", .mnt_dir="/."}, {.mnt_fsname="/fsname", .mnt_dir="/"}, + {.mnt_fsname="virtfs", .mnt_dir="/NONROOT"}, + {.mnt_fsname="virtfs", .mnt_dir="/NONROOT"}, }; - if (!getenv ("CU_TEST_DUPE_INVALID") && done == 1) + if (done == 1) + { + nonroot_fs = getenv ("CU_NONROOT_FS"); + if (!nonroot_fs || !*nonroot_fs) + nonroot_fs = "/"; /* merge into / entries. */ + } + + if (done == 1 && !getenv ("CU_TEST_DUPE_INVALID")) done++; /* skip the first entry. */ - while (done++ <= 4) + while (done++ <= 6) { mntents[done-2].mnt_type = "-"; + if (strcmp (mntents[done-2].mnt_dir, "/NONROOT") == 0) + mntents[done-2].mnt_dir = nonroot_fs; return &mntents[done-2]; } + return NULL; } EOF @@ -69,22 +88,22 @@ test -f x || skip_ "internal test failure: maybe LD_PRELOAD doesn't work?" # The fake mtab file should only contain entries # having the same device number; thus the output should -# consist of a header and one entry. +# consist of a header and unique entries. LD_PRELOAD=./k.so df >out || fail=1 -test $(wc -l out && fail=1 -test $(wc -l out || fail=1 -test $(wc -l ) id 1W7D4Q-0007z3-0l for submit@debbugs.gnu.org; Sat, 25 Jan 2014 18:55:26 -0500 Received: from moutng.kundenserver.de ([212.227.126.187]:50841) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1W7D4L-0007yl-7w for 16539@debbugs.gnu.org; Sat, 25 Jan 2014 18:55:22 -0500 Received: from [192.168.1.11] (p5499CDA4.dip0.t-ipconnect.de [84.153.205.164]) by mrelayeu.kundenserver.de (node=mreu0) with ESMTP (Nemesis) id 0MIAsE-1W8qQk47nq-003aL2; Sun, 26 Jan 2014 00:55:17 +0100 Message-ID: <52E44EE4.9020503@bernhard-voelker.de> Date: Sun, 26 Jan 2014 00:55:16 +0100 From: Bernhard Voelker User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.2.0 MIME-Version: 1.0 To: =?UTF-8?B?UMOhZHJhaWcgQnJhZHk=?= , 16539@debbugs.gnu.org, crubel@compro.net Subject: Re: bug#16539: More details on df command output for you References: <67f0ced2351b31a6ac4523659f306b25@msmail.compro.net> <3ce9319232fc3427c2ecefb1d68df226@msmail.compro.net> <52E2E8BF.1000700@bernhard-voelker.de> <52E32D5D.2030900@draigBrady.com> In-Reply-To: <52E32D5D.2030900@draigBrady.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Provags-ID: V02:K0:4sgCX2fgq2DYsFOz0VtTQKwc7AznXEu7nwxvxhYhRgS kHp+c0bFqB8zbNw33XcoeOe+mgaWxcBa1HiigxKjlp33Posfub vf22Kv3kvPd0ah4isD6VlcT6e6mQW2hPCvcoNX4sFOvf5vsy70 g890eOeVryCWwQjVXObWgrllGFI1wdokAcfWeelQaGI+fsAyH6 SOXfdrR46PJ4G49ljfBPysB8jGZm00Kw0y6Xxt+wLM5si2N/b7 UoNpuvE0mmpgj8TtjXSD7p4h3Ooo6gU+/SAsdvAIzp909AiSNY 9b/0koVpkhdccoP9xlWtIrFb5/Ym0y+GEM/rYFvg+Ke8SGIKpB mgTL0xGNfv+tJK3MBR8OxBi1k2B1CyO53sg5unG5W X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 16539 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.0 (/) On 01/25/2014 04:19 AM, Pádraig Brady wrote: > On 01/24/2014 10:27 PM, Bernhard Voelker wrote: >> The above is the result of df suppressing duplicate entries like >> bind mounts. This filtering is done based on the device number. >> As this example shows, a few exports of directories of the same file >> system from "host" are mounted - yet it's the same file system. > > Right. Essentially df is showing storage for available file systems. > Noting that df also has a --total option, it makes sense by default > to not repeat file systems. This can be overridden easily with the > -a option as noted above. > > Actually we should in fact be merging more entries! > Notice the following: > >>> tmpfs 4095336 4688 4090648 1% /run >>> tmpfs 4095336 4688 4090648 1% /var/run >>> tmpfs 4095336 4688 4090648 1% /var/lock > > Hopefully the attached patch addresses this > (and a couple of other test issues). Good idea. I think we're on the right way - and the patch looks good to me. Thanks. However, I remember some other corner cases with eclipsed file systems in the Fedora bug tracker. I think we're quite close to solve them all this time (hopefully). The idea was to trust the order of mount entries returned by the kernel, i.e. in the loop over the mount entries, if the mount point is the same one as a previous one, then we should process the one mounted later. E.g. the situation where 2 file systems are mounted on the same mount point: $ findmnt | grep loop └─/mnt /dev/loop0 ext4 rw,relatime,data=ordered └─/mnt/dir /dev/loop1 ext4 rw,relatime,data=ordered └─/mnt/dir /dev/loop2 ext4 rw,relatime,data=ordered df - the new one with your patch - still shows the wrong device: $ src/df | grep loop /dev/loop0 122835 1551 112110 2% /mnt /dev/loop1 122835 1550 112111 2% /mnt/dir It should say /dev/loop2 here. BTW the numbers are correct. Have a nice day, Berny From debbugs-submit-bounces@debbugs.gnu.org Sat Jan 25 19:04:16 2014 Received: (at 16539) by debbugs.gnu.org; 26 Jan 2014 00:04:16 +0000 Received: from localhost ([127.0.0.1]:35996 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1W7DCy-0008Dx-Ct for submit@debbugs.gnu.org; Sat, 25 Jan 2014 19:04:16 -0500 Received: from moutng.kundenserver.de ([212.227.126.186]:62344) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1W7DCv-0008Dn-Pw for 16539@debbugs.gnu.org; Sat, 25 Jan 2014 19:04:14 -0500 Received: from [192.168.1.11] (p5499CDA4.dip0.t-ipconnect.de [84.153.205.164]) by mrelayeu.kundenserver.de (node=mreu2) with ESMTP (Nemesis) id 0MF8TX-1W5rkU2bud-00GPW0; Sun, 26 Jan 2014 01:04:05 +0100 Message-ID: <52E450F5.5000203@bernhard-voelker.de> Date: Sun, 26 Jan 2014 01:04:05 +0100 From: Bernhard Voelker User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.2.0 MIME-Version: 1.0 To: =?UTF-8?B?UMOhZHJhaWcgQnJhZHk=?= , 16539@debbugs.gnu.org, crubel@compro.net Subject: Re: bug#16539: More details on df command output for you References: <67f0ced2351b31a6ac4523659f306b25@msmail.compro.net> <3ce9319232fc3427c2ecefb1d68df226@msmail.compro.net> <52E2E8BF.1000700@bernhard-voelker.de> <52E32D5D.2030900@draigBrady.com> <52E44EE4.9020503@bernhard-voelker.de> In-Reply-To: <52E44EE4.9020503@bernhard-voelker.de> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Provags-ID: V02:K0:9cEY2ZUhfy/1cLU3KwV7h77/9BZcpqXyjT/yRt1h3zC qSBTjhBI+nYTOy4/ciJT0Ps7VED817IZv+Q6jvFgjVd5MIBnhw hmC7hrKocPk0vSa9nM6kHpJ2p/lgb72AS11EPEZoDUXpP1b4AM Q7H0mi9T1568/rb4bRWfreEo2MO2kx6A+HY5OO/8fC/G2XD7Nf dDipoueu9PPKjmEhQxKdtImNjH9Z40NMASNdPbnErTFb1XTdUP N8N1Mk3ZLx4IijrBwlgmjoZUeLLaq1IxWCLCbDjwIkJCewJqB2 T0daAWPbocg7yT8p5ChlrQ81HJi+va2YuIedsh9C3XmaLaBTCs X8gldd3JgJQCJG7xGcSHpgj/baTzNN7QUM82Ut7AI X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 16539 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.0 (/) On 01/26/2014 12:55 AM, Bernhard Voelker wrote: > I think we're on the right way - and the patch looks good to me. oops, too early: $ make syntax-check ... tests/df/skip-duplicates.sh:72: if (strcmp (mntents[done-2].mnt_dir, "/NONROOT") == 0) maint.mk: replace strcmp calls above with STREQ/STRNEQ make: *** [sc_prohibit_strcmp] Error 1 make: *** Waiting for unfinished jobs.... --- ./po/POTFILES.in +++ ./po/POTFILES.in @@ -16,11 +16,14 @@ lib/rpmatch.c lib/set-acl.c lib/siglist.h +lib/spawn-pipe.c lib/strsignal.c lib/unicodeio.c lib/userspec.c lib/verror.c lib/version-etc.c +lib/w32spawn.h +lib/wait-process.c lib/xalloc-die.c lib/xfreopen.c lib/xmemcoll.c maint.mk: you have changed the set of files with translatable diagnostics; apply the above patch make: *** [sc_po_check] Error 1 The latter sc error is not related to this patch, obviously. Have a nice day, Berny From debbugs-submit-bounces@debbugs.gnu.org Sun Jan 26 06:29:07 2014 Received: (at 16539) by debbugs.gnu.org; 26 Jan 2014 11:29:07 +0000 Received: from localhost ([127.0.0.1]:36156 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1W7Ntj-0002Dk-1E for submit@debbugs.gnu.org; Sun, 26 Jan 2014 06:29:07 -0500 Received: from mail2.vodafone.ie ([213.233.128.44]:27792) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1W7Ntg-0002DS-8y for 16539@debbugs.gnu.org; Sun, 26 Jan 2014 06:29:05 -0500 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: ApQBADbx5FJtThEL/2dsb2JhbAANTYcXtlGDBYEagxkBAQEDASMPAUYFCwkCDQEKAgIFFgsCAgkDAgECAUUGDQEHAQGHeQ2PVpp7dpwsF4EpjRtJB4JvgUkBA5Q/ileOXIFp Received: from unknown (HELO [192.168.1.79]) ([109.78.17.11]) by mail2.vodafone.ie with ESMTP; 26 Jan 2014 11:28:51 +0000 Message-ID: <52E4F174.9040602@draigBrady.com> Date: Sun, 26 Jan 2014 11:28:52 +0000 From: =?UTF-8?B?UMOhZHJhaWcgQnJhZHk=?= User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130110 Thunderbird/17.0.2 MIME-Version: 1.0 To: Bernhard Voelker Subject: Re: bug#16539: More details on df command output for you References: <67f0ced2351b31a6ac4523659f306b25@msmail.compro.net> <3ce9319232fc3427c2ecefb1d68df226@msmail.compro.net> <52E2E8BF.1000700@bernhard-voelker.de> <52E32D5D.2030900@draigBrady.com> <52E44EE4.9020503@bernhard-voelker.de> In-Reply-To: <52E44EE4.9020503@bernhard-voelker.de> X-Enigmail-Version: 1.6 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 16539 Cc: 16539@debbugs.gnu.org, crubel@compro.net X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 0.0 (/) On 01/25/2014 11:55 PM, Bernhard Voelker wrote: > On 01/25/2014 04:19 AM, Pádraig Brady wrote: >> On 01/24/2014 10:27 PM, Bernhard Voelker wrote: >>> The above is the result of df suppressing duplicate entries like >>> bind mounts. This filtering is done based on the device number. >>> As this example shows, a few exports of directories of the same file >>> system from "host" are mounted - yet it's the same file system. >> >> Right. Essentially df is showing storage for available file systems. >> Noting that df also has a --total option, it makes sense by default >> to not repeat file systems. This can be overridden easily with the >> -a option as noted above. >> >> Actually we should in fact be merging more entries! >> Notice the following: >> >>>> tmpfs 4095336 4688 4090648 1% /run >>>> tmpfs 4095336 4688 4090648 1% /var/run >>>> tmpfs 4095336 4688 4090648 1% /var/lock >> >> Hopefully the attached patch addresses this >> (and a couple of other test issues). > > Good idea. > > I think we're on the right way - and the patch looks good to me. Thanks for the review. I'll handle the syntax check too. > However, I remember some other corner cases with eclipsed file > systems in the Fedora bug tracker. I think we're quite close > to solve them all this time (hopefully). > The idea was to trust the order of mount entries returned by > the kernel, i.e. in the loop over the mount entries, if the > mount point is the same one as a previous one, then we should > process the one mounted later. > > E.g. the situation where 2 file systems are mounted on the > same mount point: > > $ findmnt | grep loop > └─/mnt /dev/loop0 ext4 rw,relatime,data=ordered > └─/mnt/dir /dev/loop1 ext4 rw,relatime,data=ordered > └─/mnt/dir /dev/loop2 ext4 rw,relatime,data=ordered > > df - the new one with your patch - still shows the wrong device: > > $ src/df | grep loop > /dev/loop0 122835 1551 112110 2% /mnt > /dev/loop1 122835 1550 112111 2% /mnt/dir > > It should say /dev/loop2 here. BTW the numbers are correct. Right, that could be handled easy enough. loop1 is not accessible above and so should be hidden. But consider a bind mount resulting in something like: > └─/mnt /dev/loop0 ext4 rw,relatime,data=ordered > └─/mnt/dir /dev/loop1 ext4 rw,relatime,data=ordered > └─/some/place/else /dev/loop1 ext4 rw,relatime,data=ordered > └─/mnt/dir /dev/loop2 ext4 rw,relatime,data=ordered If we did a linear scan through that, we'd lose the /some/place/else due to it being a longer mount dir, and then also the original loop1 as we took /dev/loop2 for /mnt/dir. Seems like when discarding we would need to see if this was the last entry for a device and then see if there are any other candidate mount points for that device? thanks, Pádraig. From debbugs-submit-bounces@debbugs.gnu.org Sun Jan 26 18:36:13 2014 Received: (at 16539) by debbugs.gnu.org; 26 Jan 2014 23:36:13 +0000 Received: from localhost ([127.0.0.1]:37024 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1W7ZFM-0007gN-Aj for submit@debbugs.gnu.org; Sun, 26 Jan 2014 18:36:12 -0500 Received: from moutng.kundenserver.de ([212.227.126.186]:58928) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1W7ZFK-0007gE-6N for 16539@debbugs.gnu.org; Sun, 26 Jan 2014 18:36:11 -0500 Received: from [192.168.1.11] (p5499CDA4.dip0.t-ipconnect.de [84.153.205.164]) by mrelayeu.kundenserver.de (node=mreu1) with ESMTP (Nemesis) id 0MUASM-1Vhotg3pB4-00QaXD; Mon, 27 Jan 2014 00:35:59 +0100 Message-ID: <52E59BDE.9020206@bernhard-voelker.de> Date: Mon, 27 Jan 2014 00:35:58 +0100 From: Bernhard Voelker User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.2.0 MIME-Version: 1.0 To: =?UTF-8?B?UMOhZHJhaWcgQnJhZHk=?= Subject: Re: bug#16539: More details on df command output for you References: <67f0ced2351b31a6ac4523659f306b25@msmail.compro.net> <3ce9319232fc3427c2ecefb1d68df226@msmail.compro.net> <52E2E8BF.1000700@bernhard-voelker.de> <52E32D5D.2030900@draigBrady.com> <52E44EE4.9020503@bernhard-voelker.de> <52E4F174.9040602@draigBrady.com> In-Reply-To: <52E4F174.9040602@draigBrady.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Provags-ID: V02:K0:7l7JUCoRUnmA3eCWQZhXfvoi6m3VpIWsWK8uT0CzFcM VVhxTuxbHpVuD0wQFDMJZ//t0xrUDdZ7H+VKFWvlk5g1Zl24RT 12M7t7+vq8k66778L83FHdwjoF6lM7vlXNllaNSd7oN55iAISK +qBmxUibCxf8FxigKOzp/r4CinYDMQCbZb4PqE53vFLbXhCY9q GJ2vP9dkF81Yv/RzWEnBZn+pPYnKffJX94hH812LmsrTvacHOb 9COt0JxuRhBiTocJrNpL6+e0sL5effp8NXAi378jYq6lso06Ii Nl3JCMqWo4Fwp4DCu2GVLZL/L3d0x9Z5Hm6EDRIDxboE4BhkgK 5J2POhCXcaO7ASi8aMz3iU3ug7jizaSavp8tdNP89 X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 16539 Cc: 16539@debbugs.gnu.org, crubel@compro.net X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.0 (/) On 01/26/2014 12:28 PM, Pádraig Brady wrote: > On 01/25/2014 11:55 PM, Bernhard Voelker wrote: >> However, I remember some other corner cases with eclipsed file >> systems in the Fedora bug tracker. I think we're quite close >> to solve them all this time (hopefully). >> The idea was to trust the order of mount entries returned by >> the kernel, i.e. in the loop over the mount entries, if the >> mount point is the same one as a previous one, then we should >> process the one mounted later. >> >> E.g. the situation where 2 file systems are mounted on the >> same mount point: >> >> $ findmnt | grep loop >> └─/mnt /dev/loop0 ext4 rw,relatime,data=ordered >> └─/mnt/dir /dev/loop1 ext4 rw,relatime,data=ordered >> └─/mnt/dir /dev/loop2 ext4 rw,relatime,data=ordered >> >> df - the new one with your patch - still shows the wrong device: >> >> $ src/df | grep loop >> /dev/loop0 122835 1551 112110 2% /mnt >> /dev/loop1 122835 1550 112111 2% /mnt/dir >> >> It should say /dev/loop2 here. BTW the numbers are correct. BTW: the fstype is wrong, too (which can only be seen with -T or --output, and if it differs, of course). > Right, that could be handled easy enough. > loop1 is not accessible above and so should be hidden. > But consider a bind mount resulting in something like: > >> └─/mnt /dev/loop0 ext4 rw,relatime,data=ordered >> └─/mnt/dir /dev/loop1 ext4 rw,relatime,data=ordered >> └─/some/place/else /dev/loop1 ext4 rw,relatime,data=ordered >> └─/mnt/dir /dev/loop2 ext4 rw,relatime,data=ordered > > If we did a linear scan through that, we'd lose the /some/place/else > due to it being a longer mount dir, and then also the original loop1 > as we took /dev/loop2 for /mnt/dir. > Seems like when discarding we would need to see if this was the > last entry for a device and then see if there are any other candidate > mount points for that device? Hi Padraig, thanks. Again, mount_list is a little beast - more below. The following patch (on top of yours) would handle both cases without a problem. Feel free to squash it in, if you like. diff --git a/src/df.c b/src/df.c index 23b5156..78768cc 100644 --- a/src/df.c +++ b/src/df.c @@ -631,9 +631,20 @@ filter_mount_list (void) else { /* If we've already seen this device... */ + struct devlist *d = NULL; for (devlist = devlist_head; devlist; devlist = devlist->next) if (devlist->dev_num == buf.st_dev) - break; + { + d = devlist; + if (!STREQ (devlist->me->me_devname, me->me_devname)) + { + /* Fix the devname if the mount dir has been + mounted over by a different devname. */ + free (devlist->me->me_devname); + devlist->me->me_devname = xstrdup (me->me_devname); + } + } + devlist = d; if (devlist) { But there is yet another issue with the -a mode for such over-mounted and therefore eclipsed file systems: # Create 2 file system images: 1 ext4, 1 xfs. $ dd if=/dev/zero bs=1M status=none count=128 of=img1 $ dd if=/dev/zero bs=1M status=none count=256 of=img2 $ mkfs -t ext4 -F img1 >/dev/null 2>&1 $ mkfs -t xfs -f img2 >/dev/null 2>&1 $ mkdir /mnt{1,2} # Mount both on /mnt1. $ mount -o loop img1 /mnt1 $ mount -o loop img2 /mnt1 # Mount the former (ext4) also on /mnt2 via its loop device. $ mount /dev/loop0 /mnt2 # Result: $ findmnt --output=TARGET,SOURCE,FSTYPE | grep loop ├─/mnt1 /dev/loop0 ext4 │ └─/mnt1 /dev/loop1 xfs └─/mnt2 /dev/loop0 ext4 Everything is fine now with the filtered df run ... $ src/df --out -h | grep loop /dev/loop1 xfs 256K 3 256K 1% 252M 13M 239M 6% - /mnt1 /dev/loop0 ext4 32K 11 32K 1% 120M 1.6M 110M 2% - /mnt2 ...but "df -a" prints the wrong statistics for the "over-mounted" /mnt1! $ src/df --out -h -a | grep loop /dev/loop0 ext4 256K 3 256K 1% 252M 13M 239M 6% - /mnt1 /dev/loop1 xfs 256K 3 256K 1% 252M 13M 239M 6% - /mnt1 /dev/loop0 ext4 32K 11 32K 1% 120M 1.6M 110M 2% - /mnt2 Okay, this is nothing new. BTW: strictly speaking, also the output of today's "df -t rootfs -a" is wrong because the numbers are definitely not that of the early-boot rootfs file system. Now, how should df handle this? a) df silently filters out the mount entries of all eclipsed mount dirs, even with -a. --> Hmm, I think this would probably contradict to POSIX. b) df prints an error diagnostic for each eclipsed mount dir, and exits non-Zero. --> Well, there are probably such mounts on every system, e.g. on my box: TARGET SOURCE FSTYPE /proc/sys/fs/binfmt_misc systemd-1 autofs /proc/sys/fs/binfmt_misc binfmt_misc binfmt_misc Therefore, a "df -a" would always fail. ;-( At least on my system, there are c) df prints a warning diagnostic for each eclipsed mount dir, and exits Zero (unless another error occurs). --> Due to the same reason as in b), these warning might be messy and users will probably be irritated. d) df outputs "-" for all numbers of such eclipsed file systems, e.g. $ src/df --out -h -a | grep mnt1 /dev/loop0 ext4 - - - - - - - - - /mnt1 /dev/loop1 xfs 256K 3 256K 1% 252M 13M 239M 6% - /mnt1 Maybe d) is the best solution, as it mirrors what df can know: it knows source, target and the file system type, but it doesn't have access to the block and inode numbers. WDYT? Have a nice day, Berny From debbugs-submit-bounces@debbugs.gnu.org Sun Jan 26 20:06:22 2014 Received: (at 16539) by debbugs.gnu.org; 27 Jan 2014 01:06:22 +0000 Received: from localhost ([127.0.0.1]:37049 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1W7aeb-0001X9-Nc for submit@debbugs.gnu.org; Sun, 26 Jan 2014 20:06:22 -0500 Received: from mail2.vodafone.ie ([213.233.128.44]:14450) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1W7aeY-0001Wz-Gh for 16539@debbugs.gnu.org; Sun, 26 Jan 2014 20:06:19 -0500 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: ApQBAMGv5VJtThEL/2dsb2JhbAANTIcXtlSDBYEegxkBAQEEIwQLAUYQCQINAQoCAgUWCwICCQMCAQIBRQYNAQcBAReHb49dmnt2nDAXgSmNZAeCb4FJAQOUP4pXjlw Received: from unknown (HELO [192.168.1.79]) ([109.78.17.11]) by mail2.vodafone.ie with ESMTP; 27 Jan 2014 01:06:16 +0000 Message-ID: <52E5B108.5080304@draigBrady.com> Date: Mon, 27 Jan 2014 01:06:16 +0000 From: =?UTF-8?B?UMOhZHJhaWcgQnJhZHk=?= User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130110 Thunderbird/17.0.2 MIME-Version: 1.0 To: Bernhard Voelker Subject: Re: bug#16539: More details on df command output for you References: <67f0ced2351b31a6ac4523659f306b25@msmail.compro.net> <3ce9319232fc3427c2ecefb1d68df226@msmail.compro.net> <52E2E8BF.1000700@bernhard-voelker.de> <52E32D5D.2030900@draigBrady.com> <52E44EE4.9020503@bernhard-voelker.de> <52E4F174.9040602@draigBrady.com> <52E59BDE.9020206@bernhard-voelker.de> In-Reply-To: <52E59BDE.9020206@bernhard-voelker.de> X-Enigmail-Version: 1.6 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 16539 Cc: 16539@debbugs.gnu.org, crubel@compro.net X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 0.0 (/) On 01/26/2014 11:35 PM, Bernhard Voelker wrote: > On 01/26/2014 12:28 PM, Pádraig Brady wrote: >> On 01/25/2014 11:55 PM, Bernhard Voelker wrote: >>> However, I remember some other corner cases with eclipsed file >>> systems in the Fedora bug tracker. I think we're quite close >>> to solve them all this time (hopefully). >>> The idea was to trust the order of mount entries returned by >>> the kernel, i.e. in the loop over the mount entries, if the >>> mount point is the same one as a previous one, then we should >>> process the one mounted later. >>> >>> E.g. the situation where 2 file systems are mounted on the >>> same mount point: >>> >>> $ findmnt | grep loop >>> └─/mnt /dev/loop0 ext4 rw,relatime,data=ordered >>> └─/mnt/dir /dev/loop1 ext4 rw,relatime,data=ordered >>> └─/mnt/dir /dev/loop2 ext4 rw,relatime,data=ordered >>> >>> df - the new one with your patch - still shows the wrong device: >>> >>> $ src/df | grep loop >>> /dev/loop0 122835 1551 112110 2% /mnt >>> /dev/loop1 122835 1550 112111 2% /mnt/dir >>> >>> It should say /dev/loop2 here. BTW the numbers are correct. > > BTW: the fstype is wrong, too (which can only be seen with -T or --output, > and if it differs, of course). > >> Right, that could be handled easy enough. >> loop1 is not accessible above and so should be hidden. >> But consider a bind mount resulting in something like: >> >>> └─/mnt /dev/loop0 ext4 rw,relatime,data=ordered >>> └─/mnt/dir /dev/loop1 ext4 rw,relatime,data=ordered >>> └─/some/place/else /dev/loop1 ext4 rw,relatime,data=ordered >>> └─/mnt/dir /dev/loop2 ext4 rw,relatime,data=ordered >> >> If we did a linear scan through that, we'd lose the /some/place/else >> due to it being a longer mount dir, and then also the original loop1 >> as we took /dev/loop2 for /mnt/dir. >> Seems like when discarding we would need to see if this was the >> last entry for a device and then see if there are any other candidate >> mount points for that device? > > Hi Padraig, > > thanks. > Again, mount_list is a little beast - more below. > > The following patch (on top of yours) would handle both cases > without a problem. Feel free to squash it in, if you like. > > diff --git a/src/df.c b/src/df.c > index 23b5156..78768cc 100644 > --- a/src/df.c > +++ b/src/df.c > @@ -631,9 +631,20 @@ filter_mount_list (void) > else > { > /* If we've already seen this device... */ > + struct devlist *d = NULL; > for (devlist = devlist_head; devlist; devlist = devlist->next) > if (devlist->dev_num == buf.st_dev) > - break; > + { > + d = devlist; > + if (!STREQ (devlist->me->me_devname, me->me_devname)) > + { > + /* Fix the devname if the mount dir has been > + mounted over by a different devname. */ > + free (devlist->me->me_devname); > + devlist->me->me_devname = xstrdup (me->me_devname); > + } > + } > + devlist = d; > > if (devlist) > { > > But there is yet another issue with the -a mode for such > over-mounted and therefore eclipsed file systems: > > # Create 2 file system images: 1 ext4, 1 xfs. > $ dd if=/dev/zero bs=1M status=none count=128 of=img1 > $ dd if=/dev/zero bs=1M status=none count=256 of=img2 > $ mkfs -t ext4 -F img1 >/dev/null 2>&1 > $ mkfs -t xfs -f img2 >/dev/null 2>&1 > $ mkdir /mnt{1,2} > > # Mount both on /mnt1. > $ mount -o loop img1 /mnt1 > $ mount -o loop img2 /mnt1 > > # Mount the former (ext4) also on /mnt2 via its loop device. > $ mount /dev/loop0 /mnt2 > > # Result: > $ findmnt --output=TARGET,SOURCE,FSTYPE | grep loop > ├─/mnt1 /dev/loop0 ext4 > │ └─/mnt1 /dev/loop1 xfs > └─/mnt2 /dev/loop0 ext4 > > Everything is fine now with the filtered df run ... > > $ src/df --out -h | grep loop > /dev/loop1 xfs 256K 3 256K 1% 252M 13M 239M 6% - /mnt1 > /dev/loop0 ext4 32K 11 32K 1% 120M 1.6M 110M 2% - /mnt2 > > ...but "df -a" prints the wrong statistics for the "over-mounted" /mnt1! > > $ src/df --out -h -a | grep loop > /dev/loop0 ext4 256K 3 256K 1% 252M 13M 239M 6% - /mnt1 > /dev/loop1 xfs 256K 3 256K 1% 252M 13M 239M 6% - /mnt1 > /dev/loop0 ext4 32K 11 32K 1% 120M 1.6M 110M 2% - /mnt2 > > Okay, this is nothing new. > BTW: strictly speaking, also the output of today's "df -t rootfs -a" > is wrong because the numbers are definitely not that of the early-boot > rootfs file system. > > Now, how should df handle this? > > a) > df silently filters out the mount entries of all eclipsed mount dirs, > even with -a. > --> Hmm, I think this would probably contradict to POSIX. > > b) > df prints an error diagnostic for each eclipsed mount dir, and exits > non-Zero. > --> Well, there are probably such mounts on every system, e.g. on my box: > > TARGET SOURCE FSTYPE > /proc/sys/fs/binfmt_misc systemd-1 autofs > /proc/sys/fs/binfmt_misc binfmt_misc binfmt_misc > > Therefore, a "df -a" would always fail. ;-( > At least on my system, there are > > c) > df prints a warning diagnostic for each eclipsed mount dir, and exits > Zero (unless another error occurs). > > --> Due to the same reason as in b), these warning might be messy > and users will probably be irritated. > > d) > df outputs "-" for all numbers of such eclipsed file systems, e.g. > > $ src/df --out -h -a | grep mnt1 > /dev/loop0 ext4 - - - - - - - - - /mnt1 > /dev/loop1 xfs 256K 3 256K 1% 252M 13M 239M 6% - /mnt1 > > > Maybe d) is the best solution, as it mirrors what df can know: > it knows source, target and the file system type, but it doesn't > have access to the block and inode numbers. > > WDYT? Thanks for the nice analysis and tests. d) seems like the best option here, though we'd have to be careful about cases where /proc/mounts was giving a system wide view, while df wasn't privy to that due to mount namespaces or overmounts etc. I'm not thinking of a specific issue here, just the general problem. wrt c) and annoying warnings, I also notice `df -a` on a default Fedora 20 install here, giving multiple duplicate warnings like: df: ‘net:[4026532416]’: No such file or directory df: ‘net:[4026532416]’: No such file or directory That's due to: $ grep net: /proc/mounts proc net:[4026532416] proc rw,nosuid,nodev,noexec,relatime 0 0 proc net:[4026532416] proc rw,nosuid,nodev,noexec,relatime 0 0 Which is due to support for namespaces. Seems like we should not try to lookup non absolute mount points? Also a general point is that a lot of stuff has changed underneath us recently, and perhaps we should be looking at abstracting that away somewhere (like libmount that is part of util-linux). In the short term anyway we should fix up the above warts within df. thanks, Pádraig. thanks, Pádraig. From debbugs-submit-bounces@debbugs.gnu.org Mon Jan 27 17:47:31 2014 Received: (at 16539) by debbugs.gnu.org; 27 Jan 2014 22:47:31 +0000 Received: from localhost ([127.0.0.1]:38450 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1W7uxm-000825-W6 for submit@debbugs.gnu.org; Mon, 27 Jan 2014 17:47:31 -0500 Received: from moutng.kundenserver.de ([212.227.126.186]:62459) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1W7uxk-00081w-JD for 16539@debbugs.gnu.org; Mon, 27 Jan 2014 17:47:29 -0500 Received: from [192.168.1.11] (p5499CDA4.dip0.t-ipconnect.de [84.153.205.164]) by mrelayeu.kundenserver.de (node=mreu2) with ESMTP (Nemesis) id 0MOETY-1WBEsF0YdQ-005deq; Mon, 27 Jan 2014 23:47:19 +0100 Message-ID: <52E6E1F6.2040803@bernhard-voelker.de> Date: Mon, 27 Jan 2014 23:47:18 +0100 From: Bernhard Voelker User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.2.0 MIME-Version: 1.0 To: =?UTF-8?B?UMOhZHJhaWcgQnJhZHk=?= Subject: Re: bug#16539: More details on df command output for you References: <67f0ced2351b31a6ac4523659f306b25@msmail.compro.net> <3ce9319232fc3427c2ecefb1d68df226@msmail.compro.net> <52E2E8BF.1000700@bernhard-voelker.de> <52E32D5D.2030900@draigBrady.com> <52E44EE4.9020503@bernhard-voelker.de> <52E4F174.9040602@draigBrady.com> <52E59BDE.9020206@bernhard-voelker.de> <52E5B108.5080304@draigBrady.com> In-Reply-To: <52E5B108.5080304@draigBrady.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Provags-ID: V02:K0:UNcAoIPFGomb8DfyQQq2RL3KUlVeyJnVbPUDI7U/8VC yzaHD+urTWp6PxeS047kVvcW28DwlKVFxkQ/1M6+2EnyVvW7B6 1Wp4S4J2jBNQov2Ml6UOVfG9p+JAcP0mGW+iKmGaymdm1gkUN9 z0KzPmo55psgTvTyQF3oKioHQB95rlQOGhupV2p3HcmzsT2Ed1 rKG+qCWga6w/EQmCtZNNc/QVR4TQejRUA5SgRsHJC/UMkGtmGy fE9r8hVZfIFXtFUDlUY5SlSxEeufxutrLUYbMBWsLgX2F9wklU uKml/AB2fxEG4iF9x8a/cT7U6vVsLRNbnN+ju5BDDiLGcZoL83 aWqYs2ZTh/wlZeumnzjQnXjzCO50jb0E4cwjv8wbJ X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 16539 Cc: 16539@debbugs.gnu.org, crubel@compro.net X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.0 (/) On 01/27/2014 02:06 AM, Pádraig Brady wrote: > On 01/26/2014 11:35 PM, Bernhard Voelker wrote: >> Now, how should df handle this? >> >> a) >> df silently filters out the mount entries of all eclipsed mount dirs, >> even with -a. >> --> Hmm, I think this would probably contradict to POSIX. >> >> b) >> df prints an error diagnostic for each eclipsed mount dir, and exits >> non-Zero. >> --> Well, there are probably such mounts on every system, e.g. on my box: >> >> TARGET SOURCE FSTYPE >> /proc/sys/fs/binfmt_misc systemd-1 autofs >> /proc/sys/fs/binfmt_misc binfmt_misc binfmt_misc >> >> Therefore, a "df -a" would always fail. ;-( >> At least on my system, there are >> >> c) >> df prints a warning diagnostic for each eclipsed mount dir, and exits >> Zero (unless another error occurs). >> >> --> Due to the same reason as in b), these warning might be messy >> and users will probably be irritated. >> >> d) >> df outputs "-" for all numbers of such eclipsed file systems, e.g. >> >> $ src/df --out -h -a | grep mnt1 >> /dev/loop0 ext4 - - - - - - - - - /mnt1 >> /dev/loop1 xfs 256K 3 256K 1% 252M 13M 239M 6% - /mnt1 >> >> >> Maybe d) is the best solution, as it mirrors what df can know: >> it knows source, target and the file system type, but it doesn't >> have access to the block and inode numbers. >> >> WDYT? > > Thanks for the nice analysis and tests. > d) seems like the best option here, though we'd have to be careful > about cases where /proc/mounts was giving a system wide view, > while df wasn't privy to that due to mount namespaces or > overmounts etc. I'm not thinking of a specific issue here, > just the general problem. okay, let's try it that way. I think this is not much related to the issue your patch (with my amendment) is trying to fix. Therefore, I suggest to finish that and handle the overmounts in a separate commit. > wrt c) and annoying warnings, I also notice `df -a` on a default Fedora 20 install here, > giving multiple duplicate warnings like: > df: ‘net:[4026532416]’: No such file or directory > df: ‘net:[4026532416]’: No such file or directory > That's due to: > $ grep net: /proc/mounts > proc net:[4026532416] proc rw,nosuid,nodev,noexec,relatime 0 0 > proc net:[4026532416] proc rw,nosuid,nodev,noexec,relatime 0 0 > Which is due to support for namespaces. Ugh ... and that's a third problm class for df. ;-( > Seems like we should not try to lookup non absolute mount points? yes, that's probably our best chance. > Also a general point is that a lot of stuff has changed underneath us recently, > and perhaps we should be looking at abstracting that away somewhere > (like libmount that is part of util-linux). In the short term anyway > we should fix up the above warts within df. I'm not sure about such an abstraction. Actually, the mount_list is already abstracted ... by gnulib. And that's the biggest difference to the situation in util-linux: while util-linux only has to run on GNU/Linux, coreutils' df has to run on a big variety of systems including far-off systems like cygwin. I think if we find a way to ignore such non-accessible file systems without producing too many annoying warnings, then I'd say we're off the hook. Namespaces have been invented to hide mounts, so people shouldn't wonder that they are hidden to df. ;-) Have a nice day, Berny From debbugs-submit-bounces@debbugs.gnu.org Tue Jan 28 06:13:13 2014 Received: (at 16539) by debbugs.gnu.org; 28 Jan 2014 11:13:13 +0000 Received: from localhost ([127.0.0.1]:38704 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1W86bR-0002V7-1g for submit@debbugs.gnu.org; Tue, 28 Jan 2014 06:13:13 -0500 Received: from moutng.kundenserver.de ([212.227.126.171]:51308) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1W86bO-0002Ux-2L for 16539@debbugs.gnu.org; Tue, 28 Jan 2014 06:13:10 -0500 Received: from [10.0.2.15] (gw.camline.com [62.153.148.194]) by mrelayeu.kundenserver.de (node=mreu2) with ESMTP (Nemesis) id 0Mh8wH-1VugTk1byz-00MUCz; Tue, 28 Jan 2014 12:13:01 +0100 Message-ID: <52E790BC.2030303@bernhard-voelker.de> Date: Tue, 28 Jan 2014 12:13:00 +0100 From: Bernhard Voelker User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.2.0 MIME-Version: 1.0 To: =?UTF-8?B?UMOhZHJhaWcgQnJhZHk=?= Subject: Re: bug#16539: More details on df command output for you References: <67f0ced2351b31a6ac4523659f306b25@msmail.compro.net> <3ce9319232fc3427c2ecefb1d68df226@msmail.compro.net> <52E2E8BF.1000700@bernhard-voelker.de> <52E32D5D.2030900@draigBrady.com> <52E44EE4.9020503@bernhard-voelker.de> <52E4F174.9040602@draigBrady.com> <52E59BDE.9020206@bernhard-voelker.de> <52E5B108.5080304@draigBrady.com> <52E6E1F6.2040803@bernhard-voelker.de> In-Reply-To: <52E6E1F6.2040803@bernhard-voelker.de> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Provags-ID: V02:K0:RQzc8eyPaph524PSPHPz4CdfSqL7aJcB5On0c17gVYx MrmvBkKgNE3AnfK2a8t1r063hP5lPZjyWS0EL73NvR/uK+3E+b 1uExEDHQAYahoCqYTa4DLYerVidOTYyMq3qUZB+PYj0SFI6UI6 TZgP8K30dTO8wjNncZVAO1ve/fXGo1YXXyIJDexzA0WaCQuh0n cWD1eoa2w/5tZ+NLmxCxB7ssbuwM9g5htYrElFB/ObbZS5C76u dWgH2sv2rDQcIDPKmy834wPMlIIydrVF3Xq17wVXpuZfpnUV1D eChdHSxGtXcRx1nYjnpxLcGsLTtZ2NPji4VILzodqkTRBY9wxc wAwa4Cm/CeaEk3AUjNjuGXvIyLqav+hvmszHB9NHx X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 16539 Cc: 16539@debbugs.gnu.org, crubel@compro.net X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.0 (/) On 01/27/2014 11:47 PM, Bernhard Voelker wrote: > On 01/27/2014 02:06 AM, Pádraig Brady wrote: >> wrt c) and annoying warnings, I also notice `df -a` on a default Fedora 20 install here, >> giving multiple duplicate warnings like: >> df: ‘net:[4026532416]’: No such file or directory >> df: ‘net:[4026532416]’: No such file or directory >> That's due to: >> $ grep net: /proc/mounts >> proc net:[4026532416] proc rw,nosuid,nodev,noexec,relatime 0 0 >> proc net:[4026532416] proc rw,nosuid,nodev,noexec,relatime 0 0 >> Which is due to support for namespaces. > > Ugh ... and that's a third problm class for df. ;-( > >> Seems like we should not try to lookup non absolute mount points? > > yes, that's probably our best chance. Thinking further, this is mandatory: $ touch 'net:[4026532416]' This would make the stat() in df succeed and lead to wrong output. Have a nice day, Berny From debbugs-submit-bounces@debbugs.gnu.org Tue Jan 28 06:34:28 2014 Received: (at 16539) by debbugs.gnu.org; 28 Jan 2014 11:34:28 +0000 Received: from localhost ([127.0.0.1]:38716 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1W86vz-00034R-Mt for submit@debbugs.gnu.org; Tue, 28 Jan 2014 06:34:28 -0500 Received: from mail5.vodafone.ie ([213.233.128.176]:28927) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1W86vx-00034H-6o for 16539@debbugs.gnu.org; Tue, 28 Jan 2014 06:34:25 -0500 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: ApQBADuV51JtTnZ1/2dsb2JhbAANTYcXtlKDBoEngxkBAQEEIw8BRhALDQEKAgIFFgsCAgkDAgECAUUGDQEHAQGIBqhjdp91F4EpjVYHgm+BSQEDnxiOXA Received: from unknown (HELO [192.168.1.79]) ([109.78.118.117]) by mail3.vodafone.ie with ESMTP; 28 Jan 2014 11:34:23 +0000 Message-ID: <52E795BE.2050902@draigBrady.com> Date: Tue, 28 Jan 2014 11:34:22 +0000 From: =?UTF-8?B?UMOhZHJhaWcgQnJhZHk=?= User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130110 Thunderbird/17.0.2 MIME-Version: 1.0 To: Bernhard Voelker Subject: Re: bug#16539: More details on df command output for you References: <67f0ced2351b31a6ac4523659f306b25@msmail.compro.net> <3ce9319232fc3427c2ecefb1d68df226@msmail.compro.net> <52E2E8BF.1000700@bernhard-voelker.de> <52E32D5D.2030900@draigBrady.com> <52E44EE4.9020503@bernhard-voelker.de> <52E4F174.9040602@draigBrady.com> <52E59BDE.9020206@bernhard-voelker.de> <52E5B108.5080304@draigBrady.com> <52E6E1F6.2040803@bernhard-voelker.de> <52E790BC.2030303@bernhard-voelker.de> In-Reply-To: <52E790BC.2030303@bernhard-voelker.de> X-Enigmail-Version: 1.6 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 16539 Cc: 16539@debbugs.gnu.org, crubel@compro.net X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 0.0 (/) On 01/28/2014 11:13 AM, Bernhard Voelker wrote: > On 01/27/2014 11:47 PM, Bernhard Voelker wrote: >> On 01/27/2014 02:06 AM, Pádraig Brady wrote: >>> wrt c) and annoying warnings, I also notice `df -a` on a default Fedora 20 install here, >>> giving multiple duplicate warnings like: >>> df: ‘net:[4026532416]’: No such file or directory >>> df: ‘net:[4026532416]’: No such file or directory >>> That's due to: >>> $ grep net: /proc/mounts >>> proc net:[4026532416] proc rw,nosuid,nodev,noexec,relatime 0 0 >>> proc net:[4026532416] proc rw,nosuid,nodev,noexec,relatime 0 0 >>> Which is due to support for namespaces. >> >> Ugh ... and that's a third problm class for df. ;-( >> >>> Seems like we should not try to lookup non absolute mount points? >> >> yes, that's probably our best chance. > > Thinking further, this is mandatory: > > $ touch 'net:[4026532416]' > > This would make the stat() in df succeed and lead to wrong output. OK I'll do a patchset for these df issue this evening hopefully. thanks, Pádraig. From unknown Thu Jun 19 12:19:43 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Tue, 25 Feb 2014 12:24:04 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator From debbugs-submit-bounces@debbugs.gnu.org Mon May 12 11:07:58 2014 Received: (at control) by debbugs.gnu.org; 12 May 2014 15:07:58 +0000 Received: from localhost ([127.0.0.1]:60835 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Wjrpd-0005xc-SD for submit@debbugs.gnu.org; Mon, 12 May 2014 11:07:58 -0400 Received: from mail2.vodafone.ie ([213.233.128.44]:31673) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Wjrpb-0005xL-CK for control@debbugs.gnu.org; Mon, 12 May 2014 11:07:56 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AskBAPDicFNtTeEu/2dsb2JhbAANTIQNgwfCfTKBBoM5CipUDQIFFgsCCwMCAQIBOQYCAhUIAQGIQqoxd6QDF4EqjUWCX4FLBKBWjzA Received: from unknown (HELO [192.168.1.79]) ([109.77.225.46]) by mail2.vodafone.ie with ESMTP; 12 May 2014 16:07:50 +0100 Message-ID: <5370E3C5.6000604@draigBrady.com> Date: Mon, 12 May 2014 16:07:49 +0100 From: =?UTF-8?B?UMOhZHJhaWcgQnJhZHk=?= User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130110 Thunderbird/17.0.2 MIME-Version: 1.0 To: control@debbugs.gnu.org X-Enigmail-Version: 1.6 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Score: 2.0 (++) X-Spam-Report: Spam detection software, running on the system "debbugs.gnu.org", has identified this incoming email as possible spam. The original message has been attached to this so you can view it (if it isn't spam) or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: unarchive 16539 [...] Content analysis details: (2.0 points, 10.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at http://www.dnswl.org/, no trust [213.233.128.44 listed in list.dnswl.org] 1.8 MISSING_SUBJECT Missing Subject: header 0.2 NO_SUBJECT Extra score for no subject X-Debbugs-Envelope-To: control X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 2.0 (++) X-Spam-Report: Spam detection software, running on the system "debbugs.gnu.org", has identified this incoming email as possible spam. The original message has been attached to this so you can view it (if it isn't spam) or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: unarchive 16539 [...] Content analysis details: (2.0 points, 10.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at http://www.dnswl.org/, no trust [213.233.128.44 listed in list.dnswl.org] 1.8 MISSING_SUBJECT Missing Subject: header 0.2 NO_SUBJECT Extra score for no subject 0.0 TVD_SPACE_RATIO TVD_SPACE_RATIO unarchive 16539 From debbugs-submit-bounces@debbugs.gnu.org Mon May 12 11:11:08 2014 Received: (at 16539) by debbugs.gnu.org; 12 May 2014 15:11:08 +0000 Received: from localhost ([127.0.0.1]:60840 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Wjrsg-00063B-RM for submit@debbugs.gnu.org; Mon, 12 May 2014 11:11:08 -0400 Received: from mail2.vodafone.ie ([213.233.128.44]:26953) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Wjrsc-00062Z-HB for 16539@debbugs.gnu.org; Mon, 12 May 2014 11:11:04 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: ApUBABnkcFNtTeEu/2dsb2JhbAANTINVgz/DBgGBLoMZAQEBAwEjBCAyEAkCDQEDAwECAQkWCwICCQMCAQIBPQgGDQEFAgEBFgEDiBsNjw+bJ3eEE59vF4kxhFg4EQcJgmyBSwEDkTCBOYJniwaPMIFtASQ Received: from unknown (HELO [192.168.1.79]) ([109.77.225.46]) by mail2.vodafone.ie with ESMTP; 12 May 2014 16:10:56 +0100 Message-ID: <5370E47F.3030401@draigBrady.com> Date: Mon, 12 May 2014 16:10:55 +0100 From: =?UTF-8?B?UMOhZHJhaWcgQnJhZHk=?= User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130110 Thunderbird/17.0.2 MIME-Version: 1.0 To: Bernhard Voelker Subject: Re: bug#16539: More details on df command output for you References: <67f0ced2351b31a6ac4523659f306b25@msmail.compro.net> <3ce9319232fc3427c2ecefb1d68df226@msmail.compro.net> <52E2E8BF.1000700@bernhard-voelker.de> <52E32D5D.2030900@draigBrady.com> <52E44EE4.9020503@bernhard-voelker.de> <52E4F174.9040602@draigBrady.com> <52E59BDE.9020206@bernhard-voelker.de> <52E5B108.5080304@draigBrady.com> In-Reply-To: <52E5B108.5080304@draigBrady.com> X-Enigmail-Version: 1.6 Content-Type: multipart/mixed; boundary="------------000009000404090706020202" X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 16539 Cc: 16539@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 0.0 (/) This is a multi-part message in MIME format. --------------000009000404090706020202 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit On 01/27/2014 01:06 AM, Pádraig Brady wrote: > On 01/26/2014 11:35 PM, Bernhard Voelker wrote: >> On 01/26/2014 12:28 PM, Pádraig Brady wrote: >>> On 01/25/2014 11:55 PM, Bernhard Voelker wrote: >>>> However, I remember some other corner cases with eclipsed file >>>> systems in the Fedora bug tracker. I think we're quite close >>>> to solve them all this time (hopefully). >>>> The idea was to trust the order of mount entries returned by >>>> the kernel, i.e. in the loop over the mount entries, if the >>>> mount point is the same one as a previous one, then we should >>>> process the one mounted later. >>>> >>>> E.g. the situation where 2 file systems are mounted on the >>>> same mount point: >>>> >>>> $ findmnt | grep loop >>>> └─/mnt /dev/loop0 ext4 rw,relatime,data=ordered >>>> └─/mnt/dir /dev/loop1 ext4 rw,relatime,data=ordered >>>> └─/mnt/dir /dev/loop2 ext4 rw,relatime,data=ordered >>>> >>>> df - the new one with your patch - still shows the wrong device: >>>> >>>> $ src/df | grep loop >>>> /dev/loop0 122835 1551 112110 2% /mnt >>>> /dev/loop1 122835 1550 112111 2% /mnt/dir >>>> >>>> It should say /dev/loop2 here. BTW the numbers are correct. >> >> BTW: the fstype is wrong, too (which can only be seen with -T or --output, >> and if it differs, of course). >> >>> Right, that could be handled easy enough. >>> loop1 is not accessible above and so should be hidden. >>> But consider a bind mount resulting in something like: >>> >>>> └─/mnt /dev/loop0 ext4 rw,relatime,data=ordered >>>> └─/mnt/dir /dev/loop1 ext4 rw,relatime,data=ordered >>>> └─/some/place/else /dev/loop1 ext4 rw,relatime,data=ordered >>>> └─/mnt/dir /dev/loop2 ext4 rw,relatime,data=ordered >>> >>> If we did a linear scan through that, we'd lose the /some/place/else >>> due to it being a longer mount dir, and then also the original loop1 >>> as we took /dev/loop2 for /mnt/dir. >>> Seems like when discarding we would need to see if this was the >>> last entry for a device and then see if there are any other candidate >>> mount points for that device? >> >> Hi Padraig, >> >> thanks. >> Again, mount_list is a little beast - more below. >> >> The following patch (on top of yours) would handle both cases >> without a problem. Feel free to squash it in, if you like. >> >> diff --git a/src/df.c b/src/df.c >> index 23b5156..78768cc 100644 >> --- a/src/df.c >> +++ b/src/df.c >> @@ -631,9 +631,20 @@ filter_mount_list (void) >> else >> { >> /* If we've already seen this device... */ >> + struct devlist *d = NULL; >> for (devlist = devlist_head; devlist; devlist = devlist->next) >> if (devlist->dev_num == buf.st_dev) >> - break; >> + { >> + d = devlist; >> + if (!STREQ (devlist->me->me_devname, me->me_devname)) >> + { >> + /* Fix the devname if the mount dir has been >> + mounted over by a different devname. */ >> + free (devlist->me->me_devname); >> + devlist->me->me_devname = xstrdup (me->me_devname); >> + } >> + } >> + devlist = d; >> >> if (devlist) >> { >> >> But there is yet another issue with the -a mode for such >> over-mounted and therefore eclipsed file systems: >> >> # Create 2 file system images: 1 ext4, 1 xfs. >> $ dd if=/dev/zero bs=1M status=none count=128 of=img1 >> $ dd if=/dev/zero bs=1M status=none count=256 of=img2 >> $ mkfs -t ext4 -F img1 >/dev/null 2>&1 >> $ mkfs -t xfs -f img2 >/dev/null 2>&1 >> $ mkdir /mnt{1,2} >> >> # Mount both on /mnt1. >> $ mount -o loop img1 /mnt1 >> $ mount -o loop img2 /mnt1 >> >> # Mount the former (ext4) also on /mnt2 via its loop device. >> $ mount /dev/loop0 /mnt2 >> >> # Result: >> $ findmnt --output=TARGET,SOURCE,FSTYPE | grep loop >> ├─/mnt1 /dev/loop0 ext4 >> │ └─/mnt1 /dev/loop1 xfs >> └─/mnt2 /dev/loop0 ext4 >> >> Everything is fine now with the filtered df run ... >> >> $ src/df --out -h | grep loop >> /dev/loop1 xfs 256K 3 256K 1% 252M 13M 239M 6% - /mnt1 >> /dev/loop0 ext4 32K 11 32K 1% 120M 1.6M 110M 2% - /mnt2 >> >> ...but "df -a" prints the wrong statistics for the "over-mounted" /mnt1! >> >> $ src/df --out -h -a | grep loop >> /dev/loop0 ext4 256K 3 256K 1% 252M 13M 239M 6% - /mnt1 >> /dev/loop1 xfs 256K 3 256K 1% 252M 13M 239M 6% - /mnt1 >> /dev/loop0 ext4 32K 11 32K 1% 120M 1.6M 110M 2% - /mnt2 >> >> Okay, this is nothing new. >> BTW: strictly speaking, also the output of today's "df -t rootfs -a" >> is wrong because the numbers are definitely not that of the early-boot >> rootfs file system. >> >> Now, how should df handle this? >> >> a) >> df silently filters out the mount entries of all eclipsed mount dirs, >> even with -a. >> --> Hmm, I think this would probably contradict to POSIX. >> >> b) >> df prints an error diagnostic for each eclipsed mount dir, and exits >> non-Zero. >> --> Well, there are probably such mounts on every system, e.g. on my box: >> >> TARGET SOURCE FSTYPE >> /proc/sys/fs/binfmt_misc systemd-1 autofs >> /proc/sys/fs/binfmt_misc binfmt_misc binfmt_misc >> >> Therefore, a "df -a" would always fail. ;-( >> At least on my system, there are >> >> c) >> df prints a warning diagnostic for each eclipsed mount dir, and exits >> Zero (unless another error occurs). >> >> --> Due to the same reason as in b), these warning might be messy >> and users will probably be irritated. >> >> d) >> df outputs "-" for all numbers of such eclipsed file systems, e.g. >> >> $ src/df --out -h -a | grep mnt1 >> /dev/loop0 ext4 - - - - - - - - - /mnt1 >> /dev/loop1 xfs 256K 3 256K 1% 252M 13M 239M 6% - /mnt1 >> >> >> Maybe d) is the best solution, as it mirrors what df can know: >> it knows source, target and the file system type, but it doesn't >> have access to the block and inode numbers. >> >> WDYT? > > Thanks for the nice analysis and tests. > d) seems like the best option here, though we'd have to be careful > about cases where /proc/mounts was giving a system wide view, > while df wasn't privy to that due to mount namespaces or > overmounts etc. I'm not thinking of a specific issue here, > just the general problem. > > wrt c) and annoying warnings, I also notice `df -a` on a default Fedora 20 install here, > giving multiple duplicate warnings like: > df: ‘net:[4026532416]’: No such file or directory > df: ‘net:[4026532416]’: No such file or directory > That's due to: > $ grep net: /proc/mounts > proc net:[4026532416] proc rw,nosuid,nodev,noexec,relatime 0 0 > proc net:[4026532416] proc rw,nosuid,nodev,noexec,relatime 0 0 > Which is due to support for namespaces. > Seems like we should not try to lookup non absolute mount points? Hi Bernhard, I've attached 4 patches for df to: df: also deduplicate virtual file systems df: fix handling of symlinks in mount list df: ignore non file system entries in /proc/mounts maint: avoid clang -Wtautological-constant-out-of-range-compare warning Not included is your "overmount change" or the "d)" adjustment above, as I was unsure how you wanted to handle exactly. thanks, Pádraig. --------------000009000404090706020202 Content-Type: text/x-patch; name="df-8.23-fixes.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="df-8.23-fixes.patch" >From 62112df539326d9f874ad44a94f70b2a9749a975 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C3=A1draig=20Brady?= Date: Sat, 25 Jan 2014 01:14:29 +0000 Subject: [PATCH 1/4] df: also deduplicate virtual file systems * src/df.c (filter_mountlist): Remove the constraint that a '/' needs to be in the device name for a mount entry to be considered for deduplication. Virtual file systems also have storage associated with them (like tmpfs for example), and thus need to be deduplicated since they will be shown in the default df output and subject to --total processing also. * test/df/skip-duplicates.sh: Add a test to ensure we deduplicate all entries, even for virtual file systems. Also avoid possible length operations on many remote file systems in the initial check of df operation. Also avoid the assumption that "/root" is on the same file system as "/". * NEWS: Mention the change in behavior. --- NEWS | 2 + src/df.c | 31 ++++++++++++--------------- tests/df/skip-duplicates.sh | 47 +++++++++++++++++++++++++++++++----------- 3 files changed, 50 insertions(+), 30 deletions(-) diff --git a/NEWS b/NEWS index 4efd60d..c204b68 100644 --- a/NEWS +++ b/NEWS @@ -44,6 +44,8 @@ GNU coreutils NEWS -*- outline -*- [These dd bugs were present in "the beginning".] + df now correctly elides duplicates for virtual file systems like tmpfs. + head --bytes=-N and --lines=-N now handles devices more consistently, not ignoring data from virtual devices like /dev/zero, or on BSD systems data from tty devices. diff --git a/src/df.c b/src/df.c index e763943..2b5a54e 100644 --- a/src/df.c +++ b/src/df.c @@ -630,26 +630,23 @@ filter_mount_list (void) } else { - /* If the device name is a real path name ... */ - if (strchr (me->me_devname, '/')) + /* If we've already seen this device... */ + for (devlist = devlist_head; devlist; devlist = devlist->next) + if (devlist->dev_num == buf.st_dev) + break; + + if (devlist) { - /* ... try to find its device number in the devlist. */ - for (devlist = devlist_head; devlist; devlist = devlist->next) - if (devlist->dev_num == buf.st_dev) - break; + discard_me = me; - if (devlist) + /* ...let the shorter mountdir win. */ + if ((strchr (me->me_devname, '/') + && ! strchr (devlist->me->me_devname, '/')) + || (strlen (devlist->me->me_mountdir) + > strlen (me->me_mountdir))) { - discard_me = me; - - /* Let the shorter mountdir win. */ - if (! strchr (devlist->me->me_devname, '/') - || (strlen (devlist->me->me_mountdir) - > strlen (me->me_mountdir))) - { - discard_me = devlist->me; - devlist->me = me; - } + discard_me = devlist->me; + devlist->me = me; } } } diff --git a/tests/df/skip-duplicates.sh b/tests/df/skip-duplicates.sh index 266520a..d872f27 100755 --- a/tests/df/skip-duplicates.sh +++ b/tests/df/skip-duplicates.sh @@ -21,19 +21,28 @@ print_ver_ df require_gcc_shared_ -df || skip_ "df fails" +# We use --local here so as to not activate +# potentially very many remote mounts. +df --local || skip_ "df fails" -# Simulate an mtab file with two entries of the same device number. -# Also add entries with unstatable mount dirs to ensure that's handled. +export CU_NONROOT_FS=$(df --local --output=target 2>&1 | grep /. | head -n1) +test -z "$CU_NONROOT_FS" && unique_entries=1 || unique_entries=2 + +# Simulate an mtab file to test various cases. cat > k.c <<'EOF' || framework_failure_ #include #include +#include #include +#define STREQ(a, b) (strcmp (a, b) == 0) + struct mntent *getmntent (FILE *fp) { + static char *nonroot_fs; + static int done; + /* Prove that LD_PRELOAD works. */ - static int done = 0; if (!done) { fclose (fopen ("x", "w")); @@ -43,18 +52,30 @@ struct mntent *getmntent (FILE *fp) static struct mntent mntents[] = { {.mnt_fsname="/short", .mnt_dir="/invalid/mount/dir"}, {.mnt_fsname="fsname", .mnt_dir="/",}, - {.mnt_fsname="/fsname", .mnt_dir="/root"}, + {.mnt_fsname="/fsname", .mnt_dir="/."}, {.mnt_fsname="/fsname", .mnt_dir="/"}, + {.mnt_fsname="virtfs", .mnt_dir="/NONROOT"}, + {.mnt_fsname="virtfs", .mnt_dir="/NONROOT"}, }; - if (!getenv ("CU_TEST_DUPE_INVALID") && done == 1) + if (done == 1) + { + nonroot_fs = getenv ("CU_NONROOT_FS"); + if (!nonroot_fs || !*nonroot_fs) + nonroot_fs = "/"; /* merge into / entries. */ + } + + if (done == 1 && !getenv ("CU_TEST_DUPE_INVALID")) done++; /* skip the first entry. */ - while (done++ <= 4) + while (done++ <= 6) { mntents[done-2].mnt_type = "-"; + if (STREQ (mntents[done-2].mnt_dir, "/NONROOT")) + mntents[done-2].mnt_dir = nonroot_fs; return &mntents[done-2]; } + return NULL; } EOF @@ -69,22 +90,22 @@ test -f x || skip_ "internal test failure: maybe LD_PRELOAD doesn't work?" # The fake mtab file should only contain entries # having the same device number; thus the output should -# consist of a header and one entry. +# consist of a header and unique entries. LD_PRELOAD=./k.so df >out || fail=1 -test $(wc -l out && fail=1 -test $(wc -l out || fail=1 -test $(wc -l From 3449cad1576a3d584b248524bd03ed1b3d6bcb0a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C3=A1draig=20Brady?= Date: Mon, 12 May 2014 13:29:01 +0100 Subject: [PATCH 2/4] df: fix handling of symlinks in mount list The symlink handling in commit v8.21-172-g33660b4 was incomplete in the case where there were symlinks in the mount list itself. For example, in the case where /dev/mapper/fedora-home was in the mount list and that in turn was a symlink to /dev/dm-2, we have: before> df --out=source /dev/mapper/fedora-home devtmpfs after > df --out=source /dev/mapper/fedora-home /dev/mapper/fedora-home * src/df.c (get_disk): Compare canonicalized device names from the mount list. Note we still display the non canonicalized name, even if longer, as we assume that is the most representative. * tests/df/df-symlink.sh: This could theoretically fail on some systems depending on the content of the mount list, but adjust to fail on any system where symlinks are present in the mount list for the current dir. --- src/df.c | 12 ++++++++++-- tests/df/df-symlink.sh | 7 +++++++ 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/src/df.c b/src/df.c index 2b5a54e..24897a3 100644 --- a/src/df.c +++ b/src/df.c @@ -1056,13 +1056,19 @@ get_disk (char const *disk) char const *file = disk; char *resolved = canonicalize_file_name (disk); - if (resolved && resolved[0] == '/') + if (resolved && IS_ABSOLUTE_FILE_NAME (resolved)) disk = resolved; size_t best_match_len = SIZE_MAX; for (me = mount_list; me; me = me->me_next) { - if (STREQ (disk, me->me_devname)) + /* TODO: Should cache canon_dev in the mount_entry struct. */ + char *devname = me->me_devname; + char *canon_dev = canonicalize_file_name (me->me_devname); + if (canon_dev && IS_ABSOLUTE_FILE_NAME (canon_dev)) + devname = canon_dev; + + if (STREQ (disk, devname)) { size_t len = strlen (me->me_mountdir); if (len < best_match_len) @@ -1074,6 +1080,8 @@ get_disk (char const *disk) best_match_len = len; } } + + free (canon_dev); } free (resolved); diff --git a/tests/df/df-symlink.sh b/tests/df/df-symlink.sh index aaed810..6d96bd2 100755 --- a/tests/df/df-symlink.sh +++ b/tests/df/df-symlink.sh @@ -28,4 +28,11 @@ df --out=source,target "$disk" > exp || skip_ "cannot get info for $disk" df --out=source,target symlink > out || fail=1 compare exp out || fail=1 +# Ensure we output the same values for device nodes and '.' +# This was not the case in coreutil-8.22 on systems +# where the device in the mount list was a symlink itself. +# I.E. '.' => /dev/mapper/fedora-home -> /dev/dm-2 +df --out=source,target '.' > out || fail=1 +compare exp out || fail=1 + Exit $fail -- 1.7.7.6 >From 3e6da84f0af81b2a8a9539b14889f299680d7f7f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C3=A1draig=20Brady?= Date: Mon, 12 May 2014 14:49:13 +0100 Subject: [PATCH 3/4] df: ignore non file system entries in /proc/mounts Linux with network namespaces contains entries in /proc/mounts like: proc net:[4026532464] proc rw,nosuid,nodev,noexec,relatime 0 0 resulting in a failure to stat 'net:[...]', inducing a warning and an exit with failure status. * src/df.c (get_dev): Ignore all relative mount points. * tests/df/skip-duplicates.sh: Add an entry to test relative dirs. --- src/df.c | 5 +++++ tests/df/skip-duplicates.sh | 3 ++- 2 files changed, 7 insertions(+), 1 deletions(-) diff --git a/src/df.c b/src/df.c index 24897a3..a7fc57f 100644 --- a/src/df.c +++ b/src/df.c @@ -853,6 +853,11 @@ get_dev (char const *disk, char const *mount_point, char const* file, if (!selected_fstype (fstype) || excluded_fstype (fstype)) return; + /* Ignore relative MOUNT_POINTs, which are present for example + in /proc/mounts on Linux with network namespaces. */ + if (!force_fsu && mount_point && ! IS_ABSOLUTE_FILE_NAME (mount_point)) + return; + /* If MOUNT_POINT is NULL, then the file system is not mounted, and this program reports on the file system that the special file is on. It would be better to report on the unmounted file system, diff --git a/tests/df/skip-duplicates.sh b/tests/df/skip-duplicates.sh index d872f27..44f7d4c 100755 --- a/tests/df/skip-duplicates.sh +++ b/tests/df/skip-duplicates.sh @@ -56,6 +56,7 @@ struct mntent *getmntent (FILE *fp) {.mnt_fsname="/fsname", .mnt_dir="/"}, {.mnt_fsname="virtfs", .mnt_dir="/NONROOT"}, {.mnt_fsname="virtfs", .mnt_dir="/NONROOT"}, + {.mnt_fsname="netns", .mnt_dir="net:[1234567]"}, }; if (done == 1) @@ -68,7 +69,7 @@ struct mntent *getmntent (FILE *fp) if (done == 1 && !getenv ("CU_TEST_DUPE_INVALID")) done++; /* skip the first entry. */ - while (done++ <= 6) + while (done++ <= 7) { mntents[done-2].mnt_type = "-"; if (STREQ (mntents[done-2].mnt_dir, "/NONROOT")) -- 1.7.7.6 >From 6e4f211d62110a719a42b13da59e5c9b073f29fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C3=A1draig=20Brady?= Date: Mon, 12 May 2014 15:46:43 +0100 Subject: [PATCH 4/4] maint: avoid clang -Wtautological-constant-out-of-range-compare warning * src/df.c (decode_output_arg): Use only enum constants to avoid clang "warning: comparison of constant -1 with expression of type 'display_field_t' is always false" --- src/df.c | 7 ++++--- 1 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/df.c b/src/df.c index a7fc57f..01ecca6 100644 --- a/src/df.c +++ b/src/df.c @@ -144,7 +144,8 @@ typedef enum IAVAIL_FIELD, /* inodes available */ IPCENT_FIELD, /* inodes used in percent */ TARGET_FIELD, /* mount point */ - FILE_FIELD /* specified file name */ + FILE_FIELD, /* specified file name */ + INVALID_FIELD /* validation marker */ } display_field_t; /* Flag if a field contains a block, an inode or another value. */ @@ -372,7 +373,7 @@ decode_output_arg (char const *arg) *comma++ = 0; /* process S. */ - display_field_t field = -1; + display_field_t field = INVALID_FIELD; for (unsigned int i = 0; i < ARRAY_CARDINALITY (field_data); i++) { if (STREQ (field_data[i].arg, s)) @@ -381,7 +382,7 @@ decode_output_arg (char const *arg) break; } } - if (field == -1) + if (field == INVALID_FIELD) { error (0, 0, _("option --output: field %s unknown"), quote (s)); usage (EXIT_FAILURE); -- 1.7.7.6 --------------000009000404090706020202-- From debbugs-submit-bounces@debbugs.gnu.org Tue May 13 18:20:21 2014 Received: (at 16539) by debbugs.gnu.org; 13 May 2014 22:20:21 +0000 Received: from localhost ([127.0.0.1]:34484 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1WkL3c-00054S-K4 for submit@debbugs.gnu.org; Tue, 13 May 2014 18:20:21 -0400 Received: from mout.kundenserver.de ([212.227.17.13]:60026) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1WkL3Z-00054E-T2 for 16539@debbugs.gnu.org; Tue, 13 May 2014 18:20:18 -0400 Received: from [192.168.1.10] (p5084F89F.dip0.t-ipconnect.de [80.132.248.159]) by mrelayeu.kundenserver.de (node=mreue101) with ESMTP (Nemesis) id 0LuMNz-1WtvpO1IZj-011l37; Wed, 14 May 2014 00:20:09 +0200 Message-ID: <53729A98.2020502@bernhard-voelker.de> Date: Wed, 14 May 2014 00:20:08 +0200 From: Bernhard Voelker User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.4.0 MIME-Version: 1.0 To: =?UTF-8?B?UMOhZHJhaWcgQnJhZHk=?= Subject: Re: bug#16539: More details on df command output for you References: <67f0ced2351b31a6ac4523659f306b25@msmail.compro.net> <3ce9319232fc3427c2ecefb1d68df226@msmail.compro.net> <52E2E8BF.1000700@bernhard-voelker.de> <52E32D5D.2030900@draigBrady.com> <52E44EE4.9020503@bernhard-voelker.de> <52E4F174.9040602@draigBrady.com> <52E59BDE.9020206@bernhard-voelker.de> <52E5B108.5080304@draigBrady.com> <5370E47F.3030401@draigBrady.com> In-Reply-To: <5370E47F.3030401@draigBrady.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Provags-ID: V02:K0:HlaI8dZVmTihgrsBVpsS3yO1kqnqKEgHiJVxO69F9kf Jax3DTsdZurLUkuZOA6c0jAa+ucTq8vmKm5CPH/1F86HntXYCU fBJIVZ4JjuZp7TzH+ILwmtITj2OrrI3DPASPsPK44HFTPNz6B6 3N0P3hPp4Sd0ArsI+6Dhsjr9/uB7d66ZKwt7l/vlx7/Vh3iTXA IjmnC3/paqsNL7LPKMCvTMeCt9Evj/kdIUU2LjrqVJ6DG3LFCw fJvt5LQCk65El2Vg9xhlkGUbuvIRECm4/LnBEI57WvHgyauelI qO0NmXFqxQQbn8Olz24i0ki2Qc/3Gf0yboglyPi758dGSiSlTU hwdLJRhNT3YKHAenqHZrOV1MqjjFcvDErDngW8Pol X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 16539 Cc: 16539@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 0.0 (/) On 05/12/2014 05:10 PM, Pádraig Brady wrote: > I've attached 4 patches for df to: > > df: also deduplicate virtual file systems > df: fix handling of symlinks in mount list > df: ignore non file system entries in /proc/mounts > maint: avoid clang -Wtautological-constant-out-of-range-compare warning They are look good to me - great work, thanks! AFAIR, the last one was also warned about by Coverity (but I can't check now as their website is down for maintenance). > Not included is your "overmount change" or the "d)" adjustment above, > as I was unsure how you wanted to handle exactly. To recap, this was the problem: $ mount /dev/sda5 /tmp/mnt $ mount -o loop tmp.img /tmp/mnt df - even including your 4 patches - shows wrong results: $ src/df | grep mnt /dev/sda5 59365 1308 53471 3% /tmp/mnt $ src/df -a | grep mnt /dev/sda5 59365 1308 53471 3% /tmp/mnt /dev/loop0 59365 1308 53471 3% /tmp/mnt The idea was to trust the order of /proc/mounts $ tail -n2 /proc/mounts /dev/sda5 /tmp/mnt ext2 rw,relatime 0 0 /dev/loop0 /tmp/mnt ext3 rw,relatime,data=ordered 0 0 i.e., loop through the mount list leaving only the last unique (maybe canonicalized) mount point. Another special case is when a mount point is not reachable at all anymore: /dev/sda5 /tmp/mnt/some/subdir ext2 rw,relatime 0 0 /dev/loop0 /tmp/mnt ext3 rw,relatime,data=ordered 0 0 I recommend discarding eclipsed mounts in normal output, and output "-" values with -a. Thanks & have a nice day, Berny From unknown Thu Jun 19 12:19:43 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Wed, 11 Jun 2014 11:24:04 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator From debbugs-submit-bounces@debbugs.gnu.org Tue Jun 17 12:01:32 2014 Received: (at control) by debbugs.gnu.org; 17 Jun 2014 16:01:32 +0000 Received: from localhost ([127.0.0.1]:50808 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Wwvp8-0005hH-Md for submit@debbugs.gnu.org; Tue, 17 Jun 2014 12:01:31 -0400 Received: from mail2.vodafone.ie ([213.233.128.44]:31707) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Wwvp1-0005gr-Lb for control@debbugs.gnu.org; Tue, 17 Jun 2014 12:01:24 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AqABAI5loFNtTcgV/2dsb2JhbAANTYQZgwyKJKBflT4ye4UYCipUDQIFFgsCCwMCAQIBOQYCAhUIAQGIQ6wrd58OF4EqjWmCYYFMBKFmj3Y Received: from unknown (HELO [192.168.1.79]) ([109.77.200.21]) by mail2.vodafone.ie with ESMTP; 17 Jun 2014 17:01:14 +0100 Message-ID: <53A06649.4060105@draigBrady.com> Date: Tue, 17 Jun 2014 17:01:13 +0100 From: =?UTF-8?B?UMOhZHJhaWcgQnJhZHk=?= User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130110 Thunderbird/17.0.2 MIME-Version: 1.0 To: control@debbugs.gnu.org X-Enigmail-Version: 1.6 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Score: 2.0 (++) X-Spam-Report: Spam detection software, running on the system "debbugs.gnu.org", has identified this incoming email as possible spam. The original message has been attached to this so you can view it (if it isn't spam) or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: unarchive 16539 [...] Content analysis details: (2.0 points, 10.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at http://www.dnswl.org/, no trust [213.233.128.44 listed in list.dnswl.org] 1.8 MISSING_SUBJECT Missing Subject: header 0.2 NO_SUBJECT Extra score for no subject X-Debbugs-Envelope-To: control X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 2.0 (++) X-Spam-Report: Spam detection software, running on the system "debbugs.gnu.org", has identified this incoming email as possible spam. The original message has been attached to this so you can view it (if it isn't spam) or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: unarchive 16539 [...] Content analysis details: (2.0 points, 10.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at http://www.dnswl.org/, no trust [213.233.128.44 listed in list.dnswl.org] 1.8 MISSING_SUBJECT Missing Subject: header 0.2 NO_SUBJECT Extra score for no subject 0.0 TVD_SPACE_RATIO TVD_SPACE_RATIO unarchive 16539 From debbugs-submit-bounces@debbugs.gnu.org Tue Jun 17 12:04:02 2014 Received: (at 16539) by debbugs.gnu.org; 17 Jun 2014 16:04:02 +0000 Received: from localhost ([127.0.0.1]:50813 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1WwvrZ-0005lB-5B for submit@debbugs.gnu.org; Tue, 17 Jun 2014 12:04:02 -0400 Received: from mail2.vodafone.ie ([213.233.128.44]:33641) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1WwvrR-0005kp-Er for 16539@debbugs.gnu.org; Tue, 17 Jun 2014 12:03:55 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AtYCAI5loFNtTcgV/2dsb2JhbAANTYNfU4JzwEoBgSOEeAEBAQQjBGILDQQDAQIBCSECAg8CPggTBgIBARaILQOsKHefDheOZQwMgneBTASSAIFAgnSFUoVghjiJPg Received: from unknown (HELO [192.168.1.79]) ([109.77.200.21]) by mail2.vodafone.ie with ESMTP; 17 Jun 2014 17:03:43 +0100 Message-ID: <53A066DB.308@draigBrady.com> Date: Tue, 17 Jun 2014 17:03:39 +0100 From: =?UTF-8?B?UMOhZHJhaWcgQnJhZHk=?= User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130110 Thunderbird/17.0.2 MIME-Version: 1.0 To: 16539@debbugs.gnu.org Subject: Re: bug#16539: More details on df command output for you References: <67f0ced2351b31a6ac4523659f306b25@msmail.compro.net> <3ce9319232fc3427c2ecefb1d68df226@msmail.compro.net> <52E2E8BF.1000700@bernhard-voelker.de> <52E32D5D.2030900@draigBrady.com> <52E44EE4.9020503@bernhard-voelker.de> <52E4F174.9040602@draigBrady.com> <52E59BDE.9020206@bernhard-voelker.de> <52E5B108.5080304@draigBrady.com> <5370E47F.3030401@draigBrady.com> <53729A98.2020502@bernhard-voelker.de> In-Reply-To: <53729A98.2020502@bernhard-voelker.de> X-Enigmail-Version: 1.6 Content-Type: multipart/mixed; boundary="------------050908070805050206050709" X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 16539 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 0.0 (/) This is a multi-part message in MIME format. --------------050908070805050206050709 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit On 05/13/2014 11:20 PM, Bernhard Voelker wrote: > On 05/12/2014 05:10 PM, Pádraig Brady wrote: >> I've attached 4 patches for df to: >> >> df: also deduplicate virtual file systems >> df: fix handling of symlinks in mount list >> df: ignore non file system entries in /proc/mounts >> maint: avoid clang -Wtautological-constant-out-of-range-compare warning > > They are look good to me - great work, thanks! > AFAIR, the last one was also warned about by Coverity (but > I can't check now as their website is down for maintenance). > >> Not included is your "overmount change" or the "d)" adjustment above, >> as I was unsure how you wanted to handle exactly. > > To recap, this was the problem: > > $ mount /dev/sda5 /tmp/mnt > $ mount -o loop tmp.img /tmp/mnt > > df - even including your 4 patches - shows wrong results: > > $ src/df | grep mnt > /dev/sda5 59365 1308 53471 3% /tmp/mnt > > $ src/df -a | grep mnt > /dev/sda5 59365 1308 53471 3% /tmp/mnt > /dev/loop0 59365 1308 53471 3% /tmp/mnt > > The idea was to trust the order of /proc/mounts > > $ tail -n2 /proc/mounts > /dev/sda5 /tmp/mnt ext2 rw,relatime 0 0 > /dev/loop0 /tmp/mnt ext3 rw,relatime,data=ordered 0 0 > > i.e., loop through the mount list leaving only the > last unique (maybe canonicalized) mount point. > > Another special case is when a mount point is not reachable > at all anymore: > > /dev/sda5 /tmp/mnt/some/subdir ext2 rw,relatime 0 0 > /dev/loop0 /tmp/mnt ext3 rw,relatime,data=ordered 0 0 > > I recommend discarding eclipsed mounts in normal output, > and output "-" values with -a. The attached (on top of df-fix-last-device.diff) should put "-" placeholder values in the needed cases. That should be it for df fixes for coreutils-8.23. cheers, Pádraig. --------------050908070805050206050709 Content-Type: text/x-patch; name="df-fix-wrong-device.diff" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="df-fix-wrong-device.diff" >From 0a4b8027049f6746a237c9fc34a0e0a4afdcfc62 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C3=A1draig=20Brady?= Date: Wed, 4 Jun 2014 00:09:11 +0100 Subject: [PATCH] df: output placeholder values for inaccessible mount points A system provided mount entry may be unavailable due to TOCTOU race, or if another device has been overmounted at that position, or due to access permissions. In all these cases output "-" placeholder values rather than either producing an error, or in the overmount case outputting values for the wrong device. * src/df.c (device_list): A new global list updated from ... (filter_mount_list): Adjust to take a parameter as to whether update the global mount list, or only the mount <-> device ID mapping. (get_dev): Use the device ID mapping to ensure we're not outputting stats for the wrong device. Also output plaeholder values when we can't access a system specified mount point. (devname_for_dev): A new function to search the mount <-> dev mapping. * test/df/skip-duplicates.sh: Adjust accordingly. * NEWS: Mention the bug fixes. Discussed at: http://bugs.gnu.org/16539 --- NEWS | 6 ++- src/df.c | 106 ++++++++++++++++++++++++++++++++----------- tests/df/skip-duplicates.sh | 9 +++- 3 files changed, 89 insertions(+), 32 deletions(-) diff --git a/NEWS b/NEWS index 5d1fe99..7ba145e 100644 --- a/NEWS +++ b/NEWS @@ -44,8 +44,10 @@ GNU coreutils NEWS -*- outline -*- [These dd bugs were present in "the beginning".] - df now elides duplicates for virtual file systems like tmpfs, and will - display the correct device name for directories mounted multiple times. + df now elides duplicates for virtual file systems like tmpfs. + Displays the correct device details for points mounted multiple times. + Displays placeholder values for inaccessible file systems, + rather than error messages or values for the wrong file system. [These bugs were present in "the beginning".] head --bytes=-N and --lines=-N now handles devices more diff --git a/src/df.c b/src/df.c index 10047ce..c7da208 100644 --- a/src/df.c +++ b/src/df.c @@ -45,12 +45,12 @@ /* Filled with device numbers of examined file systems to avoid duplicities in output. */ -struct devlist +static struct devlist { dev_t dev_num; struct mount_entry *me; struct devlist *next; -}; +} *device_list; /* If true, show even file systems with zero size or uninteresting types. */ @@ -610,20 +610,21 @@ excluded_fstype (const char *fstype) me_mountdir wins. */ static void -filter_mount_list (void) +filter_mount_list (bool devices_only) { struct mount_entry *me; - /* Store of already-processed device numbers. */ - struct devlist *devlist_head = NULL; - - /* Sort all 'wanted' entries into the list devlist_head. */ + /* Sort all 'wanted' entries into the list device_list. */ for (me = mount_list; me;) { struct stat buf; struct devlist *devlist; struct mount_entry *discard_me = NULL; + /* TODO: On Linux we might avoid this stat() and another in get_dev() + by using the device IDs available from /proc/self/mountinfo. + read_file_system_list() could populate me_dev from those + for efficiency and accuracy. */ if (-1 == stat (me->me_mountdir, &buf)) { /* Stat failed - add ME to be able to complain about it later. */ @@ -632,7 +633,7 @@ filter_mount_list (void) else { /* If we've already seen this device... */ - for (devlist = devlist_head; devlist; devlist = devlist->next) + for (devlist = device_list; devlist; devlist = devlist->next) if (devlist->dev_num == buf.st_dev) break; @@ -661,8 +662,9 @@ filter_mount_list (void) if (discard_me) { - me = me->me_next; - free_mount_entry (discard_me); + me = me->me_next; + if (! devices_only) + free_mount_entry (discard_me); } else { @@ -670,26 +672,46 @@ filter_mount_list (void) devlist = xmalloc (sizeof *devlist); devlist->me = me; devlist->dev_num = buf.st_dev; - devlist->next = devlist_head; - devlist_head = devlist; + devlist->next = device_list; + device_list = devlist; me = me->me_next; } } /* Finally rebuild the mount_list from the devlist. */ - mount_list = NULL; - while (devlist_head) + if (! devices_only) { + mount_list = NULL; + while (device_list) + { + /* Add the mount entry. */ + me = device_list->me; + me->me_next = mount_list; + mount_list = me; + /* Free devlist entry and advance. */ + struct devlist *devlist = device_list->next; + free (device_list); + device_list = devlist; + } + } +} + +/* Search a mount entry list for device id DEV. + Return the corresponding device name if found or NULL if not. */ + +static char const * _GL_ATTRIBUTE_PURE +devname_for_dev (dev_t dev) +{ + struct devlist *dl = device_list; + + while (dl) { - /* Add the mount entry. */ - me = devlist_head->me; - me->me_next = mount_list; - mount_list = me; - /* Free devlist entry and advance. */ - struct devlist *devlist = devlist_head->next; - free (devlist_head); - devlist_head = devlist; + if (dl->dev_num == dev) + return dl->me->me_devname; + dl = dl->next; } + + return NULL; } /* Return true if N is a known integer value. On many file systems, @@ -878,9 +900,37 @@ get_dev (char const *disk, char const *mount_point, char const* file, fsu = *force_fsu; else if (get_fs_usage (stat_file, disk, &fsu)) { - error (0, errno, "%s", quote (stat_file)); - exit_status = EXIT_FAILURE; - return; + /* If we can't access a system provided entry due + to it not being present (now), or due to permissions, + just output placeholder values rather than failing. */ + if (process_all && (errno == EACCES || errno == ENOENT)) + { + fstype = "-"; + fsu.fsu_blocksize = fsu.fsu_blocks = fsu.fsu_bfree = + fsu.fsu_bavail = fsu.fsu_files = fsu.fsu_ffree = UINTMAX_MAX; + } + else + { + error (0, errno, "%s", quote (stat_file)); + exit_status = EXIT_FAILURE; + return; + } + } + else if (process_all && show_all_fs) + { + /* Ensure we don't output incorrect stats for overmounted directories. + Discard stats when the device name doesn't match. */ + struct stat sb; + if (stat (stat_file, &sb) == 0) + { + char const * devname = devname_for_dev (sb.st_dev); + if (devname && ! STREQ (devname, disk)) + { + fstype = "-"; + fsu.fsu_blocksize = fsu.fsu_blocks = fsu.fsu_bfree = + fsu.fsu_bavail = fsu.fsu_files = fsu.fsu_ffree = UINTMAX_MAX; + } + } } if (fsu.fsu_blocks == 0 && !show_all_fs && !show_listed_fs) @@ -1230,8 +1280,10 @@ get_all_entries (void) { struct mount_entry *me; - if (!show_all_fs) - filter_mount_list (); + if (! show_all_fs) + filter_mount_list (false); + else + filter_mount_list (true); for (me = mount_list; me; me = me->me_next) get_dev (me->me_devname, me->me_mountdir, NULL, NULL, me->me_type, diff --git a/tests/df/skip-duplicates.sh b/tests/df/skip-duplicates.sh index a620e73..1b19149 100755 --- a/tests/df/skip-duplicates.sh +++ b/tests/df/skip-duplicates.sh @@ -96,9 +96,10 @@ test -f x || skip_ "internal test failure: maybe LD_PRELOAD doesn't work?" LD_PRELOAD=./k.so df -T >out || fail=1 test $(wc -l out && fail=1 -test $(wc -l out || fail=1 +test $(wc -l out || fail=1 test $(wc -l ) id 1Wx4Wx-0007Ei-V7 for submit@debbugs.gnu.org; Tue, 17 Jun 2014 21:19:16 -0400 Received: from mout.kundenserver.de ([212.227.17.13]:53260) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Wx4Wu-0007EL-HY for 16539@debbugs.gnu.org; Tue, 17 Jun 2014 21:19:13 -0400 Received: from [192.168.1.10] (p548E5626.dip0.t-ipconnect.de [84.142.86.38]) by mrelayeu.kundenserver.de (node=mreue105) with ESMTP (Nemesis) id 0MKIQ2-1WyjDr0VMs-001ewE; Wed, 18 Jun 2014 03:19:05 +0200 Message-ID: <53A0E908.7080905@bernhard-voelker.de> Date: Wed, 18 Jun 2014 03:19:04 +0200 From: Bernhard Voelker User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.5.0 MIME-Version: 1.0 To: =?UTF-8?B?UMOhZHJhaWcgQnJhZHk=?= , 16539@debbugs.gnu.org Subject: Re: bug#16539: More details on df command output for you References: <67f0ced2351b31a6ac4523659f306b25@msmail.compro.net> <3ce9319232fc3427c2ecefb1d68df226@msmail.compro.net> <52E2E8BF.1000700@bernhard-voelker.de> <52E32D5D.2030900@draigBrady.com> <52E44EE4.9020503@bernhard-voelker.de> <52E4F174.9040602@draigBrady.com> <52E59BDE.9020206@bernhard-voelker.de> <52E5B108.5080304@draigBrady.com> <5370E47F.3030401@draigBrady.com> <53729A98.2020502@bernhard-voelker.de> <53A066DB.308@draigBrady.com> In-Reply-To: <53A066DB.308@draigBrady.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Provags-ID: V02:K0:Fmk3EK/P2cXx/Zvl4opvOQDX8k6xbH4vm0u+UQxE5O9 1dy5r9MMIbYQoGm/MrpsWVZkud0+qrZ667coQAfJWvtGlF8Fjm 2UGtdzXecO32jOXtJBaK3SsV5kqhR3+M8K5UWYkv6x1kJ2RMcD qZmLxvj8N4fmXhctuS9CgFOd/JHBL0Ajwu21i1MBphCj4sKVhL 06BspA6XnD9ckzJ5VwWUSsn2JaKQUGVGrG0x09rmNIKMZCzY86 IjtY6OYp2HDUW2EtaIl9xG7eVQppJR2kFIE2b/e31B/qDxo6K3 bhn8T1yEstzf/G1OnXCmZMWZpOeKSbmatINSX54xj5ybT/xP8e Km1XS5TTkfmzHxdNovQCVZUUo/IK1g/vpMKBxbbLR X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 16539 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 0.0 (/) On 06/17/2014 06:03 PM, Pádraig Brady wrote: > From 0a4b8027049f6746a237c9fc34a0e0a4afdcfc62 Mon Sep 17 00:00:00 2001 > From: =?UTF-8?q?P=C3=A1draig=20Brady?= > Date: Wed, 4 Jun 2014 00:09:11 +0100 > Subject: [PATCH] df: output placeholder values for inaccessible mount points > > A system provided mount entry may be unavailable due to TOCTOU race, > or if another device has been overmounted at that position, or due to > access permissions. In all these cases output "-" placeholder values > rather than either producing an error, or in the overmount case > outputting values for the wrong device. Cool: finally GNU df fulfills the first sentence of the POSIX spec ;-) http://pubs.opengroup.org/onlinepubs/9699919799/utilities/df.html The df utility shall write the amount of available space ... for file systems on which the invoking user has appropriate read access. I think we already discussed whether a warning would be better than a line with "-"s (or even silently omit the line) - and seeing the result is pleasing: Before: /usr/bin/df: ‘/root/backup’: Permission denied After: /dev/sda3 - - - - /root/backup > * src/df.c (device_list): A new global list updated from ... ... from what? > (filter_mount_list): Adjust to take a parameter as to whether > update the global mount list, or only the mount <-> device ID mapping. > (get_dev): Use the device ID mapping to ensure we're not outputting > stats for the wrong device. Also output plaeholder values when we s/plaeholder/placeholder/ > can't access a system specified mount point. > (devname_for_dev): A new function to search the mount <-> dev mapping. get_all_entries was also changed. > * test/df/skip-duplicates.sh: Adjust accordingly. > * NEWS: Mention the bug fixes. > > Discussed at: http://bugs.gnu.org/16539 > diff --git a/src/df.c b/src/df.c > index 10047ce..c7da208 100644 > --- a/src/df.c > +++ b/src/df.c > @@ -45,12 +45,12 @@ > > /* Filled with device numbers of examined file systems to avoid > duplicities in output. */ > -struct devlist > +static struct devlist > { > dev_t dev_num; > struct mount_entry *me; > struct devlist *next; > -}; > +} *device_list; Maybe I'm old-fashioned, but I'd have separated the struct definition from the variable definition ... well, personal style. > @@ -610,20 +610,21 @@ excluded_fstype (const char *fstype) > me_mountdir wins. */ > > static void > -filter_mount_list (void) > +filter_mount_list (bool devices_only) The parameter name isn't very intuitive (to me). Would it harm to add a sentence in the function description? > @@ -878,9 +900,37 @@ get_dev (char const *disk, char const *mount_point, char const* file, > fsu = *force_fsu; > else if (get_fs_usage (stat_file, disk, &fsu)) > { > - error (0, errno, "%s", quote (stat_file)); > - exit_status = EXIT_FAILURE; > - return; > + /* If we can't access a system provided entry due > + to it not being present (now), or due to permissions, > + just output placeholder values rather than failing. */ > + if (process_all && (errno == EACCES || errno == ENOENT)) > + { > + fstype = "-"; > + fsu.fsu_blocksize = fsu.fsu_blocks = fsu.fsu_bfree = > + fsu.fsu_bavail = fsu.fsu_files = fsu.fsu_ffree = UINTMAX_MAX; > + } > + else > + { > + error (0, errno, "%s", quote (stat_file)); > + exit_status = EXIT_FAILURE; > + return; > + } Is it possible that errno is leaking from one get_dev() invocation to another, i.e. that one failure eclipses another? > + } > + else if (process_all && show_all_fs) > + { > + /* Ensure we don't output incorrect stats for overmounted directories. > + Discard stats when the device name doesn't match. */ > + struct stat sb; > + if (stat (stat_file, &sb) == 0) > + { > + char const * devname = devname_for_dev (sb.st_dev); > + if (devname && ! STREQ (devname, disk)) > + { > + fstype = "-"; > + fsu.fsu_blocksize = fsu.fsu_blocks = fsu.fsu_bfree = > + fsu.fsu_bavail = fsu.fsu_files = fsu.fsu_ffree = UINTMAX_MAX; > + } > + } > } > > if (fsu.fsu_blocks == 0 && !show_all_fs && !show_listed_fs) > @@ -1230,8 +1280,10 @@ get_all_entries (void) > { > struct mount_entry *me; > > - if (!show_all_fs) > - filter_mount_list (); > + if (! show_all_fs) > + filter_mount_list (false); > + else > + filter_mount_list (true); Shorter? + filter_mount_list (show_all_fs); > for (me = mount_list; me; me = me->me_next) > get_dev (me->me_devname, me->me_mountdir, NULL, NULL, me->me_type, > diff --git a/tests/df/skip-duplicates.sh b/tests/df/skip-duplicates.sh > index a620e73..1b19149 100755 > --- a/tests/df/skip-duplicates.sh > +++ b/tests/df/skip-duplicates.sh > @@ -96,9 +96,10 @@ test -f x || skip_ "internal test failure: maybe LD_PRELOAD doesn't work?" > LD_PRELOAD=./k.so df -T >out || fail=1 > test $(wc -l > -# Ensure we fail when unable to stat invalid entries > -LD_PRELOAD=./k.so CU_TEST_DUPE_INVALID=1 df -T >out && fail=1 > -test $(wc -l +# Ensure we don't fail when unable to stat (currently) unavailable entries > +# instead outputting placeholder information > +LD_PRELOAD=./k.so CU_TEST_DUPE_INVALID=1 df -T >out || fail=1 > +test $(wc -l > # df should also prefer "/fsname" over "fsname" > if test "$unique_entries" = 2; then > @@ -113,6 +114,8 @@ test $(grep -c 'virtfs2.*fstype2' # Ensure that filtering duplicates does not affect -a processing. > LD_PRELOAD=./k.so df -a >out || fail=1 > test $(wc -l +# Ensure placeholder "-" values used for the overmounted "virtfs" my Thunderbird suggests: s/overmounted/over-mounted/ > +test $(grep -c 'virtfs *-' > # Ensure that filtering duplicates does not affect > # argument processing (now without the fake getmntent()). > -- 1.7.7.6 Great, we're getting closer! Finally, I have an edge case on my PC which is not yet covered: I have a backup partition mounted on /root/backup (which is not accessible by a normal user), and a read-only bind-mount of it: $ mount /dev/sda1 /root/backup $ mount --bind /root/backup /media/backup $ mount -o ro,remount,bind /media/backup (The 3rd command is just there for setting the read-only flag). df-8.21 perfectly skipped the inaccessible entry and went ahead with the read-only copy $ /usr/bin/df /dev/sda3 Filesystem 1K-blocks Used Available Use% Mounted on /dev/sda3 155396036 124425132 23054156 85% /media/backup while the latest one from git plus these 2 patches is falling over: $ src/df /dev/sda3 src/df: ‘/root/backup’: Permission denied This is a little regression. Thus said, I'm not 100% happy with the filtering yet. I don't have an idea right now how to solve it. Maybe in a couple of days ... I have to think about it. Thanks again & have a nice day, Berny From debbugs-submit-bounces@debbugs.gnu.org Wed Jun 18 08:10:38 2014 Received: (at 16539) by debbugs.gnu.org; 18 Jun 2014 12:10:38 +0000 Received: from localhost ([127.0.0.1]:51221 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1WxEhG-0007nm-Nu for submit@debbugs.gnu.org; Wed, 18 Jun 2014 08:10:38 -0400 Received: from mail5.vodafone.ie ([213.233.128.176]:36926) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1WxEhA-0007nS-OO for 16539@debbugs.gnu.org; Wed, 18 Jun 2014 08:10:32 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: ApUBACyBoVNtT4V1/2dsb2JhbAANTYNfg0bAXAGBIYR4AQEBAwEjDwFGBQsLDQEDAwECAQICBRYLAgIJAwIBAgE9CAYNAQUCAQGINg0IrAt3nwoXgSqMYGsHgneBTAEDljSLMo94awE Received: from unknown (HELO [192.168.1.79]) ([109.79.133.117]) by mail3.vodafone.ie with ESMTP; 18 Jun 2014 13:09:56 +0100 Message-ID: <53A18194.8050900@draigBrady.com> Date: Wed, 18 Jun 2014 13:09:56 +0100 From: =?UTF-8?B?UMOhZHJhaWcgQnJhZHk=?= User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130110 Thunderbird/17.0.2 MIME-Version: 1.0 To: Bernhard Voelker Subject: Re: bug#16539: More details on df command output for you References: <67f0ced2351b31a6ac4523659f306b25@msmail.compro.net> <3ce9319232fc3427c2ecefb1d68df226@msmail.compro.net> <52E2E8BF.1000700@bernhard-voelker.de> <52E32D5D.2030900@draigBrady.com> <52E44EE4.9020503@bernhard-voelker.de> <52E4F174.9040602@draigBrady.com> <52E59BDE.9020206@bernhard-voelker.de> <52E5B108.5080304@draigBrady.com> <5370E47F.3030401@draigBrady.com> <53729A98.2020502@bernhard-voelker.de> <53A066DB.308@draigBrady.com> <53A0E908.7080905@bernhard-voelker.de> In-Reply-To: <53A0E908.7080905@bernhard-voelker.de> X-Enigmail-Version: 1.6 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 16539 Cc: 16539@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 0.0 (/) On 06/18/2014 02:19 AM, Bernhard Voelker wrote: > On 06/17/2014 06:03 PM, Pádraig Brady wrote: >> From 0a4b8027049f6746a237c9fc34a0e0a4afdcfc62 Mon Sep 17 00:00:00 2001 >> From: =?UTF-8?q?P=C3=A1draig=20Brady?= >> Date: Wed, 4 Jun 2014 00:09:11 +0100 >> Subject: [PATCH] df: output placeholder values for inaccessible mount points I agree with all your suggested tweaks here. > Finally, I have an edge case on my PC which is not yet covered: > I have a backup partition mounted on /root/backup (which is not > accessible by a normal user), and a read-only bind-mount of it: > > $ mount /dev/sda1 /root/backup > $ mount --bind /root/backup /media/backup > $ mount -o ro,remount,bind /media/backup > > (The 3rd command is just there for setting the read-only flag). > > df-8.21 perfectly skipped the inaccessible entry and went ahead > with the read-only copy > > $ /usr/bin/df /dev/sda3 > Filesystem 1K-blocks Used Available Use% Mounted on > /dev/sda3 155396036 124425132 23054156 85% /media/backup > > while the latest one from git plus these 2 patches is falling over: > > $ src/df /dev/sda3 > src/df: ‘/root/backup’: Permission denied > > This is a little regression. > Thus said, I'm not 100% happy with the filtering yet. The above is a separate case actually, triggered in 8.22 with: http://git.sv.gnu.org/gitweb/?p=coreutils.git;a=commitdiff;h=2091f449 Note that only triggers the issue when the last mount point for a device is accessible. If the /proc/mounts order was different, then you'd get the issue anyway. I'll fix this by adding a stat() to the selection criteria in get_disk(). Thanks for the excellent review. Pádraig. From debbugs-submit-bounces@debbugs.gnu.org Wed Jun 18 13:22:03 2014 Received: (at 16539) by debbugs.gnu.org; 18 Jun 2014 17:22:03 +0000 Received: from localhost ([127.0.0.1]:52029 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1WxJYg-0000Qt-2d for submit@debbugs.gnu.org; Wed, 18 Jun 2014 13:22:02 -0400 Received: from mail6.vodafone.ie ([213.233.128.184]:6907) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1WxJYc-0000QI-3J for 16539@debbugs.gnu.org; Wed, 18 Jun 2014 13:21:59 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AhIDAEzKoVNtT4V1/2dsb2JhbAANTYNfU4JzwFsBgSGEeAEBAQQjBFIQCw0BAwMBAgEJFgsCAgkDAgECAT0IBg0BBQIBARaILQMFrSp3nn0XjgpaEQcJgm6BTASSAIFAgnSFUoVghjiJQGsB Received: from unknown (HELO [192.168.1.79]) ([109.79.133.117]) by mail3.vodafone.ie with ESMTP; 18 Jun 2014 18:21:50 +0100 Message-ID: <53A1CAAE.9070704@draigBrady.com> Date: Wed, 18 Jun 2014 18:21:50 +0100 From: =?UTF-8?B?UMOhZHJhaWcgQnJhZHk=?= User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130110 Thunderbird/17.0.2 MIME-Version: 1.0 To: Bernhard Voelker Subject: Re: bug#16539: More details on df command output for you References: <67f0ced2351b31a6ac4523659f306b25@msmail.compro.net> <3ce9319232fc3427c2ecefb1d68df226@msmail.compro.net> <52E2E8BF.1000700@bernhard-voelker.de> <52E32D5D.2030900@draigBrady.com> <52E44EE4.9020503@bernhard-voelker.de> <52E4F174.9040602@draigBrady.com> <52E59BDE.9020206@bernhard-voelker.de> <52E5B108.5080304@draigBrady.com> <5370E47F.3030401@draigBrady.com> <53729A98.2020502@bernhard-voelker.de> <53A066DB.308@draigBrady.com> <53A0E908.7080905@bernhard-voelker.de> <53A18194.8050900@draigBrady.com> In-Reply-To: <53A18194.8050900@draigBrady.com> X-Enigmail-Version: 1.6 Content-Type: multipart/mixed; boundary="------------090406090509090007060108" X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 16539 Cc: 16539@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 0.0 (/) This is a multi-part message in MIME format. --------------090406090509090007060108 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit On 06/18/2014 01:09 PM, Pádraig Brady wrote: > On 06/18/2014 02:19 AM, Bernhard Voelker wrote: >> On 06/17/2014 06:03 PM, Pádraig Brady wrote: >>> From 0a4b8027049f6746a237c9fc34a0e0a4afdcfc62 Mon Sep 17 00:00:00 2001 >>> From: =?UTF-8?q?P=C3=A1draig=20Brady?= >>> Date: Wed, 4 Jun 2014 00:09:11 +0100 >>> Subject: [PATCH] df: output placeholder values for inaccessible mount points > > I agree with all your suggested tweaks here. > >> Finally, I have an edge case on my PC which is not yet covered: >> I have a backup partition mounted on /root/backup (which is not >> accessible by a normal user), and a read-only bind-mount of it: >> >> $ mount /dev/sda1 /root/backup >> $ mount --bind /root/backup /media/backup >> $ mount -o ro,remount,bind /media/backup >> >> (The 3rd command is just there for setting the read-only flag). >> >> df-8.21 perfectly skipped the inaccessible entry and went ahead >> with the read-only copy >> >> $ /usr/bin/df /dev/sda3 >> Filesystem 1K-blocks Used Available Use% Mounted on >> /dev/sda3 155396036 124425132 23054156 85% /media/backup >> >> while the latest one from git plus these 2 patches is falling over: >> >> $ src/df /dev/sda3 >> src/df: ‘/root/backup’: Permission denied >> >> This is a little regression. >> Thus said, I'm not 100% happy with the filtering yet. > > The above is a separate case actually, triggered in 8.22 with: > http://git.sv.gnu.org/gitweb/?p=coreutils.git;a=commitdiff;h=2091f449 > Note that only triggers the issue when the last mount point for a device > is accessible. If the /proc/mounts order was different, then you'd get the issue anyway. > I'll fix this by adding a stat() to the selection criteria in get_disk(). The attached 2 patches on top of current master, should address your suggested tweaks and above ordering issue. thanks, Pádraig. --------------090406090509090007060108 Content-Type: text/x-patch; name="df-fix-wrong-device.diff" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="df-fix-wrong-device.diff" >From 8a9d785f0145cc43c0a9da2763bcb32d7f2011f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C3=A1draig=20Brady?= Date: Wed, 4 Jun 2014 00:09:11 +0100 Subject: [PATCH 1/2] df: output placeholder values for inaccessible mount points A system provided mount entry may be unavailable due to TOCTOU race, or if another device has been over-mounted at that position, or due to access permissions. In all these cases output "-" placeholder values rather than either producing an error, or in the over-mount case outputting values for the wrong device. * src/df.c (device_list): A new global list now updated by filter_mount_list(). (filter_mount_list): Adjust to take a parameter as to whether update the global mount list, or only the mount <-> device ID mapping. (get_dev): Use the device ID mapping to ensure we're not outputting stats for the wrong device. Also output placeholder values when we can't access a system specified mount point. (get_all_entries): Set the DEVICE_ONLY param for filter_mount_list(). (devname_for_dev): A new function to search the mount <-> dev mapping. * test/df/skip-duplicates.sh: Adjust accordingly. * NEWS: Mention the bug fixes. Discussed at: http://bugs.gnu.org/16539 --- NEWS | 6 ++- src/df.c | 109 ++++++++++++++++++++++++++++++++----------- tests/df/skip-duplicates.sh | 6 ++- 3 files changed, 89 insertions(+), 32 deletions(-) diff --git a/NEWS b/NEWS index 77286f8..15846b0 100644 --- a/NEWS +++ b/NEWS @@ -44,8 +44,10 @@ GNU coreutils NEWS -*- outline -*- [These dd bugs were present in "the beginning".] - df now elides duplicates for virtual file systems like tmpfs, and will - display the correct device name for directories mounted multiple times. + df now elides duplicates for virtual file systems like tmpfs. + Displays the correct device details for points mounted multiple times. + Displays placeholder values for inaccessible file systems, + rather than error messages or values for the wrong file system. [These bugs were present in "the beginning".] head --bytes=-N and --lines=-N now handles devices more diff --git a/src/df.c b/src/df.c index 10047ce..d6d4b0e 100644 --- a/src/df.c +++ b/src/df.c @@ -45,12 +45,12 @@ /* Filled with device numbers of examined file systems to avoid duplicities in output. */ -struct devlist +static struct devlist { dev_t dev_num; struct mount_entry *me; struct devlist *next; -}; +} *device_list; /* If true, show even file systems with zero size or uninteresting types. */ @@ -607,23 +607,25 @@ excluded_fstype (const char *fstype) In the case of duplicities - based on the device number - the mount entry with a '/' in its me_devname (i.e. not pseudo name like tmpfs) wins. If both have a real devname (e.g. bind mounts), then that with the shorter - me_mountdir wins. */ + me_mountdir wins. With DEVICES_ONLY == true (set with df -a), only update + the global device_list, rather than filtering the global mount_list. */ static void -filter_mount_list (void) +filter_mount_list (bool devices_only) { struct mount_entry *me; - /* Store of already-processed device numbers. */ - struct devlist *devlist_head = NULL; - - /* Sort all 'wanted' entries into the list devlist_head. */ + /* Sort all 'wanted' entries into the list device_list. */ for (me = mount_list; me;) { struct stat buf; struct devlist *devlist; struct mount_entry *discard_me = NULL; + /* TODO: On Linux we might avoid this stat() and another in get_dev() + by using the device IDs available from /proc/self/mountinfo. + read_file_system_list() could populate me_dev from those + for efficiency and accuracy. */ if (-1 == stat (me->me_mountdir, &buf)) { /* Stat failed - add ME to be able to complain about it later. */ @@ -632,7 +634,7 @@ filter_mount_list (void) else { /* If we've already seen this device... */ - for (devlist = devlist_head; devlist; devlist = devlist->next) + for (devlist = device_list; devlist; devlist = devlist->next) if (devlist->dev_num == buf.st_dev) break; @@ -661,8 +663,9 @@ filter_mount_list (void) if (discard_me) { - me = me->me_next; - free_mount_entry (discard_me); + me = me->me_next; + if (! devices_only) + free_mount_entry (discard_me); } else { @@ -670,26 +673,46 @@ filter_mount_list (void) devlist = xmalloc (sizeof *devlist); devlist->me = me; devlist->dev_num = buf.st_dev; - devlist->next = devlist_head; - devlist_head = devlist; + devlist->next = device_list; + device_list = devlist; me = me->me_next; } } /* Finally rebuild the mount_list from the devlist. */ - mount_list = NULL; - while (devlist_head) + if (! devices_only) { + mount_list = NULL; + while (device_list) + { + /* Add the mount entry. */ + me = device_list->me; + me->me_next = mount_list; + mount_list = me; + /* Free devlist entry and advance. */ + struct devlist *devlist = device_list->next; + free (device_list); + device_list = devlist; + } + } +} + +/* Search a mount entry list for device id DEV. + Return the corresponding device name if found or NULL if not. */ + +static char const * _GL_ATTRIBUTE_PURE +devname_for_dev (dev_t dev) +{ + struct devlist *dl = device_list; + + while (dl) { - /* Add the mount entry. */ - me = devlist_head->me; - me->me_next = mount_list; - mount_list = me; - /* Free devlist entry and advance. */ - struct devlist *devlist = devlist_head->next; - free (devlist_head); - devlist_head = devlist; + if (dl->dev_num == dev) + return dl->me->me_devname; + dl = dl->next; } + + return NULL; } /* Return true if N is a known integer value. On many file systems, @@ -878,9 +901,40 @@ get_dev (char const *disk, char const *mount_point, char const* file, fsu = *force_fsu; else if (get_fs_usage (stat_file, disk, &fsu)) { - error (0, errno, "%s", quote (stat_file)); - exit_status = EXIT_FAILURE; - return; + /* If we can't access a system provided entry due + to it not being present (now), or due to permissions, + just output placeholder values rather than failing. */ + if (process_all && (errno == EACCES || errno == ENOENT)) + { + if (! show_all_fs) + return; + + fstype = "-"; + fsu.fsu_blocksize = fsu.fsu_blocks = fsu.fsu_bfree = + fsu.fsu_bavail = fsu.fsu_files = fsu.fsu_ffree = UINTMAX_MAX; + } + else + { + error (0, errno, "%s", quote (stat_file)); + exit_status = EXIT_FAILURE; + return; + } + } + else if (process_all && show_all_fs) + { + /* Ensure we don't output incorrect stats for over-mounted directories. + Discard stats when the device name doesn't match. */ + struct stat sb; + if (stat (stat_file, &sb) == 0) + { + char const * devname = devname_for_dev (sb.st_dev); + if (devname && ! STREQ (devname, disk)) + { + fstype = "-"; + fsu.fsu_blocksize = fsu.fsu_blocks = fsu.fsu_bfree = + fsu.fsu_bavail = fsu.fsu_files = fsu.fsu_ffree = UINTMAX_MAX; + } + } } if (fsu.fsu_blocks == 0 && !show_all_fs && !show_listed_fs) @@ -1230,8 +1284,7 @@ get_all_entries (void) { struct mount_entry *me; - if (!show_all_fs) - filter_mount_list (); + filter_mount_list (show_all_fs); for (me = mount_list; me; me = me->me_next) get_dev (me->me_devname, me->me_mountdir, NULL, NULL, me->me_type, diff --git a/tests/df/skip-duplicates.sh b/tests/df/skip-duplicates.sh index a620e73..9f0f749 100755 --- a/tests/df/skip-duplicates.sh +++ b/tests/df/skip-duplicates.sh @@ -96,8 +96,8 @@ test -f x || skip_ "internal test failure: maybe LD_PRELOAD doesn't work?" LD_PRELOAD=./k.so df -T >out || fail=1 test $(wc -l out && fail=1 +# Ensure we don't fail when unable to stat (currently) unavailable entries +LD_PRELOAD=./k.so CU_TEST_DUPE_INVALID=1 df -T >out || fail=1 test $(wc -l out || fail=1 test $(wc -l From cc15c083795d3e97e3693a4f11ae745940cc045b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C3=A1draig=20Brady?= Date: Wed, 18 Jun 2014 13:10:17 +0100 Subject: [PATCH 2/2] df: look for accessible mount points for specified devices * src/df.c (get_disk): Include in the mount entry selection criteria, whether we can access the mount directory. This handles the case where a device is (bind) mounted multiple times with the shortest mount path not being accessible, while some of the other mount points are. Discussed at: http://bugs.gnu.org/16539#63 --- src/df.c | 24 ++++++++++++++++++------ 1 files changed, 18 insertions(+), 6 deletions(-) diff --git a/src/df.c b/src/df.c index d6d4b0e..dc6544b 100644 --- a/src/df.c +++ b/src/df.c @@ -1121,6 +1121,7 @@ get_disk (char const *disk) { struct mount_entry const *me; struct mount_entry const *best_match = NULL; + bool best_match_accessible = false; char const *file = disk; char *resolved = canonicalize_file_name (disk); @@ -1139,13 +1140,24 @@ get_disk (char const *disk) if (STREQ (disk, devname)) { size_t len = strlen (me->me_mountdir); - if (len < best_match_len) + + if (! best_match_accessible || len < best_match_len) { - best_match = me; - if (len == 1) /* Traditional root. */ - break; - else - best_match_len = len; + struct stat disk_stats; + bool this_match_accessible = false; + + if (stat (me->me_mountdir, &disk_stats) == 0) + best_match_accessible = this_match_accessible = true; + + if (this_match_accessible + || (! best_match_accessible && len < best_match_len)) + { + best_match = me; + if (len == 1) /* Traditional root. */ + break; + else + best_match_len = len; + } } } -- 1.7.7.6 --------------090406090509090007060108-- From debbugs-submit-bounces@debbugs.gnu.org Thu Jun 19 20:23:22 2014 Received: (at 16539) by debbugs.gnu.org; 20 Jun 2014 00:23:22 +0000 Received: from localhost ([127.0.0.1]:53577 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Wxmbx-0008F3-SS for submit@debbugs.gnu.org; Thu, 19 Jun 2014 20:23:22 -0400 Received: from mout.kundenserver.de ([212.227.126.130]:54032) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Wxmbv-0008Eo-9Y for 16539@debbugs.gnu.org; Thu, 19 Jun 2014 20:23:20 -0400 Received: from [192.168.1.10] (p548E4BA4.dip0.t-ipconnect.de [84.142.75.164]) by mrelayeu.kundenserver.de (node=mreue006) with ESMTP (Nemesis) id 0MgUmQ-1XKEsA38Hm-00NkRn; Fri, 20 Jun 2014 02:23:12 +0200 Message-ID: <53A37EF0.6040701@bernhard-voelker.de> Date: Fri, 20 Jun 2014 02:23:12 +0200 From: Bernhard Voelker User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.5.0 MIME-Version: 1.0 To: =?UTF-8?B?UMOhZHJhaWcgQnJhZHk=?= Subject: Re: bug#16539: More details on df command output for you References: <67f0ced2351b31a6ac4523659f306b25@msmail.compro.net> <3ce9319232fc3427c2ecefb1d68df226@msmail.compro.net> <52E2E8BF.1000700@bernhard-voelker.de> <52E32D5D.2030900@draigBrady.com> <52E44EE4.9020503@bernhard-voelker.de> <52E4F174.9040602@draigBrady.com> <52E59BDE.9020206@bernhard-voelker.de> <52E5B108.5080304@draigBrady.com> <5370E47F.3030401@draigBrady.com> <53729A98.2020502@bernhard-voelker.de> <53A066DB.308@draigBrady.com> <53A0E908.7080905@bernhard-voelker.de> <53A18194.8050900@draigBrady.com> <53A1CAAE.9070704@draigBrady.com> In-Reply-To: <53A1CAAE.9070704@draigBrady.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Provags-ID: V02:K0:wzeMdanz85hHbEQ4vuB77bW/83m6/dlVJPoejczZLAh m+xG7Qy/L2MJEmNEVOWEZ8qqQc3vZ11zanK3tG+QNj0pHxg8QT 0LLHEaMMX2EqM+ryM9cqm4yZL+pmTuXg5h9XJAl1YjVaVXAulh gZr7PHh80jc5CMqWFUFBZD99G4vzU2m55WYM3GPvDKxuJnUeVr CuiDsF4iuLaL1BpR1qDMgB5lQNFF3vmlFy0qZ9vFqIAmCUa2Pu cqQFxi0HB45ztZJjLGSRrzFyCzL0JtVLGewZpf0Aryo6tvjFgC PX4gb7YIThi4BkYXZzGVU1fOsPbFzs4va/GN6bW2NOuvEo6fB+ v3nXKaO+EVCbt2zxoqj6w2WKjuDkUWCSUMELKNaKB X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 16539 Cc: 16539@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 0.0 (/) On 06/18/2014 07:21 PM, Pádraig Brady wrote: > The attached 2 patches on top of current master, > should address your suggested tweaks and above ordering issue. Thanks. Both patches look good. The whole story is already rather long, so I almost don't dare to come up with it ... but there is one last issue left with eclipsed file systems: $ mount /dev/sda5 /mnt $ src/df /mnt Filesystem 1K-blocks Used Available Use% Mounted on /dev/sda5 206424760 440500 195482116 1% /mnt $ mount -o loop tmp.img /mnt $ src/df /mnt # correct: search by mount point Filesystem 1K-blocks Used Available Use% Mounted on /dev/loop0 59365 1308 53471 3% /mnt $ src/df /dev/sda5 # wrong: search by device Filesystem 1K-blocks Used Available Use% Mounted on /dev/sda5 59365 1308 53471 3% /mnt Have a nice day, Berny From debbugs-submit-bounces@debbugs.gnu.org Tue Jun 24 12:36:20 2014 Received: (at 16539) by debbugs.gnu.org; 24 Jun 2014 16:36:21 +0000 Received: from localhost ([127.0.0.1]:59503 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1WzThk-0005bm-1W for submit@debbugs.gnu.org; Tue, 24 Jun 2014 12:36:20 -0400 Received: from mail6.vodafone.ie ([213.233.128.184]:17974) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1WzThg-0005bQ-VT for 16539@debbugs.gnu.org; Tue, 24 Jun 2014 12:36:18 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AscCAMqnqVNtTXbI/2dsb2JhbAANQgqDX1OCdIVbuzgBgR2EeAEBAQQjBFIQCw0BAwMBAgEJIQICDwI+CAYNAQUCAQEFEYgtA6t0d54WF44gSxEHCYJugUwFj3SCFIFBiE6FYYY9iUo Received: from unknown (HELO [192.168.1.79]) ([109.77.118.200]) by mail3.vodafone.ie with ESMTP; 24 Jun 2014 17:36:08 +0100 Message-ID: <53A9A8F8.20400@draigBrady.com> Date: Tue, 24 Jun 2014 17:36:08 +0100 From: =?UTF-8?B?UMOhZHJhaWcgQnJhZHk=?= User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130110 Thunderbird/17.0.2 MIME-Version: 1.0 To: Bernhard Voelker Subject: Re: bug#16539: More details on df command output for you References: <67f0ced2351b31a6ac4523659f306b25@msmail.compro.net> <3ce9319232fc3427c2ecefb1d68df226@msmail.compro.net> <52E2E8BF.1000700@bernhard-voelker.de> <52E32D5D.2030900@draigBrady.com> <52E44EE4.9020503@bernhard-voelker.de> <52E4F174.9040602@draigBrady.com> <52E59BDE.9020206@bernhard-voelker.de> <52E5B108.5080304@draigBrady.com> <5370E47F.3030401@draigBrady.com> <53729A98.2020502@bernhard-voelker.de> <53A066DB.308@draigBrady.com> <53A0E908.7080905@bernhard-voelker.de> <53A18194.8050900@draigBrady.com> <53A1CAAE.9070704@draigBrady.com> <53A37EF0.6040701@bernhard-voelker.de> In-Reply-To: <53A37EF0.6040701@bernhard-voelker.de> X-Enigmail-Version: 1.6 Content-Type: multipart/mixed; boundary="------------080603000606020908020601" X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 16539 Cc: 16539@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 0.0 (/) This is a multi-part message in MIME format. --------------080603000606020908020601 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit On 06/20/2014 01:23 AM, Bernhard Voelker wrote: > On 06/18/2014 07:21 PM, Pádraig Brady wrote: >> The attached 2 patches on top of current master, >> should address your suggested tweaks and above ordering issue. > > Thanks. Both patches look good. > > The whole story is already rather long, so I almost don't dare > to come up with it ... but there is one last issue left with > eclipsed file systems: > > $ mount /dev/sda5 /mnt > > $ src/df /mnt > Filesystem 1K-blocks Used Available Use% Mounted on > /dev/sda5 206424760 440500 195482116 1% /mnt > > $ mount -o loop tmp.img /mnt > > $ src/df /mnt # correct: search by mount point > Filesystem 1K-blocks Used Available Use% Mounted on > /dev/loop0 59365 1308 53471 3% /mnt > > $ src/df /dev/sda5 # wrong: search by device > Filesystem 1K-blocks Used Available Use% Mounted on > /dev/sda5 59365 1308 53471 3% /mnt Fingers crossed this is the last df issue. df is getting quite messy and could do with a refactoring to use prepopulate hashes from /proc/self/mountinfo, but not for this iteration at least. Proposed test attached. thanks, Pádraig. --------------080603000606020908020601 Content-Type: text/x-patch; name="df-dev-eclipse.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="df-dev-eclipse.patch" >From 47c314a266042fd52890019fe3a7f0b5403c7e26 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C3=A1draig=20Brady?= Date: Tue, 24 Jun 2014 15:34:39 +0100 Subject: [PATCH] df: report correct device in presence of eclipsed mounts * src/df.c (last_device_for_mount): A new function to identify the last device mounted for a mount point. (get_disk): Use the above to discard mount entries for a device, where a later mount entry uses a different device name than that of the user specified device. * tests/df/over-mount-device.sh: A new root test. * tests/local.mk: Reference the new test. * NEWS: Reword for all these related recent fixes. Discussed at: http://bugs.gnu.org/16539#69 --- NEWS | 9 +++--- src/df.c | 42 +++++++++++++++++++++++++++++- tests/df/over-mount-device.sh | 57 +++++++++++++++++++++++++++++++++++++++++ tests/local.mk | 1 + 4 files changed, 104 insertions(+), 5 deletions(-) create mode 100755 tests/df/over-mount-device.sh diff --git a/NEWS b/NEWS index 15846b0..f4204cb 100644 --- a/NEWS +++ b/NEWS @@ -44,10 +44,11 @@ GNU coreutils NEWS -*- outline -*- [These dd bugs were present in "the beginning".] - df now elides duplicates for virtual file systems like tmpfs. - Displays the correct device details for points mounted multiple times. - Displays placeholder values for inaccessible file systems, - rather than error messages or values for the wrong file system. + df has more fixes related to the newer dynamic representation of file systems: + Duplicates are elided for virtual file systems like tmpfs. + Details for the correct device are output for points mounted multiple times. + Placeholder values are output for inaccessible file systems, rather than + than error messages or values for the wrong file system. [These bugs were present in "the beginning".] head --bytes=-N and --lines=-N now handles devices more diff --git a/src/df.c b/src/df.c index dc6544b..25a6df5 100644 --- a/src/df.c +++ b/src/df.c @@ -1114,6 +1114,33 @@ get_dev (char const *disk, char const *mount_point, char const* file, free (dev_name); } +/* Scan the mount list returning the _last_ device found for MOUNT. + NULL is returned if MOUNT not found. The result is malloced. */ +static char * +last_device_for_mount (char const* mount) +{ + struct mount_entry const *me; + struct mount_entry const *le = NULL; + + for (me = mount_list; me; me = me->me_next) + { + if (STREQ (me->me_mountdir, mount)) + le = me; + } + + if (le) + { + char *devname = le->me_devname; + char *canon_dev = canonicalize_file_name (devname); + if (canon_dev && IS_ABSOLUTE_FILE_NAME (canon_dev)) + return canon_dev; + free (canon_dev); + return xstrdup (le->me_devname); + } + else + return NULL; +} + /* If DISK corresponds to a mount point, show its usage and return true. Otherwise, return false. */ static bool @@ -1122,6 +1149,7 @@ get_disk (char const *disk) struct mount_entry const *me; struct mount_entry const *best_match = NULL; bool best_match_accessible = false; + bool eclipsed_device = false; char const *file = disk; char *resolved = canonicalize_file_name (disk); @@ -1139,9 +1167,12 @@ get_disk (char const *disk) if (STREQ (disk, devname)) { + char *last_device = last_device_for_mount (me->me_mountdir); + eclipsed_device = ! STREQ (last_device, devname); size_t len = strlen (me->me_mountdir); - if (! best_match_accessible || len < best_match_len) + if (! eclipsed_device + && (! best_match_accessible || len < best_match_len)) { struct stat disk_stats; bool this_match_accessible = false; @@ -1159,6 +1190,8 @@ get_disk (char const *disk) best_match_len = len; } } + + free (last_device); } free (canon_dev); @@ -1173,6 +1206,13 @@ get_disk (char const *disk) best_match->me_remote, NULL, false); return true; } + else if (eclipsed_device) + { + error (0, 0, _("cannot access %s: over-mounted by another device"), + quote (file)); + exit_status = EXIT_FAILURE; + return true; + } return false; } diff --git a/tests/df/over-mount-device.sh b/tests/df/over-mount-device.sh new file mode 100755 index 0000000..a85ce8d --- /dev/null +++ b/tests/df/over-mount-device.sh @@ -0,0 +1,57 @@ +#!/bin/sh +# Ensure that df /dev/loop0 errors out if overmounted by another device + +# Copyright (C) 2014 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src +print_ver_ df +require_root_ + +cwd=$(pwd) +cleanup_() { cd /; umount "$cwd/mnt"; umount "$cwd/mnt"; } + +skip=0 + +# Create 2 file systems +for i in 1 2; do + dd if=/dev/zero of=blob$i bs=8192 count=200 > /dev/null 2>&1 \ + || skip=1 + mkfs -t ext2 -F blob$i \ + || skip_ "failed to create ext2 file system" +done + +# Mount both at the same place (eclipsing the first) +mkdir mnt || skip=1 +mount -oloop blob1 mnt || skip=1 +eclipsed_dev=$(df --o=source mnt | tail -n1) || skip=1 +mount -oloop blob2 mnt || skip=1 + +test $skip = 1 \ + && skip_ "insufficient mount/ext2 support" + +df . || skip_ "failed to lookup the device for the current dir" + +echo "df: cannot access '$eclipsed_dev': over-mounted by another device" > exp + +# We should get an error for the eclipsed device and continue +df $eclipsed_dev . > out 2> err && fail=1 + +# header and single entry in output +test $(wc -l < out) = 2 || fail=1 + +compare exp err || fail=1 + +Exit $fail diff --git a/tests/local.mk b/tests/local.mk index cd7da5b..86050dc 100644 --- a/tests/local.mk +++ b/tests/local.mk @@ -115,6 +115,7 @@ all_root_tests = \ tests/cp/sparse-fiemap.sh \ tests/dd/skip-seek-past-dev.sh \ tests/df/problematic-chars.sh \ + tests/df/over-mount-device.sh \ tests/du/bind-mount-dir-cycle.sh \ tests/id/setgid.sh \ tests/install/install-C-root.sh \ -- 1.7.7.6 --------------080603000606020908020601-- From debbugs-submit-bounces@debbugs.gnu.org Wed Jun 25 04:39:54 2014 Received: (at 16539) by debbugs.gnu.org; 25 Jun 2014 08:39:54 +0000 Received: from localhost ([127.0.0.1]:59933 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1WzikD-0000iI-VS for submit@debbugs.gnu.org; Wed, 25 Jun 2014 04:39:54 -0400 Received: from mout.kundenserver.de ([212.227.126.131]:49831) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1WzikB-0000hw-G1 for 16539@debbugs.gnu.org; Wed, 25 Jun 2014 04:39:52 -0400 Received: from [10.0.4.15] (gw.camline.com [62.153.148.194]) by mrelayeu.kundenserver.de (node=mreue006) with ESMTP (Nemesis) id 0MYpHi-1XCUJ11FY2-00VTvg; Wed, 25 Jun 2014 10:39:45 +0200 Message-ID: <53AA89D0.1070406@bernhard-voelker.de> Date: Wed, 25 Jun 2014 10:35:28 +0200 From: Bernhard Voelker User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.5.0 MIME-Version: 1.0 To: =?UTF-8?B?UMOhZHJhaWcgQnJhZHk=?= Subject: Re: bug#16539: More details on df command output for you References: <67f0ced2351b31a6ac4523659f306b25@msmail.compro.net> <3ce9319232fc3427c2ecefb1d68df226@msmail.compro.net> <52E2E8BF.1000700@bernhard-voelker.de> <52E32D5D.2030900@draigBrady.com> <52E44EE4.9020503@bernhard-voelker.de> <52E4F174.9040602@draigBrady.com> <52E59BDE.9020206@bernhard-voelker.de> <52E5B108.5080304@draigBrady.com> <5370E47F.3030401@draigBrady.com> <53729A98.2020502@bernhard-voelker.de> <53A066DB.308@draigBrady.com> <53A0E908.7080905@bernhard-voelker.de> <53A18194.8050900@draigBrady.com> <53A1CAAE.9070704@draigBrady.com> <53A37EF0.6040701@bernhard-voelker.de> <53A9A8F8.20400@draigBrady.com> In-Reply-To: <53A9A8F8.20400@draigBrady.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Provags-ID: V02:K0:uMNtdoVVo8z3yzwzVdoutbRCnWVbb7FbjtAvL5/mfaK 5GDSqP9hAPPScQ/Gg0TscnUxIQioiYNOa0i0LW064fQRv+6kuR IL+mZmDwurgpzH3suheKB1dc6ADfJFM4be7+L1xf7Az6VvWt4e 8ivuR31BegkjD22jRKJcmwWpmsplj9ZuzSVEh2fwkQATJNBrUs /A8oM40fpFhbmveFb7QEvz1G/PqHDXxuy8FBfFHqYslX/xtiC+ OcEI/Z0sCfT8/5JuAgOU/wc6JVCu+b4LTUUiHiA9A7oMhP0L5r L4iXqe529q2WbbzVS/LpZydiKKkX0FJeAzPdqEW+F9gJheullh g2EWSjgM8s8a/A/whzlhl45TAZPPJdUpZHEEfgREO X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 16539 Cc: 16539@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 0.0 (/) On 06/24/2014 06:36 PM, Pádraig Brady wrote: > Fingers crossed this is the last df issue. +1 > df is getting quite messy and could do with a refactoring > to use prepopulate hashes from /proc/self/mountinfo, > but not for this iteration at least. Good idea. Maybe we should wait for user feedback (with yet other strange test cases) anyway. The patch looks perfect, thanks! Have a nice day, Berny From debbugs-submit-bounces@debbugs.gnu.org Wed Jun 25 04:54:35 2014 Received: (at 16539) by debbugs.gnu.org; 25 Jun 2014 08:54:35 +0000 Received: from localhost ([127.0.0.1]:59937 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1WziyM-00018n-BR for submit@debbugs.gnu.org; Wed, 25 Jun 2014 04:54:35 -0400 Received: from mail6.vodafone.ie ([213.233.128.184]:30973) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1WziyF-00018O-1L for 16539@debbugs.gnu.org; Wed, 25 Jun 2014 04:54:28 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: ApQBAMGMqlNtT2RN/2dsb2JhbAANTYcmvUSDFQGBJYR4AQEBBCMECwFGEAsNAQoCAgUhAgIPAkYGDQEHAQGIQ6kxd54kF4EqjVIHgneBTAEEoXiQBw Received: from unknown (HELO [192.168.1.79]) ([109.79.100.77]) by mail3.vodafone.ie with ESMTP; 25 Jun 2014 09:54:16 +0100 Message-ID: <53AA8E37.102@draigBrady.com> Date: Wed, 25 Jun 2014 09:54:15 +0100 From: =?UTF-8?B?UMOhZHJhaWcgQnJhZHk=?= User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130110 Thunderbird/17.0.2 MIME-Version: 1.0 To: Bernhard Voelker Subject: Re: bug#16539: More details on df command output for you References: <67f0ced2351b31a6ac4523659f306b25@msmail.compro.net> <3ce9319232fc3427c2ecefb1d68df226@msmail.compro.net> <52E2E8BF.1000700@bernhard-voelker.de> <52E32D5D.2030900@draigBrady.com> <52E44EE4.9020503@bernhard-voelker.de> <52E4F174.9040602@draigBrady.com> <52E59BDE.9020206@bernhard-voelker.de> <52E5B108.5080304@draigBrady.com> <5370E47F.3030401@draigBrady.com> <53729A98.2020502@bernhard-voelker.de> <53A066DB.308@draigBrady.com> <53A0E908.7080905@bernhard-voelker.de> <53A18194.8050900@draigBrady.com> <53A1CAAE.9070704@draigBrady.com> <53A37EF0.6040701@bernhard-voelker.de> <53A9A8F8.20400@draigBrady.com> <53AA89D0.1070406@bernhard-voelker.de> In-Reply-To: <53AA89D0.1070406@bernhard-voelker.de> X-Enigmail-Version: 1.6 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 16539 Cc: 16539@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 0.0 (/) On 06/25/2014 09:35 AM, Bernhard Voelker wrote: > On 06/24/2014 06:36 PM, Pádraig Brady wrote: >> Fingers crossed this is the last df issue. > > +1 > >> df is getting quite messy and could do with a refactoring >> to use prepopulate hashes from /proc/self/mountinfo, >> but not for this iteration at least. > > Good idea. Maybe we should wait for user feedback (with yet > other strange test cases) anyway. > > The patch looks perfect, thanks! I submitted a slightly stale patch to the list. The one I'll push now has this change. diff --git a/src/df.c b/src/df.c index 25a6df5..063cabf 100644 --- a/src/df.c +++ b/src/df.c @@ -1168,7 +1168,7 @@ get_disk (char const *disk) if (STREQ (disk, devname)) { char *last_device = last_device_for_mount (me->me_mountdir); - eclipsed_device = ! STREQ (last_device, devname); + eclipsed_device = last_device && ! STREQ (last_device, devname); size_t len = strlen (me->me_mountdir); if (! eclipsed_device thanks, Pádraig. From debbugs-submit-bounces@debbugs.gnu.org Wed Jun 25 05:15:27 2014 Received: (at 16539) by debbugs.gnu.org; 25 Jun 2014 09:15:27 +0000 Received: from localhost ([127.0.0.1]:59943 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1WzjIc-0001k3-6U for submit@debbugs.gnu.org; Wed, 25 Jun 2014 05:15:26 -0400 Received: from mout.kundenserver.de ([212.227.126.187]:59295) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1WzjIZ-0001jk-NX for 16539@debbugs.gnu.org; Wed, 25 Jun 2014 05:15:24 -0400 Received: from [10.0.4.15] (gw.camline.com [62.153.148.194]) by mrelayeu.kundenserver.de (node=mreue005) with ESMTP (Nemesis) id 0LhifF-1WMHo22HdB-00ms0W; Wed, 25 Jun 2014 11:15:15 +0200 Message-ID: <53AA9224.30502@bernhard-voelker.de> Date: Wed, 25 Jun 2014 11:11:00 +0200 From: Bernhard Voelker User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.5.0 MIME-Version: 1.0 To: =?UTF-8?B?UMOhZHJhaWcgQnJhZHk=?= Subject: Re: bug#16539: More details on df command output for you References: <67f0ced2351b31a6ac4523659f306b25@msmail.compro.net> <3ce9319232fc3427c2ecefb1d68df226@msmail.compro.net> <52E2E8BF.1000700@bernhard-voelker.de> <52E32D5D.2030900@draigBrady.com> <52E44EE4.9020503@bernhard-voelker.de> <52E4F174.9040602@draigBrady.com> <52E59BDE.9020206@bernhard-voelker.de> <52E5B108.5080304@draigBrady.com> <5370E47F.3030401@draigBrady.com> <53729A98.2020502@bernhard-voelker.de> <53A066DB.308@draigBrady.com> <53A0E908.7080905@bernhard-voelker.de> <53A18194.8050900@draigBrady.com> <53A1CAAE.9070704@draigBrady.com> <53A37EF0.6040701@bernhard-voelker.de> <53A9A8F8.20400@draigBrady.com> <53AA89D0.1070406@bernhard-voelker.de> <53AA8E37.102@draigBrady.com> In-Reply-To: <53AA8E37.102@draigBrady.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Provags-ID: V02:K0:inNjxlsw7h7d2iGhiU6m7QrXX3epzl3nPPHo+67dMJb uuVh8AkfhiFWZMmkM0PnkCgRcFdVs31nJNBNS/hmDJwyd6XLwi /2nvRlbTdtniZXEJYweAZrGs6JDbmVNe4KJfzmm0x8Spv+YDLY O1UWRGNbVtaLgPMnwty3Ot4RUClD41adYL6+ytQrDWvsyux1+h udwCxeYJbv1+94Sgbc3FN+yeSDvuh/VKdmAPhdgfDExMnm4I84 zWHnCZRSpoPo+Ow7Qjs0QRLLe8QgrJNc+YsLtTeX5BAs59jhAz bpGwqrvdMtCeaAXGmDNre80zcdldnbzhB5LsMRacyBA6ykSkIp XFV3ssITo5WaQIrITh7ghN497D/LUtRzQUbihITol X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 16539 Cc: 16539@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 0.0 (/) On 06/25/2014 10:54 AM, Pádraig Brady wrote: > I submitted a slightly stale patch to the list. > The one I'll push now has this change. > > diff --git a/src/df.c b/src/df.c > index 25a6df5..063cabf 100644 > --- a/src/df.c > +++ b/src/df.c > @@ -1168,7 +1168,7 @@ get_disk (char const *disk) > if (STREQ (disk, devname)) > { > char *last_device = last_device_for_mount (me->me_mountdir); > - eclipsed_device = ! STREQ (last_device, devname); > + eclipsed_device = last_device && ! STREQ (last_device, devname); > size_t len = strlen (me->me_mountdir); > > if (! eclipsed_device oops, correct. Thanks & have a nice day, Berny From unknown Thu Jun 19 12:19:43 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Wed, 23 Jul 2014 11:24:04 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator