1*0Sstevel@tonic-gate /* 2*0Sstevel@tonic-gate * CDDL HEADER START 3*0Sstevel@tonic-gate * 4*0Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5*0Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only 6*0Sstevel@tonic-gate * (the "License"). You may not use this file except in compliance 7*0Sstevel@tonic-gate * with the License. 8*0Sstevel@tonic-gate * 9*0Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10*0Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 11*0Sstevel@tonic-gate * See the License for the specific language governing permissions 12*0Sstevel@tonic-gate * and limitations under the License. 13*0Sstevel@tonic-gate * 14*0Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 15*0Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16*0Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 17*0Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 18*0Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 19*0Sstevel@tonic-gate * 20*0Sstevel@tonic-gate * CDDL HEADER END 21*0Sstevel@tonic-gate */ 22*0Sstevel@tonic-gate /* ident "%Z%%M% %I% %E% SMI" */ 23*0Sstevel@tonic-gate 24*0Sstevel@tonic-gate /* 25*0Sstevel@tonic-gate * Copyright (c) 1988,1990-1992,1998 by Sun Microsystems, Inc. 26*0Sstevel@tonic-gate * All rights reserved. 27*0Sstevel@tonic-gate */ 28*0Sstevel@tonic-gate 29*0Sstevel@tonic-gate /* 30*0Sstevel@tonic-gate * Protocol description for the mount program 31*0Sstevel@tonic-gate */ 32*0Sstevel@tonic-gate 33*0Sstevel@tonic-gate const MNTPATHLEN = 1024; /* maximum bytes in a pathname argument */ 34*0Sstevel@tonic-gate const MNTNAMLEN = 255; /* maximum bytes in a name argument */ 35*0Sstevel@tonic-gate const FHSIZE = 32; /* size in bytes of a v2 file handle */ 36*0Sstevel@tonic-gate const FHSIZE3 = 64; /* " " " " " v3 " " */ 37*0Sstevel@tonic-gate 38*0Sstevel@tonic-gate /* 39*0Sstevel@tonic-gate * The fhandle is the file handle that the server passes to the client. 40*0Sstevel@tonic-gate * All file operations are done using the file handles to refer to a file 41*0Sstevel@tonic-gate * or a directory. The file handle can contain whatever information the 42*0Sstevel@tonic-gate * server needs to distinguish an individual file. 43*0Sstevel@tonic-gate * 44*0Sstevel@tonic-gate * Versions 1 and 2 of the protocol share a filehandle of 32 bytes. 45*0Sstevel@tonic-gate * 46*0Sstevel@tonic-gate * Version 3 supports a 64 byte filehandle that can be used only 47*0Sstevel@tonic-gate * with version 3 of the NFS protocol. 48*0Sstevel@tonic-gate */ 49*0Sstevel@tonic-gate 50*0Sstevel@tonic-gate typedef opaque fhandle[FHSIZE]; 51*0Sstevel@tonic-gate typedef opaque fhandle3<FHSIZE3>; 52*0Sstevel@tonic-gate 53*0Sstevel@tonic-gate /* 54*0Sstevel@tonic-gate * If a V2 status of zero is returned, the call completed successfully, and 55*0Sstevel@tonic-gate * a file handle for the directory follows. A non-zero status indicates 56*0Sstevel@tonic-gate * some sort of error. The status corresponds with UNIX error numbers. 57*0Sstevel@tonic-gate */ 58*0Sstevel@tonic-gate union fhstatus switch (unsigned fhs_status) { 59*0Sstevel@tonic-gate case 0: 60*0Sstevel@tonic-gate fhandle fhs_fhandle; 61*0Sstevel@tonic-gate default: 62*0Sstevel@tonic-gate void; 63*0Sstevel@tonic-gate }; 64*0Sstevel@tonic-gate 65*0Sstevel@tonic-gate /* 66*0Sstevel@tonic-gate * This #define is added for backwards compatability with applications 67*0Sstevel@tonic-gate * which reference the old style fhstatus. The second element of that 68*0Sstevel@tonic-gate * structure was called fhs_fh, instead of the current fhs_fhandle. 69*0Sstevel@tonic-gate */ 70*0Sstevel@tonic-gate % 71*0Sstevel@tonic-gate %#define fhs_fh fhstatus_u.fhs_fhandle 72*0Sstevel@tonic-gate 73*0Sstevel@tonic-gate /* 74*0Sstevel@tonic-gate * The following status codes are defined for the V3 mount service: 75*0Sstevel@tonic-gate * Note that the precise enum encoding must be followed; the values 76*0Sstevel@tonic-gate * are derived from existing implementation practice, and there is 77*0Sstevel@tonic-gate * no good reason to disturb them. 78*0Sstevel@tonic-gate */ 79*0Sstevel@tonic-gate enum mountstat3 { 80*0Sstevel@tonic-gate MNT_OK= 0, /* no error */ 81*0Sstevel@tonic-gate MNT3ERR_PERM=1, /* Not owner */ 82*0Sstevel@tonic-gate MNT3ERR_NOENT=2, /* No such file or directory */ 83*0Sstevel@tonic-gate MNT3ERR_IO=5, /* I/O error */ 84*0Sstevel@tonic-gate MNT3ERR_ACCES=13, /* Permission denied */ 85*0Sstevel@tonic-gate MNT3ERR_NOTDIR=20, /* Not a directory*/ 86*0Sstevel@tonic-gate MNT3ERR_INVAL=22, /* Invalid argument.*/ 87*0Sstevel@tonic-gate MNT3ERR_NAMETOOLONG=63, /* File name too long */ 88*0Sstevel@tonic-gate MNT3ERR_NOTSUPP=10004, /* operation not supported */ 89*0Sstevel@tonic-gate MNT3ERR_SERVERFAULT=10006 /* An i/o or similar failure caused */ 90*0Sstevel@tonic-gate /* the server to abandon the request */ 91*0Sstevel@tonic-gate /* No attributes can be returned. The */ 92*0Sstevel@tonic-gate /* client should translate this into EIO */ 93*0Sstevel@tonic-gate }; 94*0Sstevel@tonic-gate 95*0Sstevel@tonic-gate /* 96*0Sstevel@tonic-gate * A V3 server returns a file handle and a list of the authentication 97*0Sstevel@tonic-gate * flavors that the server will accept for this mount. If the list 98*0Sstevel@tonic-gate * is empty, AUTH_UNIX is required. Otherwise, any of the flavors 99*0Sstevel@tonic-gate * listed in auth_flavors<> may be used (but no others). 100*0Sstevel@tonic-gate * The values of the authentication flavors are defined in the 101*0Sstevel@tonic-gate * underlying RPC protocol. 102*0Sstevel@tonic-gate */ 103*0Sstevel@tonic-gate struct mountres3_ok { 104*0Sstevel@tonic-gate fhandle3 fhandle; 105*0Sstevel@tonic-gate int auth_flavors<>; 106*0Sstevel@tonic-gate }; 107*0Sstevel@tonic-gate 108*0Sstevel@tonic-gate /* 109*0Sstevel@tonic-gate * If a V3 status of MNT_OK is returned, the call completed successfully, and 110*0Sstevel@tonic-gate * a file handle for the directory follows. Any other status indicates 111*0Sstevel@tonic-gate * some sort of error. 112*0Sstevel@tonic-gate */ 113*0Sstevel@tonic-gate 114*0Sstevel@tonic-gate union mountres3 switch (mountstat3 fhs_status) { 115*0Sstevel@tonic-gate case MNT_OK: 116*0Sstevel@tonic-gate mountres3_ok mountinfo; 117*0Sstevel@tonic-gate default: 118*0Sstevel@tonic-gate void; 119*0Sstevel@tonic-gate }; 120*0Sstevel@tonic-gate 121*0Sstevel@tonic-gate /* 122*0Sstevel@tonic-gate * The type dirpath is the pathname of a directory 123*0Sstevel@tonic-gate */ 124*0Sstevel@tonic-gate typedef string dirpath<MNTPATHLEN>; 125*0Sstevel@tonic-gate 126*0Sstevel@tonic-gate /* 127*0Sstevel@tonic-gate * The type name is used for arbitrary names (hostnames, groupnames) 128*0Sstevel@tonic-gate */ 129*0Sstevel@tonic-gate typedef string name<MNTNAMLEN>; 130*0Sstevel@tonic-gate 131*0Sstevel@tonic-gate /* 132*0Sstevel@tonic-gate * A list of who has what mounted. This information is 133*0Sstevel@tonic-gate * strictly advisory, since there is no mechanism to 134*0Sstevel@tonic-gate * enforce the removal of stale information. The strongest 135*0Sstevel@tonic-gate * assertion that can be made is that if a hostname:directory 136*0Sstevel@tonic-gate * pair appears in the list, the server has exported the 137*0Sstevel@tonic-gate * directory to that client at some point since the server 138*0Sstevel@tonic-gate * export data base was (re)initialized. Note also that there 139*0Sstevel@tonic-gate * is no limit on the length of the information returned 140*0Sstevel@tonic-gate * in this structure, and this may cause problems if the 141*0Sstevel@tonic-gate * mount service is accessed via a connectionless transport. 142*0Sstevel@tonic-gate * 143*0Sstevel@tonic-gate * The ifdef will ensure that these are only carried over to 144*0Sstevel@tonic-gate * mount.h - no xdr routines will be generated. We want to 145*0Sstevel@tonic-gate * do these by hand, to avoid the recursive stack-blowing ones 146*0Sstevel@tonic-gate * that rpcgen will generate. 147*0Sstevel@tonic-gate */ 148*0Sstevel@tonic-gate #ifdef RPC_HDR 149*0Sstevel@tonic-gate typedef struct mountbody *mountlist; 150*0Sstevel@tonic-gate struct mountbody { 151*0Sstevel@tonic-gate name ml_hostname; 152*0Sstevel@tonic-gate dirpath ml_directory; 153*0Sstevel@tonic-gate mountlist ml_next; 154*0Sstevel@tonic-gate }; 155*0Sstevel@tonic-gate #endif /* RPC_HDR */ 156*0Sstevel@tonic-gate 157*0Sstevel@tonic-gate /* 158*0Sstevel@tonic-gate * A list of netgroups 159*0Sstevel@tonic-gate */ 160*0Sstevel@tonic-gate typedef struct groupnode *groups; 161*0Sstevel@tonic-gate struct groupnode { 162*0Sstevel@tonic-gate name gr_name; 163*0Sstevel@tonic-gate groups gr_next; 164*0Sstevel@tonic-gate }; 165*0Sstevel@tonic-gate 166*0Sstevel@tonic-gate /* 167*0Sstevel@tonic-gate * A list of what is exported and to whom 168*0Sstevel@tonic-gate */ 169*0Sstevel@tonic-gate typedef struct exportnode *exports; 170*0Sstevel@tonic-gate struct exportnode { 171*0Sstevel@tonic-gate dirpath ex_dir; 172*0Sstevel@tonic-gate groups ex_groups; 173*0Sstevel@tonic-gate exports ex_next; 174*0Sstevel@tonic-gate }; 175*0Sstevel@tonic-gate 176*0Sstevel@tonic-gate /* 177*0Sstevel@tonic-gate * POSIX pathconf information 178*0Sstevel@tonic-gate */ 179*0Sstevel@tonic-gate struct ppathcnf { 180*0Sstevel@tonic-gate int pc_link_max; /* max links allowed */ 181*0Sstevel@tonic-gate short pc_max_canon; /* max line len for a tty */ 182*0Sstevel@tonic-gate short pc_max_input; /* input a tty can eat all at once */ 183*0Sstevel@tonic-gate short pc_name_max; /* max file name length (dir entry) */ 184*0Sstevel@tonic-gate short pc_path_max; /* max path name length (/x/y/x/.. ) */ 185*0Sstevel@tonic-gate short pc_pipe_buf; /* size of a pipe (bytes) */ 186*0Sstevel@tonic-gate u_char pc_vdisable; /* safe char to turn off c_cc[i] */ 187*0Sstevel@tonic-gate char pc_xxx; /* alignment padding; cc_t == char */ 188*0Sstevel@tonic-gate short pc_mask[2]; /* validity and boolean bits */ 189*0Sstevel@tonic-gate }; 190*0Sstevel@tonic-gate 191*0Sstevel@tonic-gate program MOUNTPROG { 192*0Sstevel@tonic-gate /* 193*0Sstevel@tonic-gate * Version one of the mount protocol communicates with version two 194*0Sstevel@tonic-gate * of the NFS protocol. The only connecting point is the fhandle 195*0Sstevel@tonic-gate * structure, which is the same for both protocols. 196*0Sstevel@tonic-gate */ 197*0Sstevel@tonic-gate version MOUNTVERS { 198*0Sstevel@tonic-gate /* 199*0Sstevel@tonic-gate * Does no work. It is made available in all RPC services 200*0Sstevel@tonic-gate * to allow server reponse testing and timing 201*0Sstevel@tonic-gate */ 202*0Sstevel@tonic-gate void 203*0Sstevel@tonic-gate MOUNTPROC_NULL(void) = 0; 204*0Sstevel@tonic-gate 205*0Sstevel@tonic-gate /* 206*0Sstevel@tonic-gate * If fhs_status is 0, then fhs_fhandle contains the 207*0Sstevel@tonic-gate * file handle for the directory. This file handle may 208*0Sstevel@tonic-gate * be used in the NFS protocol. This procedure also adds 209*0Sstevel@tonic-gate * a new entry to the mount list for this client mounting 210*0Sstevel@tonic-gate * the directory. 211*0Sstevel@tonic-gate * Unix authentication required. 212*0Sstevel@tonic-gate */ 213*0Sstevel@tonic-gate fhstatus 214*0Sstevel@tonic-gate MOUNTPROC_MNT(dirpath) = 1; 215*0Sstevel@tonic-gate 216*0Sstevel@tonic-gate /* 217*0Sstevel@tonic-gate * Returns the list of remotely mounted filesystems. The 218*0Sstevel@tonic-gate * mountlist contains one entry for each hostname and 219*0Sstevel@tonic-gate * directory pair. 220*0Sstevel@tonic-gate */ 221*0Sstevel@tonic-gate mountlist 222*0Sstevel@tonic-gate MOUNTPROC_DUMP(void) = 2; 223*0Sstevel@tonic-gate 224*0Sstevel@tonic-gate /* 225*0Sstevel@tonic-gate * Removes the mount list entry for the directory 226*0Sstevel@tonic-gate * Unix authentication required. 227*0Sstevel@tonic-gate */ 228*0Sstevel@tonic-gate void 229*0Sstevel@tonic-gate MOUNTPROC_UMNT(dirpath) = 3; 230*0Sstevel@tonic-gate 231*0Sstevel@tonic-gate /* 232*0Sstevel@tonic-gate * Removes all of the mount list entries for this client 233*0Sstevel@tonic-gate * Unix authentication required. 234*0Sstevel@tonic-gate */ 235*0Sstevel@tonic-gate void 236*0Sstevel@tonic-gate MOUNTPROC_UMNTALL(void) = 4; 237*0Sstevel@tonic-gate 238*0Sstevel@tonic-gate /* 239*0Sstevel@tonic-gate * Returns a list of all the exported filesystems, and which 240*0Sstevel@tonic-gate * machines are allowed to import it. 241*0Sstevel@tonic-gate */ 242*0Sstevel@tonic-gate exports 243*0Sstevel@tonic-gate MOUNTPROC_EXPORT(void) = 5; 244*0Sstevel@tonic-gate 245*0Sstevel@tonic-gate /* 246*0Sstevel@tonic-gate * Identical to MOUNTPROC_EXPORT above 247*0Sstevel@tonic-gate */ 248*0Sstevel@tonic-gate exports 249*0Sstevel@tonic-gate MOUNTPROC_EXPORTALL(void) = 6; 250*0Sstevel@tonic-gate } = 1; 251*0Sstevel@tonic-gate 252*0Sstevel@tonic-gate /* 253*0Sstevel@tonic-gate * Version two of the mount protocol communicates with version two 254*0Sstevel@tonic-gate * of the NFS protocol. It is identical to version one except for a 255*0Sstevel@tonic-gate * new procedure call for posix. 256*0Sstevel@tonic-gate */ 257*0Sstevel@tonic-gate version MOUNTVERS_POSIX { 258*0Sstevel@tonic-gate /* 259*0Sstevel@tonic-gate * Does no work. It is made available in all RPC services 260*0Sstevel@tonic-gate * to allow server reponse testing and timing 261*0Sstevel@tonic-gate */ 262*0Sstevel@tonic-gate void 263*0Sstevel@tonic-gate MOUNTPROC_NULL(void) = 0; 264*0Sstevel@tonic-gate 265*0Sstevel@tonic-gate /* 266*0Sstevel@tonic-gate * If fhs_status is 0, then fhs_fhandle contains the 267*0Sstevel@tonic-gate * file handle for the directory. This file handle may 268*0Sstevel@tonic-gate * be used in the NFS protocol. This procedure also adds 269*0Sstevel@tonic-gate * a new entry to the mount list for this client mounting 270*0Sstevel@tonic-gate * the directory. 271*0Sstevel@tonic-gate * Unix authentication required. 272*0Sstevel@tonic-gate */ 273*0Sstevel@tonic-gate fhstatus 274*0Sstevel@tonic-gate MOUNTPROC_MNT(dirpath) = 1; 275*0Sstevel@tonic-gate 276*0Sstevel@tonic-gate /* 277*0Sstevel@tonic-gate * Returns the list of remotely mounted filesystems. The 278*0Sstevel@tonic-gate * mountlist contains one entry for each hostname and 279*0Sstevel@tonic-gate * directory pair. 280*0Sstevel@tonic-gate */ 281*0Sstevel@tonic-gate mountlist 282*0Sstevel@tonic-gate MOUNTPROC_DUMP(void) = 2; 283*0Sstevel@tonic-gate 284*0Sstevel@tonic-gate /* 285*0Sstevel@tonic-gate * Removes the mount list entry for the directory 286*0Sstevel@tonic-gate * Unix authentication required. 287*0Sstevel@tonic-gate */ 288*0Sstevel@tonic-gate void 289*0Sstevel@tonic-gate MOUNTPROC_UMNT(dirpath) = 3; 290*0Sstevel@tonic-gate 291*0Sstevel@tonic-gate /* 292*0Sstevel@tonic-gate * Removes all of the mount list entries for this client 293*0Sstevel@tonic-gate * Unix authentication required. 294*0Sstevel@tonic-gate */ 295*0Sstevel@tonic-gate void 296*0Sstevel@tonic-gate MOUNTPROC_UMNTALL(void) = 4; 297*0Sstevel@tonic-gate 298*0Sstevel@tonic-gate /* 299*0Sstevel@tonic-gate * Returns a list of all the exported filesystems, and which 300*0Sstevel@tonic-gate * machines are allowed to import it. 301*0Sstevel@tonic-gate */ 302*0Sstevel@tonic-gate exports 303*0Sstevel@tonic-gate MOUNTPROC_EXPORT(void) = 5; 304*0Sstevel@tonic-gate 305*0Sstevel@tonic-gate /* 306*0Sstevel@tonic-gate * Identical to MOUNTPROC_EXPORT above 307*0Sstevel@tonic-gate */ 308*0Sstevel@tonic-gate exports 309*0Sstevel@tonic-gate MOUNTPROC_EXPORTALL(void) = 6; 310*0Sstevel@tonic-gate 311*0Sstevel@tonic-gate /* 312*0Sstevel@tonic-gate * Posix info over the wire isn't supported in NFS version 2 313*0Sstevel@tonic-gate * so we get it here at mount time. 314*0Sstevel@tonic-gate */ 315*0Sstevel@tonic-gate ppathcnf 316*0Sstevel@tonic-gate MOUNTPROC_PATHCONF(dirpath) = 7; 317*0Sstevel@tonic-gate } = 2; 318*0Sstevel@tonic-gate 319*0Sstevel@tonic-gate /* 320*0Sstevel@tonic-gate * Version 3 of the mount protocol communicates with version 3 321*0Sstevel@tonic-gate * of the NFS protocol. The only connecting point is the nfs_fh3 322*0Sstevel@tonic-gate * structure, which is the same for both protocols. 323*0Sstevel@tonic-gate * 324*0Sstevel@tonic-gate * The only significant change over version 2 is that MOUNTPROC_MNT 325*0Sstevel@tonic-gate * returns a longer filehandle (64 bytes instead of 32) as well 326*0Sstevel@tonic-gate * as authentication information. MOUNTPROC_PATHCONF is subsumed 327*0Sstevel@tonic-gate * into V3 of the NFS protocol and MOUNTPROC_EXPORTALL is eliminated. 328*0Sstevel@tonic-gate */ 329*0Sstevel@tonic-gate version MOUNTVERS3 { 330*0Sstevel@tonic-gate /* 331*0Sstevel@tonic-gate * Does no work. It is made available in all RPC services 332*0Sstevel@tonic-gate * to allow server reponse testing and timing 333*0Sstevel@tonic-gate */ 334*0Sstevel@tonic-gate void 335*0Sstevel@tonic-gate MOUNTPROC_NULL(void) = 0; 336*0Sstevel@tonic-gate 337*0Sstevel@tonic-gate /* 338*0Sstevel@tonic-gate * Mount a file system. 339*0Sstevel@tonic-gate * 340*0Sstevel@tonic-gate * If mountres.fhs_status is NFS_OK, then mountres.mountinfo 341*0Sstevel@tonic-gate * contains the file handle for the directory and 342*0Sstevel@tonic-gate * a list of acceptable authentication flavors. This file 343*0Sstevel@tonic-gate * handle may only be used in version 3 of the NFS protocol. 344*0Sstevel@tonic-gate * This procedure also results in the server adding a new 345*0Sstevel@tonic-gate * entry to its mount list recording that this client has 346*0Sstevel@tonic-gate * mounted the directory. Unix authentication or better 347*0Sstevel@tonic-gate * is required. 348*0Sstevel@tonic-gate */ 349*0Sstevel@tonic-gate mountres3 350*0Sstevel@tonic-gate MOUNTPROC_MNT(dirpath) = 1; 351*0Sstevel@tonic-gate 352*0Sstevel@tonic-gate /* 353*0Sstevel@tonic-gate * Returns the list of remotely mounted filesystems. The 354*0Sstevel@tonic-gate * mountlist contains one entry for each hostname and 355*0Sstevel@tonic-gate * directory pair. 356*0Sstevel@tonic-gate */ 357*0Sstevel@tonic-gate mountlist 358*0Sstevel@tonic-gate MOUNTPROC_DUMP(void) = 2; 359*0Sstevel@tonic-gate 360*0Sstevel@tonic-gate /* 361*0Sstevel@tonic-gate * Removes the mount list entry for the directory 362*0Sstevel@tonic-gate * Unix authentication or better is required. 363*0Sstevel@tonic-gate */ 364*0Sstevel@tonic-gate void 365*0Sstevel@tonic-gate MOUNTPROC_UMNT(dirpath) = 3; 366*0Sstevel@tonic-gate 367*0Sstevel@tonic-gate /* 368*0Sstevel@tonic-gate * Removes all of the mount list entries for this client 369*0Sstevel@tonic-gate * Unix authentication or better is required. 370*0Sstevel@tonic-gate */ 371*0Sstevel@tonic-gate void 372*0Sstevel@tonic-gate MOUNTPROC_UMNTALL(void) = 4; 373*0Sstevel@tonic-gate 374*0Sstevel@tonic-gate /* 375*0Sstevel@tonic-gate * Returns a list of all the exported filesystems, and which 376*0Sstevel@tonic-gate * machines are allowed to import each one. 377*0Sstevel@tonic-gate */ 378*0Sstevel@tonic-gate exports 379*0Sstevel@tonic-gate MOUNTPROC_EXPORT(void) = 5; 380*0Sstevel@tonic-gate 381*0Sstevel@tonic-gate } = 3; 382*0Sstevel@tonic-gate } = 100005; 383