diff options
author | dg <dg@FreeBSD.org> | 1995-02-15 14:20:50 +0000 |
---|---|---|
committer | dg <dg@FreeBSD.org> | 1995-02-15 14:20:50 +0000 |
commit | 93e241d4044ac1099148c3462977900775a61e2c (patch) | |
tree | 6fdf82e42c2b1ad27490e4101620a4e1125a5c0d /sbin/mount_ifs | |
parent | 2e334fc7b7f4c9e366c089788d17387b7cc2164a (diff) | |
download | FreeBSD-src-93e241d4044ac1099148c3462977900775a61e2c.zip FreeBSD-src-93e241d4044ac1099148c3462977900775a61e2c.tar.gz |
Verify that the last component of the mount point path exists and is
a directory - allows for better error reporting.
Diffstat (limited to 'sbin/mount_ifs')
-rw-r--r-- | sbin/mount_ifs/mount.c | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/sbin/mount_ifs/mount.c b/sbin/mount_ifs/mount.c index ee05e9d..691c07a 100644 --- a/sbin/mount_ifs/mount.c +++ b/sbin/mount_ifs/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 = ""; |