From bd6a298cae998c873c8b5d1bf60646476449642e Mon Sep 17 00:00:00 2001 From: Samuel Thibault Date: Mon, 16 May 2011 01:43:07 +0200 Subject: 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'. --- sutils/fstab.c | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) (limited to 'sutils') 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. */ -- cgit v1.2.3