Imagine a situation where:
# ls -ld /mnt/{foo,bar} drwxr-xr-x 3 root wheel 512 Mar 16 06:56 /mnt/bar lrwxr-xr-x 1 root wheel 3 Mar 16 12:10 /mnt/foo -> bar # grep /mnt/foo /etc/fstab /dev/da1 /mnt/foo ufs rw 0 0 Which means, we give symbolic link as a mount point to mount(8), but mount(8) use realpath(3) before mounting the file systems, so we get: # mount | grep /dev/da1 /dev/da1 on /mnt/bar (ufs, local) Before the commit: # snapinfo /mnt/foo usage: snapinfo [-v] -a snapinfo [-v] mountpoint # snapinfo /mnt/bar /mnt/bar/snap This commit makes snapinfo(8) to first realpath(3) the given mount point and now we have: # snapinfo /mnt/foo /mnt/bar/snap # snapinfo /mnt/bar /mnt/bar/snap
This commit is contained in:
parent
996c735fb5
commit
bb1f6478b9
@ -81,13 +81,20 @@ main(int argc, char **argv)
|
||||
usage();
|
||||
|
||||
if (!all) {
|
||||
path = *argv;
|
||||
char resolved[PATH_MAX];
|
||||
|
||||
if (strrchr(path, '/') == NULL || /* is absolute path */
|
||||
(stat(path, &st) == -1) || /* is it stat'able */
|
||||
!(st.st_mode & S_IFDIR)) /* is it a directory */
|
||||
path = *argv;
|
||||
/*
|
||||
* mount(8) use realpath(3) before mounting file system,
|
||||
* so let's do the same with the given path.
|
||||
*/
|
||||
if (realpath(path, resolved) == NULL || /* can create full path */
|
||||
stat(resolved, &st) == -1 || /* is it stat'able */
|
||||
!S_ISDIR(st.st_mode)) { /* is it a directory */
|
||||
usage();
|
||||
}
|
||||
path = resolved;
|
||||
}
|
||||
|
||||
fscount = getmntinfo(&mntbuf, MNT_WAIT);
|
||||
for (n = 0; n < fscount; n++) {
|
||||
|
Loading…
Reference in New Issue
Block a user