On 05/15/2013 04:39 PM, Pádraig Brady wrote: > On 05/15/2013 03:32 PM, Ondrej Oprala wrote:
>> Let me explain by example from my system: >> >> /dev/sda1 is mounted on /boot >> /dev/disk/by-uuid/37a5c8d4-78ff-408f-8ae8-70555df51f7f is a symlink to >> /dev/sda1 >> >> #in the following example df prints info about the fs where the symlink file >> is. >> $ df /dev/disk/by-uuid/37a5c8d4-78ff-408f-8ae8-70555df51f7f >> Filesystem 1K-blocks Used Available Use% Mounted on >> devtmpfs 1013888 0 1013888 0% /dev >> >> #with -L, information about the symlinked FS is printed. >> $ df -L /dev/disk/by-uuid/37a5c8d4-78ff-408f-8ae8-70555df51f7f >> Filesystem 1K-blocks Used Available Use% Mounted on >> /dev/sda1 1013888 0 1013888 0% /boot >> >> So although the argument is stat-ed(dereferenced) in both cases, different >> parts >> of the information are used to decide what to output if -L is specified >> (which is why >> I find the option name misleading). > > Ah /dev/sda1 (/boot) isn't mounted on my system > (as I don't want that disk spinning up (long story)). > That's why I got the results I presented. > More thinking required... 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(). Another question is if such behavior could/should be made the default or if a new option has to be introduced. POSIX [1] does not explicitly mention symbolic link arguments: [1] http://pubs.opengroup.org/onlinepubs/9699919799/utilities/df.html A pathname of a file within the hierarchy of the desired file system. If a file other than a FIFO, a regular file, a directory, [XSI] [Option Start] or a special file representing the device containing the file system (for example, /dev/dsk/0s1) [Option End] is specified, the results are unspecified. If the file operand names a file other than a special file containing a file system, df shall write the amount of free space in the file system containing the specified file operand. [XSI] [Option Start] Otherwise, df shall write the amount of free space in that file system. [Option End] Well, we could either ask the OpenGroup for clarification. How do other df's behave? Any opinions? Have a nice day, Berny
