[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: bug#10363: df vs. long-named /dev/disk/by-uuid/... file system devic
From: |
Paul Eggert |
Subject: |
Re: bug#10363: df vs. long-named /dev/disk/by-uuid/... file system device names |
Date: |
Thu, 29 Dec 2011 08:53:06 -0800 |
User-agent: |
Mozilla/5.0 (X11; Linux i686; rv:8.0) Gecko/20111124 Thunderbird/8.0 |
On 12/29/11 06:09, Jim Meyering wrote:
> + /* If dev_name is a long-named symlink like
> + /dev/disk/by-uuid/828fc648-9f30-43d8-a0b1-f7196a2edb66 and its
> + canonical name is shorter, use the shorter name. But don't bother
> + checking when DEV_NAME is no longer than e.g., "/dev/sda1" */
> + if (resolve_device_symlink && 9 < orig_len
> + && (resolved_dev = canonicalize_filename_mode (dev_name,
> CAN_EXISTING)))
> + {
> + if (strlen (resolved_dev) < orig_len)
> + {
> + free (dev_name);
> + dev_name = resolved_dev;
> + }
> + else
> + {
> + free (resolved_dev);
> + }
> + }
I have some qualms about that "is shorter" part;
couldn't that lead to confusing results, on systems
where the canonical name is sometimes a bit shorter and sometimes
a bit longer?
Also, that "9 < orig_len" could also cause confusion.
The flag "resolve_device_symlink" suggests that
the name should always be resolved, at any rate.
In short, how a simpler approach, that always resolves
symlinks? Something like this:
/* If dev_name is a symlink use the resolved name.
On recent GNU/Linux systems we often see a symlink from, e.g.,
/dev/disk/by-uuid/828fc648-9f30-43d8-a0b1-f7196a2edb66
tp /dev/sda3 and it's better to output /dev/sda3. */
if (resolve_device_symlink
&& (resolved_dev = canonicalize_filename_mode (dev_name, CAN_EXISTING)))
{
free (dev_name);
dev_name = resolved_dev;
}