From nobody@FreeBSD.org  Mon Dec 31 20:03:59 2012
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52])
	by hub.freebsd.org (Postfix) with ESMTP id 488538D7
	for <freebsd-gnats-submit@FreeBSD.org>; Mon, 31 Dec 2012 20:03:59 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from red.freebsd.org (red.freebsd.org [IPv6:2001:4f8:fff6::22])
	by mx1.freebsd.org (Postfix) with ESMTP id 2DE718FC08
	for <freebsd-gnats-submit@FreeBSD.org>; Mon, 31 Dec 2012 20:03:59 +0000 (UTC)
Received: from red.freebsd.org (localhost [127.0.0.1])
	by red.freebsd.org (8.14.5/8.14.5) with ESMTP id qBVK3xpQ042899
	for <freebsd-gnats-submit@FreeBSD.org>; Mon, 31 Dec 2012 20:03:59 GMT
	(envelope-from nobody@red.freebsd.org)
Received: (from nobody@localhost)
	by red.freebsd.org (8.14.5/8.14.5/Submit) id qBVK3xMI042898;
	Mon, 31 Dec 2012 20:03:59 GMT
	(envelope-from nobody)
Message-Id: <201212312003.qBVK3xMI042898@red.freebsd.org>
Date: Mon, 31 Dec 2012 20:03:59 GMT
From: Garrett Cooper <yaneurabeya@gmail.com>
To: freebsd-gnats-submit@FreeBSD.org
Subject: mount(2) doesn't do a good job at describing all possible errors in manpage
X-Send-Pr-Version: www-3.1
X-GNATS-Notify:

>Number:         174868
>Category:       docs
>Synopsis:       mount(2) doesn't do a good job at describing all possible errors in manpage
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-doc
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Mon Dec 31 20:10:00 UTC 2012
>Closed-Date:    
>Last-Modified:  Sun Feb 03 22:31:57 UTC 2013
>Originator:     Garrett Cooper
>Release:        9.1-STABLE
>Organization:
EMC Isilon
>Environment:
FreeBSD forza.west.isilon.com 9.1-PRERELEASE FreeBSD 9.1-PRERELEASE #0 r+336aa21: Wed Dec 19 18:05:45 PST 2012     gcooper@forza.west.isilon.com:/usr/obj/usr/src/sys/FORZA  amd64
>Description:
Several errors aren't properly documented when calling vfs_domount. In particular
these sections of code aren't documented properly:

1075                 if (fsflags & MNT_ROOTFS)
1076                         vfsp = vfs_byname(fstype);
1077                 else
1078                         vfsp = vfs_byname_kld(fstype, td, &error);
1079                 if (vfsp == NULL)
1080                         return (ENODEV);
1081                 if (jailed(td->td_ucred) && !(vfsp->vfc_flags & VFCF_JAIL))
1082                         return (EPERM);

- Line 975 seems like it should be ENOENT (according to kldload(2)), but that might cause confusion to any callers of mount(2).
- Line 976 is completely undocumented (if you don't have permissions to mount in a jail, fail with EPERM).

I'm also not entirely sure why this check exists in addition to the check on 1081 because it seems like unnecessary duplication, but I'd need to check priv_check a bit more to determine whether or not that's a disjoint set of requirements:

1045         if (jailed(td->td_ucred) || usermount == 0) {
1046                 if ((error = priv_check(td, PRIV_VFS_MOUNT)) != 0)
1047                         return (error);
1048         }
>How-To-Repeat:

>Fix:


>Release-Note:
>Audit-Trail:
>Unformatted:
