1272850Shrs/*-
2272850Shrs * Copyright (c) 2010, Oracle America, Inc.
3272850Shrs *
4272850Shrs * Redistribution and use in source and binary forms, with or without
5272850Shrs * modification, are permitted provided that the following conditions are
6272850Shrs * met:
7272850Shrs *
8272850Shrs *     * Redistributions of source code must retain the above copyright
9272850Shrs *       notice, this list of conditions and the following disclaimer.
10272850Shrs *     * Redistributions in binary form must reproduce the above
11272850Shrs *       copyright notice, this list of conditions and the following
12272850Shrs *       disclaimer in the documentation and/or other materials
13272850Shrs *       provided with the distribution.
14272850Shrs *     * Neither the name of the "Oracle America, Inc." nor the names of its
15272850Shrs *       contributors may be used to endorse or promote products derived
16272850Shrs *       from this software without specific prior written permission.
17272850Shrs *
18272850Shrs *   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19272850Shrs *   "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20272850Shrs *   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
21272850Shrs *   FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
22272850Shrs *   COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
23272850Shrs *   INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24272850Shrs *   DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
25272850Shrs *   GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26272850Shrs *   INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
27272850Shrs *   WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28272850Shrs *   NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29272850Shrs *   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
301832Swollman */
311832Swollman
321832Swollman/*
331832Swollman * Protocol description for the mount program
341832Swollman */
351832Swollman
361832Swollman#ifndef RPC_HDR
371832Swollman%#ifndef lint
381832Swollman%/*static char sccsid[] = "from: @(#)mount.x 1.2 87/09/18 Copyr 1987 Sun Micro";*/
391832Swollman%/*static char sccsid[] = "from: @(#)mount.x	2.1 88/08/01 4.0 RPCSRC";*/
401832Swollman%#endif /* not lint */
41114629Sobrien%#include <sys/cdefs.h>
42114629Sobrien%__FBSDID("$FreeBSD$");
431832Swollman#endif
441832Swollman
451832Swollmanconst MNTPATHLEN = 1024;	/* maximum bytes in a pathname argument */
461832Swollmanconst MNTNAMLEN = 255;		/* maximum bytes in a name argument */
471832Swollmanconst FHSIZE = 32;		/* size in bytes of a file handle */
4825000Sdfr#ifdef WANT_NFS3
4925000Sdfrconst FHSIZE3 = 64;		/* size in bytes of a file handle (v3) */
5025000Sdfr#endif
511832Swollman
521832Swollman/*
531832Swollman * The fhandle is the file handle that the server passes to the client.
541832Swollman * All file operations are done using the file handles to refer to a file
551832Swollman * or a directory. The file handle can contain whatever information the
561832Swollman * server needs to distinguish an individual file.
571832Swollman */
581832Swollmantypedef opaque fhandle[FHSIZE];
5925000Sdfr#ifdef WANT_NFS3
6025000Sdfrtypedef opaque fhandle3<FHSIZE3>;
6125000Sdfr#endif
621832Swollman
631832Swollman/*
641832Swollman * If a status of zero is returned, the call completed successfully, and
651832Swollman * a file handle for the directory follows. A non-zero status indicates
661832Swollman * some sort of error. The status corresponds with UNIX error numbers.
671832Swollman */
681832Swollmanunion fhstatus switch (unsigned fhs_status) {
691832Swollmancase 0:
701832Swollman	fhandle fhs_fhandle;
711832Swollmandefault:
721832Swollman	void;
731832Swollman};
741832Swollman
7525000Sdfr#ifdef WANT_NFS3
761832Swollman/*
7725000Sdfr * Status codes returned by the version 3 mount call.
7825000Sdfr */
7925000Sdfrenum mountstat3 {
8025000Sdfr	MNT3_OK = 0,                 /* no error */
8125000Sdfr	MNT3ERR_PERM = 1,            /* Not owner */
8225000Sdfr	MNT3ERR_NOENT = 2,           /* No such file or directory */
8325000Sdfr	MNT3ERR_IO = 5,              /* I/O error */
8425000Sdfr	MNT3ERR_ACCES = 13,          /* Permission denied */
8525000Sdfr	MNT3ERR_NOTDIR = 20,         /* Not a directory */
8625000Sdfr	MNT3ERR_INVAL = 22,          /* Invalid argument */
8725000Sdfr	MNT3ERR_NAMETOOLONG = 63,    /* Filename too long */
8825000Sdfr	MNT3ERR_NOTSUPP = 10004,     /* Operation not supported */
8925000Sdfr	MNT3ERR_SERVERFAULT = 10006  /* A failure on the server */
9025000Sdfr};
9125000Sdfr
9225000Sdfrstruct mountres3_ok {
9325000Sdfr	fhandle3	fhandle;
9425000Sdfr	int		auth_flavors<>;
9525000Sdfr};
9625000Sdfr
9725000Sdfrunion mountres3 switch (mountstat3 fhs_status) {
9825000Sdfrcase 0:
9925000Sdfr	mountres3_ok	mountinfo;
10025000Sdfrdefault:
10125000Sdfr	void;
10225000Sdfr};
10325000Sdfr#endif
10425000Sdfr
10525000Sdfr/*
1061832Swollman * The type dirpath is the pathname of a directory
1071832Swollman */
1081832Swollmantypedef string dirpath<MNTPATHLEN>;
1091832Swollman
1101832Swollman/*
1111832Swollman * The type name is used for arbitrary names (hostnames, groupnames)
1121832Swollman */
1131832Swollmantypedef string name<MNTNAMLEN>;
1141832Swollman
1151832Swollman/*
1161832Swollman * A list of who has what mounted
1171832Swollman */
1181832Swollmantypedef struct mountbody *mountlist;
1191832Swollmanstruct mountbody {
1201832Swollman	name ml_hostname;
1211832Swollman	dirpath ml_directory;
1221832Swollman	mountlist ml_next;
1231832Swollman};
1241832Swollman
1251832Swollman/*
1261832Swollman * A list of netgroups
1271832Swollman */
1281832Swollmantypedef struct groupnode *groups;
1291832Swollmanstruct groupnode {
1301832Swollman	name gr_name;
1311832Swollman	groups gr_next;
1321832Swollman};
1331832Swollman
1341832Swollman/*
1351832Swollman * A list of what is exported and to whom
1361832Swollman */
1371832Swollmantypedef struct exportnode *exports;
1381832Swollmanstruct exportnode {
1391832Swollman	dirpath ex_dir;
1401832Swollman	groups ex_groups;
1411832Swollman	exports ex_next;
1421832Swollman};
1431832Swollman
1441832Swollmanprogram MOUNTPROG {
1451832Swollman	/*
1461832Swollman	 * Version one of the mount protocol communicates with version two
14725000Sdfr	 * of the NFS protocol. Version three communicates with
14825000Sdfr	 * version three of the NFS protocol. The only connecting
14925000Sdfr	 * point is the fhandle structure, which is the same for both
15025000Sdfr	 * protocols.
1511832Swollman	 */
1521832Swollman	version MOUNTVERS {
1531832Swollman		/*
1541832Swollman		 * Does no work. It is made available in all RPC services
155229781Suqs		 * to allow server response testing and timing
1561832Swollman		 */
1571832Swollman		void
1581832Swollman		MOUNTPROC_NULL(void) = 0;
1591832Swollman
1601832Swollman		/*
1611832Swollman		 * If fhs_status is 0, then fhs_fhandle contains the
1621832Swollman	 	 * file handle for the directory. This file handle may
1631832Swollman		 * be used in the NFS protocol. This procedure also adds
1641832Swollman		 * a new entry to the mount list for this client mounting
1651832Swollman		 * the directory.
1661832Swollman		 * Unix authentication required.
1671832Swollman		 */
1681832Swollman		fhstatus
1691832Swollman		MOUNTPROC_MNT(dirpath) = 1;
1701832Swollman
1711832Swollman		/*
1721832Swollman		 * Returns the list of remotely mounted filesystems. The
1731832Swollman		 * mountlist contains one entry for each hostname and
1741832Swollman		 * directory pair.
1751832Swollman		 */
1761832Swollman		mountlist
1771832Swollman		MOUNTPROC_DUMP(void) = 2;
1781832Swollman
1791832Swollman		/*
1801832Swollman		 * Removes the mount list entry for the directory
1811832Swollman		 * Unix authentication required.
1821832Swollman		 */
1831832Swollman		void
1841832Swollman		MOUNTPROC_UMNT(dirpath) = 3;
1851832Swollman
1861832Swollman		/*
1871832Swollman		 * Removes all of the mount list entries for this client
1881832Swollman		 * Unix authentication required.
1891832Swollman		 */
1901832Swollman		void
1911832Swollman		MOUNTPROC_UMNTALL(void) = 4;
1921832Swollman
1931832Swollman		/*
1941832Swollman		 * Returns a list of all the exported filesystems, and which
1951832Swollman		 * machines are allowed to import it.
1961832Swollman		 */
1971832Swollman		exports
1981832Swollman		MOUNTPROC_EXPORT(void)  = 5;
1991832Swollman
2001832Swollman		/*
2011832Swollman		 * Identical to MOUNTPROC_EXPORT above
2021832Swollman		 */
2031832Swollman		exports
2041832Swollman		MOUNTPROC_EXPORTALL(void) = 6;
2051832Swollman	} = 1;
20625000Sdfr#ifdef WANT_NFS3
20725000Sdfr	version MOUNTVERS3 {
20825000Sdfr		/*
20925000Sdfr		 * Does no work. It is made available in all RPC services
210229781Suqs		 * to allow server response testing and timing
21125000Sdfr		 */
21225000Sdfr		void
21325000Sdfr		MOUNTPROC_NULL(void) = 0;
21425000Sdfr
21525000Sdfr		/*
21625000Sdfr		 * If mountres3.fhs_status is MNT3_OK, then
21725000Sdfr		 * mountres3.mountinfo contains the file handle for
21825000Sdfr		 * the directory and a list of acceptable
21925000Sdfr		 * authentication flavors.  This file handle may only
22025000Sdfr		 * be used in the NFS version 3 protocol.  This
22125000Sdfr		 * procedure also results in the server adding a new
22225000Sdfr		 * entry to its mount list recording that this client
22325000Sdfr		 * has mounted the directory. AUTH_UNIX authentication
22425000Sdfr		 * or better is required.
22525000Sdfr		 */
22625000Sdfr		mountres3
22725000Sdfr		MOUNTPROC_MNT(dirpath) = 1;
22825000Sdfr
22925000Sdfr		/*
23025000Sdfr		 * Returns the list of remotely mounted filesystems. The
23125000Sdfr		 * mountlist contains one entry for each hostname and
23225000Sdfr		 * directory pair.
23325000Sdfr		 */
23425000Sdfr		mountlist
23525000Sdfr		MOUNTPROC_DUMP(void) = 2;
23625000Sdfr
23725000Sdfr		/*
23825000Sdfr		 * Removes the mount list entry for the directory
23925000Sdfr		 * Unix authentication required.
24025000Sdfr		 */
24125000Sdfr		void
24225000Sdfr		MOUNTPROC_UMNT(dirpath) = 3;
24325000Sdfr
24425000Sdfr		/*
24525000Sdfr		 * Removes all of the mount list entries for this client
24625000Sdfr		 * Unix authentication required.
24725000Sdfr		 */
24825000Sdfr		void
24925000Sdfr		MOUNTPROC_UMNTALL(void) = 4;
25025000Sdfr
25125000Sdfr		/*
25225000Sdfr		 * Returns a list of all the exported filesystems, and which
25325000Sdfr		 * machines are allowed to import it.
25425000Sdfr		 */
25525000Sdfr		exports
25625000Sdfr		MOUNTPROC_EXPORT(void)  = 5;
25725000Sdfr	} = 3;
25825000Sdfr#endif
2591832Swollman} = 100005;
260