diff options
author | Samuel Thibault <samuel.thibault@ens-lyon.org> | 2011-05-16 01:43:07 +0200 |
---|---|---|
committer | Samuel Thibault <samuel.thibault@ens-lyon.org> | 2011-05-16 01:47:46 +0200 |
commit | bd6a298cae998c873c8b5d1bf60646476449642e (patch) | |
tree | 5c91ff07b8679270847f132d3d016189f73a4568 | |
parent | c290af8a3203ce9897574b381c4d1fa2977c315d (diff) |
fstab_find: also try to call realpath()
For symlinks and non-absolute paths.
* sutils/fstab.c (fstab_find): Also call `fstab_find_device' and
`fstab_find_mount' on path returned by `realpath'.
-rw-r--r-- | sutils/fstab.c | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/sutils/fstab.c b/sutils/fstab.c index e40572e2..19b03f50 100644 --- a/sutils/fstab.c +++ b/sutils/fstab.c @@ -497,7 +497,29 @@ fstab_find_mount (const struct fstab *fstab, const char *name) inline struct fs * fstab_find (const struct fstab *fstab, const char *name) { - return fstab_find_device (fstab, name) ?: fstab_find_mount (fstab, name); + struct fs *ret; + const char *real_name; + + ret = fstab_find_device (fstab, name); + if (ret) + return ret; + + ret = fstab_find_mount (fstab, name); + if (ret) + return ret; + + real_name = realpath (name, NULL); + + ret = fstab_find_device (fstab, real_name); + if (ret) { + free (real_name); + return ret; + } + + ret = fstab_find_mount (fstab, real_name); + free (real_name); + + return ret; } /* Cons FS onto the beginning of FSTAB's entry list. */ |