]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commit
xfsprogs: handle symlinks etc in fs_table_initialise_mounts()
authorEric Sandeen <sandeen@redhat.com>
Mon, 30 Sep 2013 17:01:19 +0000 (17:01 +0000)
committerRich Johnston <rjohnston@sgi.com>
Thu, 17 Oct 2013 19:49:56 +0000 (14:49 -0500)
commit050a7f1f79314470c18e9d11c28daf75dd959830
treeee6f12432f8a1edcb13c1329433a1109a5de59d4
parentdd297fd6d366f62ca2f579e510e6287699d0bd5d
xfsprogs: handle symlinks etc in fs_table_initialise_mounts()

Commit:

6a23747d xfs_quota: support relative path as `path' arguments

used realpath() on the supplied pathname to handle things like
relative pathnames and pathnames ending in "/" which otherwise
caused the getmntent scanning to fail.

However, this regressed cases where a path in mtab was a symlink;
realpath() resolves this to the target, and so no match is found.

This causes i.e.:

# xfs_quota -x -c report /dev/mapper/testvg-testlv

to fail with:

xfs_quota: cannot setup path for mount /dev/mapper/testvg-testlv: No such device or address

because the scanning looks for /dev/dm-3, but the long symlink
name is what exists in mtab, and no match is found.

Fix this, but keep the intended enhancements, by testing *both* the
user-specified path (which might be relative, or contain a trailing
slash on a mountpoint) and the realpath-resolved path (which turns
a relative mountpoint into a full path, and removes trailing slashes),
to determine whether the user-specified path is an xfs mountpoint or
device.

While we're at it, add a few comments, and go back to the testing
of "path" not "rpath"; whether or not path is passed to the function
is what determines control flow.  If path is specified, and realpath
succeeds, we're guaranteed to have rpath as well, so there is no need
to retest that.  rpath is initialized to NULL, so an unconditional
free(rpath) is safe as well.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Rich Johnston <rjohnston@sgi.com>
libxcmd/paths.c