coreutils
[Top][All Lists]
Advanced

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

Re: [PATCH] df: avoid stat() for dummy file systems with -l


From: Bernhard Voelker
Subject: Re: [PATCH] df: avoid stat() for dummy file systems with -l
Date: Thu, 3 Aug 2017 16:00:21 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.2.1

On 08/03/2017 02:21 PM, Kamil Dudka wrote:
> @@ -652,10 +670,9 @@ filter_mount_list (bool devices_only)
> 
>    /* Temporary list to keep entries ordered.  */
>    struct devlist *device_list = NULL;
> -  int mount_list_size = 0;
> 
> -  for (me = mount_list; me; me = me->me_next)
> -    mount_list_size++;
> +  /* reverse mount_list to better handle over-mounted file systems */
> +  int mount_list_size = reverse_me_list(&mount_list);
> 
>    devlist_table = hash_initialize (mount_list_size, NULL,
>                                   devlist_hash,
> @@ -768,6 +785,9 @@ filter_mount_list (bool devices_only)
>        hash_free (devlist_table);
>        devlist_table = NULL;
>    }
> +  else
> +    /* reverse mount_list back to preserve the order with --all */
> +    reverse_me_list(&mount_list);
>  }

No, unfortunately that doesn't work as simple as that.

The point is that today's code processes the entries, and if a later one
over-mounts a previous one, then the previous one gets removed in favor
of the later one.  IIRC, this does not work correctly in the following
case - mount points:

/a      # initial mount
/a/b    # mount on a subdirectory
/a/b    # over-mounting the sub-directory
/a      # over-mounting all of the above

AFAIR today's code wouldn't elide the /a/b mounts.
Going backward would ease creating the net list of visible mounts,
because later entries could just be ignored.
After that, the regular filtering of local, excluded, included etc.
mounts could happen in a second loop.

With -a, the over-mounted file systems could/should show up with '-' entries
again.

Thanks & have a nice day,
Berny



reply via email to

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