diff options
author | Poul-Henning Kamp <phk@FreeBSD.org> | 1999-10-09 11:54:14 +0000 |
---|---|---|
committer | Poul-Henning Kamp <phk@FreeBSD.org> | 1999-10-09 11:54:14 +0000 |
commit | 73dd3167345391095dd7c75aefa870a5bce92397 (patch) | |
tree | 33cadf04c808cb0644aedaa306f8f3c0987ba3fe /sbin/mount_ifs/getmntopts.c | |
parent | 1d64c295bbdb773ca3d62cdb5a9eec06e12799c8 (diff) | |
download | src-73dd3167345391095dd7c75aefa870a5bce92397.tar.gz src-73dd3167345391095dd7c75aefa870a5bce92397.zip |
mount* fixes from Martin Blapp <mb@imp.ch>:
Made mount more userfriendly (bad slashes are now filtered out)
and we remove in mount_nfs trailing slashes if there are any.
Fixed mount_xxx binarys to resolve with realpath(3)
the mountpoint.
Translate the deprecated nfs-syntax with '@' to ':' .
The ':' syntax has now precedence, but '@' still works.
Notify the user that the '@' syntax should not be used.
PR: 7846
PR: 13692
Submitted by: Martin Blapp <mb@imp.ch>
Reviewed by: phk
Notes
Notes:
svn path=/head/; revision=52055
Diffstat (limited to 'sbin/mount_ifs/getmntopts.c')
-rw-r--r-- | sbin/mount_ifs/getmntopts.c | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/sbin/mount_ifs/getmntopts.c b/sbin/mount_ifs/getmntopts.c index c80c26281fb6..ffc18bfac219 100644 --- a/sbin/mount_ifs/getmntopts.c +++ b/sbin/mount_ifs/getmntopts.c @@ -41,10 +41,13 @@ static const char rcsid[] = #endif /* not lint */ #include <sys/param.h> +#include <sys/stat.h> #include <err.h> +#include <errno.h> #include <stdlib.h> #include <string.h> +#include <sysexits.h> #include "mntopts.h" @@ -106,3 +109,39 @@ getmntopts(options, m0, flagp, altflagp) free(optbuf); } + +void +rmslashes(rrpin, rrpout) + char *rrpin; + char *rrpout; +{ + char *rrpoutstart; + + *rrpout = *rrpin; + for (rrpoutstart = rrpout; *rrpin != '\0'; *rrpout++ = *rrpin++) { + + /* skip all double slashes */ + while (*rrpin == '/' && *(rrpin + 1) == '/') + rrpin++; + } + + /* remove trailing slash if necessary */ + if (rrpout - rrpoutstart > 1 && *(rrpout - 1) == '/') + *(rrpout - 1) = '\0'; + else + *rrpout = '\0'; +} + +void +checkpath(path, resolved) + const char *path; + char *resolved; +{ + struct stat sb; + + if (realpath(path, resolved) != NULL && stat(resolved, &sb) == 0) { + if (!S_ISDIR(sb.st_mode)) + errx(EX_USAGE, "%s: not a directory", resolved); + } else + errx(EX_USAGE, "%s: %s", resolved, strerror(errno)); +} |