summaryrefslogtreecommitdiff
path: root/sbin/umount
diff options
context:
space:
mode:
authorIan Dowse <iedowse@FreeBSD.org>2003-07-18 17:43:13 +0000
committerIan Dowse <iedowse@FreeBSD.org>2003-07-18 17:43:13 +0000
commit38f102c2f691c7cf79bba277257e43e380703ef1 (patch)
tree772d8d08438bc69dc11be45347c350d3f3aa2539 /sbin/umount
parent084fb28576bb4663b5c492641fb6e84c6b0e0f21 (diff)
downloadsrc-test2-38f102c2f691c7cf79bba277257e43e380703ef1.tar.gz
src-test2-38f102c2f691c7cf79bba277257e43e380703ef1.zip
Notes
Diffstat (limited to 'sbin/umount')
-rw-r--r--sbin/umount/umount.820
-rw-r--r--sbin/umount/umount.c46
2 files changed, 50 insertions, 16 deletions
diff --git a/sbin/umount/umount.8 b/sbin/umount/umount.8
index 2f7f9149a45f..d992c3882775 100644
--- a/sbin/umount/umount.8
+++ b/sbin/umount/umount.8
@@ -32,7 +32,7 @@
.\" @(#)umount.8 8.2 (Berkeley) 5/8/95
.\" $FreeBSD$
.\"
-.Dd April 7, 2003
+.Dd July 18, 2003
.Dt UMOUNT 8
.Os
.Sh NAME
@@ -41,7 +41,7 @@
.Sh SYNOPSIS
.Nm
.Op Fl fv
-.Ar special \&| node
+.Ar special | node | fsid
.Nm
.Fl a | A
.Op Fl F Ar fstab
@@ -53,17 +53,15 @@ The
.Nm
utility calls the
.Xr unmount 2
-system call to remove a
-.Ar "special device"
-or the remote node (rhost:path) from the file system tree at the point
-.Ar node .
-If either
+system call to remove a file system from the file system tree.
+The file system can be specified by its
.Ar special
-or
+device or remote node (rhost:path), the path to the mount point
.Ar node
-are not provided, the appropriate information is taken from the
-.Xr fstab 5
-file.
+or by the file system ID
+.Ar fsid
+as reported by
+.Dq mount -v .
.Pp
The options are as follows:
.Bl -tag -width indent
diff --git a/sbin/umount/umount.c b/sbin/umount/umount.c
index 4ed67bf8f4b2..209808c79322 100644
--- a/sbin/umount/umount.c
+++ b/sbin/umount/umount.c
@@ -53,6 +53,7 @@ static const char rcsid[] =
#include <rpc/rpc.h>
#include <nfs/rpcv2.h>
+#include <ctype.h>
#include <err.h>
#include <errno.h>
#include <fstab.h>
@@ -66,7 +67,7 @@ static const char rcsid[] =
#define ISDOT(x) ((x)[0] == '.' && (x)[1] == '\0')
#define ISDOTDOT(x) ((x)[0] == '.' && (x)[1] == '.' && (x)[2] == '\0')
-typedef enum { MNTON, MNTFROM, NOTHING } mntwhat;
+typedef enum { MNTON, MNTFROM, MNTFSID, NOTHING } mntwhat;
typedef enum { MARK, UNMARK, NAME, COUNT, FREE } dowhat;
struct addrinfo *nfshost_ai = NULL;
@@ -465,6 +466,8 @@ getmntentry(const char *fromname, const char *onname, mntwhat what, dowhat mark)
static size_t mntsize = 0;
static char *mntcheck = NULL;
static char *mntcount = NULL;
+ fsid_t fsid;
+ char hexbuf[3];
int i, count;
if (mntsize <= 0) {
@@ -489,10 +492,41 @@ getmntentry(const char *fromname, const char *onname, mntwhat what, dowhat mark)
switch (mark) {
case NAME:
/* Return only the specific name */
+ if (fromname == NULL)
+ return (NULL);
+ if (what == MNTFSID) {
+ /* Convert the hex filesystem ID to a fsid_t. */
+ if (strlen(fromname) != sizeof(fsid) * 2)
+ return (NULL);
+ hexbuf[2] = '\0';
+ for (i = 0; i < sizeof(fsid); i++) {
+ hexbuf[0] = fromname[i * 2];
+ hexbuf[1] = fromname[i * 2 + 1];
+ if (!isxdigit(hexbuf[0]) ||
+ !isxdigit(hexbuf[1]))
+ return (NULL);
+ ((u_char *)&fsid)[i] = strtol(hexbuf, NULL, 16);
+ }
+ }
for (i = mntsize - 1; i >= 0; i--) {
- if (fromname != NULL && !strcmp((what == MNTFROM) ?
- mntbuf[i].f_mntfromname : mntbuf[i].f_mntonname,
- fromname) && mntcheck[i] != 1)
+ switch (what) {
+ case MNTON:
+ if (strcmp(mntbuf[i].f_mntonname,
+ fromname) != 0)
+ continue;
+ break;
+ case MNTFROM:
+ if (strcmp(mntbuf[i].f_mntfromname,
+ fromname) != 0)
+ continue;
+ case MNTFSID:
+ if (bcmp(&mntbuf[i].f_fsid, &fsid,
+ sizeof(fsid)) != 0)
+ continue;
+ case NOTHING: /* silence compiler warning */
+ break;
+ }
+ if (mntcheck[i] != 1)
return (&mntbuf[i]);
}
@@ -609,7 +643,9 @@ checkmntlist(char *name)
{
struct statfs *sfs;
- sfs = getmntentry(name, NULL, MNTON, NAME);
+ sfs = getmntentry(name, NULL, MNTFSID, NAME);
+ if (sfs == NULL)
+ sfs = getmntentry(name, NULL, MNTON, NAME);
if (sfs == NULL)
sfs = getmntentry(name, NULL, MNTFROM, NAME);
return (sfs);