summaryrefslogtreecommitdiffstats
path: root/sbin/mount
diff options
context:
space:
mode:
authorpjd <pjd@FreeBSD.org>2006-01-18 11:00:34 +0000
committerpjd <pjd@FreeBSD.org>2006-01-18 11:00:34 +0000
commit4f41f4bf9d6fe6cd1d586600a43d988edd5c6def (patch)
tree1799d97f97f90ceeb42525a4ef96a72a1effee4a /sbin/mount
parent3b2388f51bbda41bef5331055e5c3ab3d974722c (diff)
downloadFreeBSD-src-4f41f4bf9d6fe6cd1d586600a43d988edd5c6def.zip
FreeBSD-src-4f41f4bf9d6fe6cd1d586600a43d988edd5c6def.tar.gz
Resolve the mount point's path with realpath(2) before checking if file
system is mounted. This prevevents duplicated mounts. The change I made against the original patch is to fall back to the given path on realpath(2) failure instead of exiting with an error. Submitted by: Andreas Kohn <andreas@syndrom23.de> PR: bin/89782 MFC after: 3 days
Diffstat (limited to 'sbin/mount')
-rw-r--r--sbin/mount/mount.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/sbin/mount/mount.c b/sbin/mount/mount.c
index eb32616..5f49893 100644
--- a/sbin/mount/mount.c
+++ b/sbin/mount/mount.c
@@ -391,14 +391,21 @@ main(int argc, char *argv[])
int
ismounted(struct fstab *fs, struct statfs *mntbuf, int mntsize)
{
+ char realfsfile[PATH_MAX];
int i;
if (fs->fs_file[0] == '/' && fs->fs_file[1] == '\0')
/* the root file system can always be remounted */
return (0);
+ /* The user may have specified a symlink in fstab, resolve the path */
+ if (realpath(fs->fs_file, realfsfile) == NULL) {
+ /* Cannot resolve the path, use original one */
+ strlcpy(realfsfile, fs->fs_file, sizeof(realfsfile));
+ }
+
for (i = mntsize - 1; i >= 0; --i)
- if (strcmp(fs->fs_file, mntbuf[i].f_mntonname) == 0 &&
+ if (strcmp(realfsfile, mntbuf[i].f_mntonname) == 0 &&
(!isremountable(fs->fs_vfstype) ||
strcmp(fs->fs_spec, mntbuf[i].f_mntfromname) == 0))
return (1);
OpenPOWER on IntegriCloud