From 2e1d99cc8a99496e19013067b66e5e4e0fe8c05f Mon Sep 17 00:00:00 2001 From: iedowse Date: Mon, 8 Sep 2003 16:23:21 +0000 Subject: 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 --- lib/libc/sys/mount.2 | 19 ++++++++++++------- sys/kern/vfs_mount.c | 11 +++++++++-- 2 files changed, 21 insertions(+), 9 deletions(-) diff --git a/lib/libc/sys/mount.2 b/lib/libc/sys/mount.2 index 1b551ed..58094f2 100644 --- a/lib/libc/sys/mount.2 +++ b/lib/libc/sys/mount.2 @@ -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. diff --git a/sys/kern/vfs_mount.c b/sys/kern/vfs_mount.c index 7d166f0..efc7874 100644 --- a/sys/kern/vfs_mount.c +++ b/sys/kern/vfs_mount.c @@ -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 -- cgit v1.1