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 const MNTPATHLEN = 1024; /* maximum bytes in a pathname argument */ 3775b63130SGarrett Wollman const MNTNAMLEN = 255; /* maximum bytes in a name argument */ 3875b63130SGarrett Wollman const FHSIZE = 32; /* size in bytes of a file handle */ 397538921eSDoug Rabson #ifdef WANT_NFS3 407538921eSDoug Rabson const FHSIZE3 = 64; /* size in bytes of a file handle (v3) */ 417538921eSDoug Rabson #endif 4275b63130SGarrett Wollman 4375b63130SGarrett Wollman /* 4475b63130SGarrett Wollman * The fhandle is the file handle that the server passes to the client. 4575b63130SGarrett Wollman * All file operations are done using the file handles to refer to a file 4675b63130SGarrett Wollman * or a directory. The file handle can contain whatever information the 4775b63130SGarrett Wollman * server needs to distinguish an individual file. 4875b63130SGarrett Wollman */ 4975b63130SGarrett Wollman typedef opaque fhandle[FHSIZE]; 507538921eSDoug Rabson #ifdef WANT_NFS3 517538921eSDoug Rabson typedef opaque fhandle3<FHSIZE3>; 527538921eSDoug Rabson #endif 5375b63130SGarrett Wollman 5475b63130SGarrett Wollman /* 5575b63130SGarrett Wollman * If a status of zero is returned, the call completed successfully, and 5675b63130SGarrett Wollman * a file handle for the directory follows. A non-zero status indicates 5775b63130SGarrett Wollman * some sort of error. The status corresponds with UNIX error numbers. 5875b63130SGarrett Wollman */ 5975b63130SGarrett Wollman union fhstatus switch (unsigned fhs_status) { 6075b63130SGarrett Wollman case 0: 6175b63130SGarrett Wollman fhandle fhs_fhandle; 6275b63130SGarrett Wollman default: 6375b63130SGarrett Wollman void; 6475b63130SGarrett Wollman }; 6575b63130SGarrett Wollman 667538921eSDoug Rabson #ifdef WANT_NFS3 677538921eSDoug Rabson /* 687538921eSDoug Rabson * Status codes returned by the version 3 mount call. 697538921eSDoug Rabson */ 707538921eSDoug Rabson enum mountstat3 { 717538921eSDoug Rabson MNT3_OK = 0, /* no error */ 727538921eSDoug Rabson MNT3ERR_PERM = 1, /* Not owner */ 737538921eSDoug Rabson MNT3ERR_NOENT = 2, /* No such file or directory */ 747538921eSDoug Rabson MNT3ERR_IO = 5, /* I/O error */ 757538921eSDoug Rabson MNT3ERR_ACCES = 13, /* Permission denied */ 767538921eSDoug Rabson MNT3ERR_NOTDIR = 20, /* Not a directory */ 777538921eSDoug Rabson MNT3ERR_INVAL = 22, /* Invalid argument */ 787538921eSDoug Rabson MNT3ERR_NAMETOOLONG = 63, /* Filename too long */ 797538921eSDoug Rabson MNT3ERR_NOTSUPP = 10004, /* Operation not supported */ 807538921eSDoug Rabson MNT3ERR_SERVERFAULT = 10006 /* A failure on the server */ 817538921eSDoug Rabson }; 827538921eSDoug Rabson 837538921eSDoug Rabson struct mountres3_ok { 847538921eSDoug Rabson fhandle3 fhandle; 857538921eSDoug Rabson int auth_flavors<>; 867538921eSDoug Rabson }; 877538921eSDoug Rabson 887538921eSDoug Rabson union mountres3 switch (mountstat3 fhs_status) { 897538921eSDoug Rabson case 0: 907538921eSDoug Rabson mountres3_ok mountinfo; 917538921eSDoug Rabson default: 927538921eSDoug Rabson void; 937538921eSDoug Rabson }; 947538921eSDoug Rabson #endif 957538921eSDoug Rabson 9675b63130SGarrett Wollman /* 9775b63130SGarrett Wollman * The type dirpath is the pathname of a directory 9875b63130SGarrett Wollman */ 9975b63130SGarrett Wollman typedef string dirpath<MNTPATHLEN>; 10075b63130SGarrett Wollman 10175b63130SGarrett Wollman /* 10275b63130SGarrett Wollman * The type name is used for arbitrary names (hostnames, groupnames) 10375b63130SGarrett Wollman */ 10475b63130SGarrett Wollman typedef string name<MNTNAMLEN>; 10575b63130SGarrett Wollman 10675b63130SGarrett Wollman /* 10775b63130SGarrett Wollman * A list of who has what mounted 10875b63130SGarrett Wollman */ 10975b63130SGarrett Wollman typedef struct mountbody *mountlist; 11075b63130SGarrett Wollman struct mountbody { 11175b63130SGarrett Wollman name ml_hostname; 11275b63130SGarrett Wollman dirpath ml_directory; 11375b63130SGarrett Wollman mountlist ml_next; 11475b63130SGarrett Wollman }; 11575b63130SGarrett Wollman 11675b63130SGarrett Wollman /* 11775b63130SGarrett Wollman * A list of netgroups 11875b63130SGarrett Wollman */ 11975b63130SGarrett Wollman typedef struct groupnode *groups; 12075b63130SGarrett Wollman struct groupnode { 12175b63130SGarrett Wollman name gr_name; 12275b63130SGarrett Wollman groups gr_next; 12375b63130SGarrett Wollman }; 12475b63130SGarrett Wollman 12575b63130SGarrett Wollman /* 12675b63130SGarrett Wollman * A list of what is exported and to whom 12775b63130SGarrett Wollman */ 12875b63130SGarrett Wollman typedef struct exportnode *exports; 12975b63130SGarrett Wollman struct exportnode { 13075b63130SGarrett Wollman dirpath ex_dir; 13175b63130SGarrett Wollman groups ex_groups; 13275b63130SGarrett Wollman exports ex_next; 13375b63130SGarrett Wollman }; 13475b63130SGarrett Wollman 13575b63130SGarrett Wollman program MOUNTPROG { 13675b63130SGarrett Wollman /* 13775b63130SGarrett Wollman * Version one of the mount protocol communicates with version two 1387538921eSDoug Rabson * of the NFS protocol. Version three communicates with 1397538921eSDoug Rabson * version three of the NFS protocol. The only connecting 1407538921eSDoug Rabson * point is the fhandle structure, which is the same for both 1417538921eSDoug Rabson * protocols. 14275b63130SGarrett Wollman */ 14375b63130SGarrett Wollman version MOUNTVERS { 14475b63130SGarrett Wollman /* 14575b63130SGarrett Wollman * Does no work. It is made available in all RPC services 1462f98c0baSUlrich Spörlein * to allow server response testing and timing 14775b63130SGarrett Wollman */ 14875b63130SGarrett Wollman void 14975b63130SGarrett Wollman MOUNTPROC_NULL(void) = 0; 15075b63130SGarrett Wollman 15175b63130SGarrett Wollman /* 15275b63130SGarrett Wollman * If fhs_status is 0, then fhs_fhandle contains the 15375b63130SGarrett Wollman * file handle for the directory. This file handle may 15475b63130SGarrett Wollman * be used in the NFS protocol. This procedure also adds 15575b63130SGarrett Wollman * a new entry to the mount list for this client mounting 15675b63130SGarrett Wollman * the directory. 15775b63130SGarrett Wollman * Unix authentication required. 15875b63130SGarrett Wollman */ 15975b63130SGarrett Wollman fhstatus 16075b63130SGarrett Wollman MOUNTPROC_MNT(dirpath) = 1; 16175b63130SGarrett Wollman 16275b63130SGarrett Wollman /* 16375b63130SGarrett Wollman * Returns the list of remotely mounted filesystems. The 16475b63130SGarrett Wollman * mountlist contains one entry for each hostname and 16575b63130SGarrett Wollman * directory pair. 16675b63130SGarrett Wollman */ 16775b63130SGarrett Wollman mountlist 16875b63130SGarrett Wollman MOUNTPROC_DUMP(void) = 2; 16975b63130SGarrett Wollman 17075b63130SGarrett Wollman /* 17175b63130SGarrett Wollman * Removes the mount list entry for the directory 17275b63130SGarrett Wollman * Unix authentication required. 17375b63130SGarrett Wollman */ 17475b63130SGarrett Wollman void 17575b63130SGarrett Wollman MOUNTPROC_UMNT(dirpath) = 3; 17675b63130SGarrett Wollman 17775b63130SGarrett Wollman /* 17875b63130SGarrett Wollman * Removes all of the mount list entries for this client 17975b63130SGarrett Wollman * Unix authentication required. 18075b63130SGarrett Wollman */ 18175b63130SGarrett Wollman void 18275b63130SGarrett Wollman MOUNTPROC_UMNTALL(void) = 4; 18375b63130SGarrett Wollman 18475b63130SGarrett Wollman /* 18575b63130SGarrett Wollman * Returns a list of all the exported filesystems, and which 18675b63130SGarrett Wollman * machines are allowed to import it. 18775b63130SGarrett Wollman */ 18875b63130SGarrett Wollman exports 18975b63130SGarrett Wollman MOUNTPROC_EXPORT(void) = 5; 19075b63130SGarrett Wollman 19175b63130SGarrett Wollman /* 19275b63130SGarrett Wollman * Identical to MOUNTPROC_EXPORT above 19375b63130SGarrett Wollman */ 19475b63130SGarrett Wollman exports 19575b63130SGarrett Wollman MOUNTPROC_EXPORTALL(void) = 6; 19675b63130SGarrett Wollman } = 1; 1977538921eSDoug Rabson #ifdef WANT_NFS3 1987538921eSDoug Rabson version MOUNTVERS3 { 1997538921eSDoug Rabson /* 2007538921eSDoug Rabson * Does no work. It is made available in all RPC services 2012f98c0baSUlrich Spörlein * to allow server response testing and timing 2027538921eSDoug Rabson */ 2037538921eSDoug Rabson void 2047538921eSDoug Rabson MOUNTPROC_NULL(void) = 0; 2057538921eSDoug Rabson 2067538921eSDoug Rabson /* 2077538921eSDoug Rabson * If mountres3.fhs_status is MNT3_OK, then 2087538921eSDoug Rabson * mountres3.mountinfo contains the file handle for 2097538921eSDoug Rabson * the directory and a list of acceptable 2107538921eSDoug Rabson * authentication flavors. This file handle may only 2117538921eSDoug Rabson * be used in the NFS version 3 protocol. This 2127538921eSDoug Rabson * procedure also results in the server adding a new 2137538921eSDoug Rabson * entry to its mount list recording that this client 2147538921eSDoug Rabson * has mounted the directory. AUTH_UNIX authentication 2157538921eSDoug Rabson * or better is required. 2167538921eSDoug Rabson */ 2177538921eSDoug Rabson mountres3 2187538921eSDoug Rabson MOUNTPROC_MNT(dirpath) = 1; 2197538921eSDoug Rabson 2207538921eSDoug Rabson /* 2217538921eSDoug Rabson * Returns the list of remotely mounted filesystems. The 2227538921eSDoug Rabson * mountlist contains one entry for each hostname and 2237538921eSDoug Rabson * directory pair. 2247538921eSDoug Rabson */ 2257538921eSDoug Rabson mountlist 2267538921eSDoug Rabson MOUNTPROC_DUMP(void) = 2; 2277538921eSDoug Rabson 2287538921eSDoug Rabson /* 2297538921eSDoug Rabson * Removes the mount list entry for the directory 2307538921eSDoug Rabson * Unix authentication required. 2317538921eSDoug Rabson */ 2327538921eSDoug Rabson void 2337538921eSDoug Rabson MOUNTPROC_UMNT(dirpath) = 3; 2347538921eSDoug Rabson 2357538921eSDoug Rabson /* 2367538921eSDoug Rabson * Removes all of the mount list entries for this client 2377538921eSDoug Rabson * Unix authentication required. 2387538921eSDoug Rabson */ 2397538921eSDoug Rabson void 2407538921eSDoug Rabson MOUNTPROC_UMNTALL(void) = 4; 2417538921eSDoug Rabson 2427538921eSDoug Rabson /* 2437538921eSDoug Rabson * Returns a list of all the exported filesystems, and which 2447538921eSDoug Rabson * machines are allowed to import it. 2457538921eSDoug Rabson */ 2467538921eSDoug Rabson exports 2477538921eSDoug Rabson MOUNTPROC_EXPORT(void) = 5; 2487538921eSDoug Rabson } = 3; 2497538921eSDoug Rabson #endif 25075b63130SGarrett Wollman } = 100005; 251