diff options
author | David Greenman <dg@FreeBSD.org> | 1995-02-15 14:20:50 +0000 |
---|---|---|
committer | David Greenman <dg@FreeBSD.org> | 1995-02-15 14:20:50 +0000 |
commit | 8a978495e7c0717a3cc6b8c49e445fa403aa9c7f (patch) | |
tree | 6fdf82e42c2b1ad27490e4101620a4e1125a5c0d /sbin/mount/mount.c | |
parent | b019cc8f8e372c033b7c892f4c42d1d5637a03ac (diff) | |
download | src-8a978495e7c0717a3cc6b8c49e445fa403aa9c7f.tar.gz src-8a978495e7c0717a3cc6b8c49e445fa403aa9c7f.zip |
Verify that the last component of the mount point path exists and is
a directory - allows for better error reporting.
Notes
Notes:
svn path=/head/; revision=6441
Diffstat (limited to 'sbin/mount/mount.c')
-rw-r--r-- | sbin/mount/mount.c | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/sbin/mount/mount.c b/sbin/mount/mount.c index ee05e9db3367..691c07a473db 100644 --- a/sbin/mount/mount.c +++ b/sbin/mount/mount.c @@ -44,6 +44,8 @@ static char sccsid[] = "@(#)mount.c 8.19 (Berkeley) 4/19/94"; #include <sys/param.h> #include <sys/mount.h> #include <sys/wait.h> +#include <sys/types.h> +#include <sys/stat.h> #include <err.h> #include <errno.h> @@ -245,6 +247,8 @@ mountfs(vfstype, spec, name, flags, options, mntopts) const char *vfstype, *spec, *name, *options, *mntopts; int flags; { + struct stat sb; + /* List of directories containing mount_xxx subcommands. */ static const char *edirs[] = { _PATH_SBIN, @@ -257,10 +261,16 @@ mountfs(vfstype, spec, name, flags, options, mntopts) int argc, i, status; char *optbuf, execname[MAXPATHLEN + 1], mntpath[MAXPATHLEN]; - if (realpath(name, mntpath) == NULL) { + if ((realpath(name, mntpath) != NULL) && (stat(mntpath, &sb) == NULL)) { + if ((sb.st_mode & S_IFDIR) == 0) { + warnx("%s: Not a directory", mntpath); + return (1); + } + } else { warn("%s", mntpath); return (1); } + if (mntopts == NULL) mntopts = ""; |