coreutils
[Top][All Lists]
Advanced

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

Re: Add --dereference option to df


From: Pádraig Brady
Subject: Re: Add --dereference option to df
Date: Tue, 03 Dec 2013 15:58:35 +0000
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130110 Thunderbird/17.0.2

On 12/03/2013 03:35 PM, Bernhard Voelker wrote:
> On 12/03/2013 03:35 PM, Pádraig Brady wrote:
>> On 11/22/2013 01:52 AM, Pádraig Brady wrote:
>>> On 11/12/2013 07:45 AM, Bernhard Voelker wrote:
>>>> Isn't that what the findmnt(8) command achieves with
>>>> the -S,--source option, i.e. it's not only about dereferencing
>>>> per se but rather telling the tool that we're searching for
>>>> the source of a mount instead of the target?
>>>>
>>>> Therefore, I think making the changes in get_point() is abusing the
>>>> semantics of that function.  Instead, get_disk() should be enhanced
>>>> in a similar way as in get_point() via canonicalize_file_name().
>>>
>>> Makes sense.
>>>
>>>> Another question is if such behavior could/should be made the default
>>>> or if a new option has to be introduced.
>>>
>>> I'd make it default to dereference. No new options needed I think.
>>
>> This would be appropriate for the imminent release I think.
>> I'll have a look later if you've no time.
> 
> That would have been the next item I planned to work on, but if you're
> in a hurry for the snapshot release, then I'm also fine if you do it.
> So the question is: when would you like to do the release?

OK cool.
I hope to release a snapshot later on this evening,
and will include something like the following
after testing/thinking a bit about it.

thanks,
Pádraig.

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;
+
+  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;




reply via email to

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