In the !MNT_BYFSID case, return EINVAL from unmount(2) when the

specified directory is not found in the mount list. Before the
MNT_BYFSID changes, unmount(2) used to return ENOENT for a nonexistent
path and EINVAL for a non-mountpoint, but we can no longer distinguish
between these cases. Of the two error codes, EINVAL was more likely
to occur in practice, and it was the only one of the two that was
documented.

Update the manual page to match the current behaviour.

Suggested by:	tjr
Reviewed by:	tjr
This commit is contained in:
iedowse 2003-09-08 16:23:21 +00:00
parent e3b4b53a4a
commit 36075ef78b
2 changed files with 21 additions and 9 deletions

View File

@ -32,7 +32,7 @@
.\" @(#)mount.2 8.3 (Berkeley) 5/24/95
.\" $FreeBSD$
.\"
.Dd July 1, 2003
.Dd September 8, 2003
.Dt MOUNT 2
.Os
.Sh NAME
@ -294,15 +294,20 @@ system call may fail with one of the following errors:
The caller is neither the super-user nor the user who issued the corresponding
.Fn mount
call.
.It Bq Er ENOTDIR
A component of the path is not a directory.
.It Bq Er ENAMETOOLONG
A component of a pathname exceeded 255 characters,
or an entire path name exceeded 1023 characters.
.It Bq Er ELOOP
Too many symbolic links were encountered in translating the pathname.
The length of the path name exceeded 1023 characters.
.It Bq Er EINVAL
The requested directory is not in the mount table.
.It Bq Er ENOENT
The file system ID specified using
.Dv MNT_BYFSID
was not found in the mount table.
.It Bq Er EINVAL
The file system ID specified using
.Dv MNT_BYFSID
could not be decoded.
.It Bq Er EINVAL
The specified file system is the root file system.
.It Bq Er EBUSY
A process is holding a reference to a file located
on the file system.

View File

@ -1255,8 +1255,15 @@ unmount(td, uap)
mtx_unlock(&mountlist_mtx);
}
free(pathbuf, M_TEMP);
if (mp == NULL)
return (ENOENT);
if (mp == NULL) {
/*
* Previously we returned ENOENT for a nonexistent path and
* EINVAL for a non-mountpoint. We cannot tell these apart
* now, so in the !MNT_BYFSID case return the more likely
* EINVAL for compatibility.
*/
return ((uap->flags & MNT_BYFSID) ? ENOENT : EINVAL);
}
/*
* Only root, or the user that did the original mount is