]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commit
libxcmd: make all comparisons using realpath'd paths
authorEric Sandeen <sandeen@sandeen.net>
Wed, 16 Jul 2014 03:53:47 +0000 (13:53 +1000)
committerDave Chinner <david@fromorbit.com>
Wed, 16 Jul 2014 03:53:47 +0000 (13:53 +1000)
commited350fc6c49155ec398866ebef1d59be02636bce
tree04c464bdfaf61becd391002d8272aa0b7650a767
parent6bf4721d47d9755029a7ec944af2832bd115a851
libxcmd: make all comparisons using realpath'd paths

Both mountpoints and devices can be symlinks, so given a path
to look for, and mountpoints/devices from the system, use
realpath() on *everything* before making the comparison to see
if our path is a match.

So, with symlinks for mount points as well as for devices:

# ls -l /dev/mapper/testvg-lvol0
lrwxrwxrwx. 1 root root 7 Jul 11 19:24 /dev/mapper/testvg-lvol0 -> ../dm-3
# ls -l /mnt/scratch2
lrwxrwxrwx. 1 root root 12 Jul 11 19:57 /mnt/scratch2 -> /mnt/scratch

this should all work, and does now:

# xfs_quota -xc "report -h" /mnt/scratch2
User quota on /mnt/scratch (/dev/mapper/testvg-lvol0)
                        Blocks
User ID      Used   Soft   Hard Warn/Grace
---------- ---------------------------------
root            0      0      0  00 [------]

# xfs_quota -xc "report -h" /mnt/scratch
User quota on /mnt/scratch (/dev/mapper/testvg-lvol0)
                        Blocks
User ID      Used   Soft   Hard Warn/Grace
---------- ---------------------------------
root            0      0      0  00 [------]

# xfs_quota -xc "report -h" /dev/dm-3
User quota on /mnt/scratch (/dev/mapper/testvg-lvol0)
                        Blocks
User ID      Used   Soft   Hard Warn/Grace
---------- ---------------------------------
root            0      0      0  00 [------]

# xfs_quota -xc "report -h" /dev/mapper/testvg-lvol0
User quota on /mnt/scratch (/dev/mapper/testvg-lvol0)
                        Blocks
User ID      Used   Soft   Hard Warn/Grace
---------- ---------------------------------
root            0      0      0  00 [------]

The commit:

050a7f1 xfsprogs: handle symlinks etc in fs_table_initialise_mounts()

tried to fix this earlier, but only worked one way;
it compared the argument path in both given and realpath
form to the paths in getmntent, but did not compare to
the realpaths of the getmntent devices.

If we reduce everything, everywhere, to a realpath(), we've
got our best shot at finding the match.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Dave Chinner <david@fromorbit.com>
libxcmd/paths.c