coreutils
[Top][All Lists]
Advanced

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

Re: Add --dereference option to df


From: Bernhard Voelker
Subject: Re: Add --dereference option to df
Date: Tue, 03 Dec 2013 17:14:43 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.1.0

On 12/03/2013 04:58 PM, Pádraig Brady wrote:
> I hope to release a snapshot later on this evening,
> and will include something like the following
> after testing/thinking a bit about it.

Great, thanks.

> diff --git a/src/df.c b/src/df.c
> index f6ce79d..175e875 100644
> --- a/src/df.c
> +++ b/src/df.c
> @@ -1056,6 +1056,11 @@ get_disk (char const *disk)
>  {
>    struct mount_entry const *me;
>    struct mount_entry const *best_match = NULL;
> +  cchar const *file = disk;

s/cchar/char/

> +
> +  char *resolved = canonicalize_file_name (disk);
> +  if (resolved && resolved[0] == '/')
> +    disk = resolved;
> 
>    for (me = mount_list; me; me = me->me_next)
>      {
> @@ -1063,9 +1068,11 @@ get_disk (char const *disk)
>          best_match = me;
>      }
> 
> +  free (resolved);
> +
>    if (best_match)
>      {
> -      get_dev (best_match->me_devname, best_match->me_mountdir, disk, NULL,
> +      get_dev (best_match->me_devname, best_match->me_mountdir, file, NULL,
>                 best_match->me_type, best_match->me_dummy,
>                 best_match->me_remote, NULL, false);
>        return true;

Looks good, thanks.

And creating a test shouldn't be too hard either.
Something (untested) like this should do:

  disk=$( df --out=source '.' | sed 1d ) \
    || skip_ "cannot determine '.' file system"

  ln -s $disk symlink || framework_failure_

  df --out=source,file,target $disk   > exp || skip_ ...
  df --out=source,file,target symlink > out || fail=1
  compare exp out || fail=1

or easier:



Have a nice day,
Berny




reply via email to

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