1*8785398fSHiroki Sato /*- 2*8785398fSHiroki Sato * Copyright (c) 2010, Oracle America, Inc. 375b63130SGarrett Wollman * 4*8785398fSHiroki Sato * Redistribution and use in source and binary forms, with or without 5*8785398fSHiroki Sato * modification, are permitted provided that the following conditions are 6*8785398fSHiroki Sato * met: 775b63130SGarrett Wollman * 8*8785398fSHiroki Sato * * Redistributions of source code must retain the above copyright 9*8785398fSHiroki Sato * notice, this list of conditions and the following disclaimer. 10*8785398fSHiroki Sato * * Redistributions in binary form must reproduce the above 11*8785398fSHiroki Sato * copyright notice, this list of conditions and the following 12*8785398fSHiroki Sato * disclaimer in the documentation and/or other materials 13*8785398fSHiroki Sato * provided with the distribution. 14*8785398fSHiroki Sato * * Neither the name of the "Oracle America, Inc." nor the names of its 15*8785398fSHiroki Sato * contributors may be used to endorse or promote products derived 16*8785398fSHiroki Sato * from this software without specific prior written permission. 1775b63130SGarrett Wollman * 18*8785398fSHiroki Sato * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19*8785398fSHiroki Sato * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20*8785398fSHiroki Sato * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 21*8785398fSHiroki Sato * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 22*8785398fSHiroki Sato * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 23*8785398fSHiroki Sato * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 24*8785398fSHiroki Sato * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE 25*8785398fSHiroki Sato * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 26*8785398fSHiroki Sato * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 27*8785398fSHiroki Sato * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 28*8785398fSHiroki Sato * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29*8785398fSHiroki Sato * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 3075b63130SGarrett Wollman */ 3175b63130SGarrett Wollman 3275b63130SGarrett Wollman /* 3375b63130SGarrett Wollman * Protocol description for the mount program 3475b63130SGarrett Wollman */ 3575b63130SGarrett Wollman 3675b63130SGarrett Wollman #ifndef RPC_HDR 3775b63130SGarrett Wollman %#ifndef lint 3875b63130SGarrett Wollman %/*static char sccsid[] = "from: @(#)mount.x 1.2 87/09/18 Copyr 1987 Sun Micro";*/ 3975b63130SGarrett Wollman %/*static char sccsid[] = "from: @(#)mount.x 2.1 88/08/01 4.0 RPCSRC";*/ 4075b63130SGarrett Wollman %#endif /* not lint */ 411542dbb4SDavid E. O'Brien %#include <sys/cdefs.h> 421542dbb4SDavid E. O'Brien %__FBSDID("$FreeBSD$"); 4375b63130SGarrett Wollman #endif 4475b63130SGarrett Wollman 4575b63130SGarrett Wollman const MNTPATHLEN = 1024; /* maximum bytes in a pathname argument */ 4675b63130SGarrett Wollman const MNTNAMLEN = 255; /* maximum bytes in a name argument */ 4775b63130SGarrett Wollman const FHSIZE = 32; /* size in bytes of a file handle */ 487538921eSDoug Rabson #ifdef WANT_NFS3 497538921eSDoug Rabson const FHSIZE3 = 64; /* size in bytes of a file handle (v3) */ 507538921eSDoug Rabson #endif 5175b63130SGarrett Wollman 5275b63130SGarrett Wollman /* 5375b63130SGarrett Wollman * The fhandle is the file handle that the server passes to the client. 5475b63130SGarrett Wollman * All file operations are done using the file handles to refer to a file 5575b63130SGarrett Wollman * or a directory. The file handle can contain whatever information the 5675b63130SGarrett Wollman * server needs to distinguish an individual file. 5775b63130SGarrett Wollman */ 5875b63130SGarrett Wollman typedef opaque fhandle[FHSIZE]; 597538921eSDoug Rabson #ifdef WANT_NFS3 607538921eSDoug Rabson typedef opaque fhandle3<FHSIZE3>; 617538921eSDoug Rabson #endif 6275b63130SGarrett Wollman 6375b63130SGarrett Wollman /* 6475b63130SGarrett Wollman * If a status of zero is returned, the call completed successfully, and 6575b63130SGarrett Wollman * a file handle for the directory follows. A non-zero status indicates 6675b63130SGarrett Wollman * some sort of error. The status corresponds with UNIX error numbers. 6775b63130SGarrett Wollman */ 6875b63130SGarrett Wollman union fhstatus switch (unsigned fhs_status) { 6975b63130SGarrett Wollman case 0: 7075b63130SGarrett Wollman fhandle fhs_fhandle; 7175b63130SGarrett Wollman default: 7275b63130SGarrett Wollman void; 7375b63130SGarrett Wollman }; 7475b63130SGarrett Wollman 757538921eSDoug Rabson #ifdef WANT_NFS3 767538921eSDoug Rabson /* 777538921eSDoug Rabson * Status codes returned by the version 3 mount call. 787538921eSDoug Rabson */ 797538921eSDoug Rabson enum mountstat3 { 807538921eSDoug Rabson MNT3_OK = 0, /* no error */ 817538921eSDoug Rabson MNT3ERR_PERM = 1, /* Not owner */ 827538921eSDoug Rabson MNT3ERR_NOENT = 2, /* No such file or directory */ 837538921eSDoug Rabson MNT3ERR_IO = 5, /* I/O error */ 847538921eSDoug Rabson MNT3ERR_ACCES = 13, /* Permission denied */ 857538921eSDoug Rabson MNT3ERR_NOTDIR = 20, /* Not a directory */ 867538921eSDoug Rabson MNT3ERR_INVAL = 22, /* Invalid argument */ 877538921eSDoug Rabson MNT3ERR_NAMETOOLONG = 63, /* Filename too long */ 887538921eSDoug Rabson MNT3ERR_NOTSUPP = 10004, /* Operation not supported */ 897538921eSDoug Rabson MNT3ERR_SERVERFAULT = 10006 /* A failure on the server */ 907538921eSDoug Rabson }; 917538921eSDoug Rabson 927538921eSDoug Rabson struct mountres3_ok { 937538921eSDoug Rabson fhandle3 fhandle; 947538921eSDoug Rabson int auth_flavors<>; 957538921eSDoug Rabson }; 967538921eSDoug Rabson 977538921eSDoug Rabson union mountres3 switch (mountstat3 fhs_status) { 987538921eSDoug Rabson case 0: 997538921eSDoug Rabson mountres3_ok mountinfo; 1007538921eSDoug Rabson default: 1017538921eSDoug Rabson void; 1027538921eSDoug Rabson }; 1037538921eSDoug Rabson #endif 1047538921eSDoug Rabson 10575b63130SGarrett Wollman /* 10675b63130SGarrett Wollman * The type dirpath is the pathname of a directory 10775b63130SGarrett Wollman */ 10875b63130SGarrett Wollman typedef string dirpath<MNTPATHLEN>; 10975b63130SGarrett Wollman 11075b63130SGarrett Wollman /* 11175b63130SGarrett Wollman * The type name is used for arbitrary names (hostnames, groupnames) 11275b63130SGarrett Wollman */ 11375b63130SGarrett Wollman typedef string name<MNTNAMLEN>; 11475b63130SGarrett Wollman 11575b63130SGarrett Wollman /* 11675b63130SGarrett Wollman * A list of who has what mounted 11775b63130SGarrett Wollman */ 11875b63130SGarrett Wollman typedef struct mountbody *mountlist; 11975b63130SGarrett Wollman struct mountbody { 12075b63130SGarrett Wollman name ml_hostname; 12175b63130SGarrett Wollman dirpath ml_directory; 12275b63130SGarrett Wollman mountlist ml_next; 12375b63130SGarrett Wollman }; 12475b63130SGarrett Wollman 12575b63130SGarrett Wollman /* 12675b63130SGarrett Wollman * A list of netgroups 12775b63130SGarrett Wollman */ 12875b63130SGarrett Wollman typedef struct groupnode *groups; 12975b63130SGarrett Wollman struct groupnode { 13075b63130SGarrett Wollman name gr_name; 13175b63130SGarrett Wollman groups gr_next; 13275b63130SGarrett Wollman }; 13375b63130SGarrett Wollman 13475b63130SGarrett Wollman /* 13575b63130SGarrett Wollman * A list of what is exported and to whom 13675b63130SGarrett Wollman */ 13775b63130SGarrett Wollman typedef struct exportnode *exports; 13875b63130SGarrett Wollman struct exportnode { 13975b63130SGarrett Wollman dirpath ex_dir; 14075b63130SGarrett Wollman groups ex_groups; 14175b63130SGarrett Wollman exports ex_next; 14275b63130SGarrett Wollman }; 14375b63130SGarrett Wollman 14475b63130SGarrett Wollman program MOUNTPROG { 14575b63130SGarrett Wollman /* 14675b63130SGarrett Wollman * Version one of the mount protocol communicates with version two 1477538921eSDoug Rabson * of the NFS protocol. Version three communicates with 1487538921eSDoug Rabson * version three of the NFS protocol. The only connecting 1497538921eSDoug Rabson * point is the fhandle structure, which is the same for both 1507538921eSDoug Rabson * protocols. 15175b63130SGarrett Wollman */ 15275b63130SGarrett Wollman version MOUNTVERS { 15375b63130SGarrett Wollman /* 15475b63130SGarrett Wollman * Does no work. It is made available in all RPC services 1552f98c0baSUlrich Spörlein * to allow server response testing and timing 15675b63130SGarrett Wollman */ 15775b63130SGarrett Wollman void 15875b63130SGarrett Wollman MOUNTPROC_NULL(void) = 0; 15975b63130SGarrett Wollman 16075b63130SGarrett Wollman /* 16175b63130SGarrett Wollman * If fhs_status is 0, then fhs_fhandle contains the 16275b63130SGarrett Wollman * file handle for the directory. This file handle may 16375b63130SGarrett Wollman * be used in the NFS protocol. This procedure also adds 16475b63130SGarrett Wollman * a new entry to the mount list for this client mounting 16575b63130SGarrett Wollman * the directory. 16675b63130SGarrett Wollman * Unix authentication required. 16775b63130SGarrett Wollman */ 16875b63130SGarrett Wollman fhstatus 16975b63130SGarrett Wollman MOUNTPROC_MNT(dirpath) = 1; 17075b63130SGarrett Wollman 17175b63130SGarrett Wollman /* 17275b63130SGarrett Wollman * Returns the list of remotely mounted filesystems. The 17375b63130SGarrett Wollman * mountlist contains one entry for each hostname and 17475b63130SGarrett Wollman * directory pair. 17575b63130SGarrett Wollman */ 17675b63130SGarrett Wollman mountlist 17775b63130SGarrett Wollman MOUNTPROC_DUMP(void) = 2; 17875b63130SGarrett Wollman 17975b63130SGarrett Wollman /* 18075b63130SGarrett Wollman * Removes the mount list entry for the directory 18175b63130SGarrett Wollman * Unix authentication required. 18275b63130SGarrett Wollman */ 18375b63130SGarrett Wollman void 18475b63130SGarrett Wollman MOUNTPROC_UMNT(dirpath) = 3; 18575b63130SGarrett Wollman 18675b63130SGarrett Wollman /* 18775b63130SGarrett Wollman * Removes all of the mount list entries for this client 18875b63130SGarrett Wollman * Unix authentication required. 18975b63130SGarrett Wollman */ 19075b63130SGarrett Wollman void 19175b63130SGarrett Wollman MOUNTPROC_UMNTALL(void) = 4; 19275b63130SGarrett Wollman 19375b63130SGarrett Wollman /* 19475b63130SGarrett Wollman * Returns a list of all the exported filesystems, and which 19575b63130SGarrett Wollman * machines are allowed to import it. 19675b63130SGarrett Wollman */ 19775b63130SGarrett Wollman exports 19875b63130SGarrett Wollman MOUNTPROC_EXPORT(void) = 5; 19975b63130SGarrett Wollman 20075b63130SGarrett Wollman /* 20175b63130SGarrett Wollman * Identical to MOUNTPROC_EXPORT above 20275b63130SGarrett Wollman */ 20375b63130SGarrett Wollman exports 20475b63130SGarrett Wollman MOUNTPROC_EXPORTALL(void) = 6; 20575b63130SGarrett Wollman } = 1; 2067538921eSDoug Rabson #ifdef WANT_NFS3 2077538921eSDoug Rabson version MOUNTVERS3 { 2087538921eSDoug Rabson /* 2097538921eSDoug Rabson * Does no work. It is made available in all RPC services 2102f98c0baSUlrich Spörlein * to allow server response testing and timing 2117538921eSDoug Rabson */ 2127538921eSDoug Rabson void 2137538921eSDoug Rabson MOUNTPROC_NULL(void) = 0; 2147538921eSDoug Rabson 2157538921eSDoug Rabson /* 2167538921eSDoug Rabson * If mountres3.fhs_status is MNT3_OK, then 2177538921eSDoug Rabson * mountres3.mountinfo contains the file handle for 2187538921eSDoug Rabson * the directory and a list of acceptable 2197538921eSDoug Rabson * authentication flavors. This file handle may only 2207538921eSDoug Rabson * be used in the NFS version 3 protocol. This 2217538921eSDoug Rabson * procedure also results in the server adding a new 2227538921eSDoug Rabson * entry to its mount list recording that this client 2237538921eSDoug Rabson * has mounted the directory. AUTH_UNIX authentication 2247538921eSDoug Rabson * or better is required. 2257538921eSDoug Rabson */ 2267538921eSDoug Rabson mountres3 2277538921eSDoug Rabson MOUNTPROC_MNT(dirpath) = 1; 2287538921eSDoug Rabson 2297538921eSDoug Rabson /* 2307538921eSDoug Rabson * Returns the list of remotely mounted filesystems. The 2317538921eSDoug Rabson * mountlist contains one entry for each hostname and 2327538921eSDoug Rabson * directory pair. 2337538921eSDoug Rabson */ 2347538921eSDoug Rabson mountlist 2357538921eSDoug Rabson MOUNTPROC_DUMP(void) = 2; 2367538921eSDoug Rabson 2377538921eSDoug Rabson /* 2387538921eSDoug Rabson * Removes the mount list entry for the directory 2397538921eSDoug Rabson * Unix authentication required. 2407538921eSDoug Rabson */ 2417538921eSDoug Rabson void 2427538921eSDoug Rabson MOUNTPROC_UMNT(dirpath) = 3; 2437538921eSDoug Rabson 2447538921eSDoug Rabson /* 2457538921eSDoug Rabson * Removes all of the mount list entries for this client 2467538921eSDoug Rabson * Unix authentication required. 2477538921eSDoug Rabson */ 2487538921eSDoug Rabson void 2497538921eSDoug Rabson MOUNTPROC_UMNTALL(void) = 4; 2507538921eSDoug Rabson 2517538921eSDoug Rabson /* 2527538921eSDoug Rabson * Returns a list of all the exported filesystems, and which 2537538921eSDoug Rabson * machines are allowed to import it. 2547538921eSDoug Rabson */ 2557538921eSDoug Rabson exports 2567538921eSDoug Rabson MOUNTPROC_EXPORT(void) = 5; 2577538921eSDoug Rabson } = 3; 2587538921eSDoug Rabson #endif 25975b63130SGarrett Wollman } = 100005; 260