coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: df: use mountinfo from /proc on Linux


From: Fridolin Pokorny
Subject: Re: df: use mountinfo from /proc on Linux
Date: Tue, 02 Sep 2014 14:43:35 +0200

On Fri, 2014-08-29 at 15:40 +0200, Fridolin Pokorny wrote:
> On Wed, 2014-08-27 at 17:02 +0100, Pádraig Brady wrote:
> > On 08/27/2014 04:13 PM, Fridolin Pokorny wrote:
> > > diff --git a/src/df.c b/src/df.c
> > > index e907b94..156c7c1 100644
> > > --- a/src/df.c
> > > +++ b/src/df.c
> > > @@ -622,11 +622,11 @@ filter_mount_list (bool devices_only)
> > >        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.  */
> > > +#ifdef _linux_
> > > +      if (me->me_dev == (dev_t) -1 && stat (me->me_mountdir, &buf) == -1)
> > > +#else
> > >        if (-1 == stat (me->me_mountdir, &buf))
> > > +#endif
> > 
> > Do we need the ifdef at all?
> > Won't me_dev be -1 or valid?
> 
> I wasn't sure about this; I don't know why testing for me_dev == -1
> wasn't already covered. This forced to call stat() even when me_dev was
> set from dev_from_mount_options() in gnulib on non-Linux systems (or
> specific calls on BeOS/Ultrix). These ifdefs should be removed in my
> opinion.
> 
> If ifdefs will be removed, this patch has nothing to do with mountinfo
> on Linux. It simply lets me_dev to be populated from gnulib, if any, or
> it tries to find some using stat() (which might not be always correct
> in chroot).

Proposing modified patch and a simple test case.

Have a nice day!
Fridolin Pookrny

Attachment: 0001-df-let-me_dev-be-populated-from-gnulib.patch
Description: Text Data

Attachment: 0002-df-add-a-test-for-proc-self-mountinfo-support.patch
Description: Text Data


reply via email to

[Prev in Thread] Current Thread [Next in Thread]