1 /* $NetBSD: nfs_prot_sunos5_8.h,v 1.1.1.2 2009/03/20 20:26:52 christos Exp $ */ 2 3 /* 4 * Copyright (c) 1997-2009 Erez Zadok 5 * Copyright (c) 1990 Jan-Simon Pendry 6 * Copyright (c) 1990 Imperial College of Science, Technology & Medicine 7 * Copyright (c) 1990 The Regents of the University of California. 8 * All rights reserved. 9 * 10 * This code is derived from software contributed to Berkeley by 11 * Jan-Simon Pendry at Imperial College, London. 12 * 13 * Redistribution and use in source and binary forms, with or without 14 * modification, are permitted provided that the following conditions 15 * are met: 16 * 1. Redistributions of source code must retain the above copyright 17 * notice, this list of conditions and the following disclaimer. 18 * 2. Redistributions in binary form must reproduce the above copyright 19 * notice, this list of conditions and the following disclaimer in the 20 * documentation and/or other materials provided with the distribution. 21 * 3. All advertising materials mentioning features or use of this software 22 * must display the following acknowledgment: 23 * This product includes software developed by the University of 24 * California, Berkeley and its contributors. 25 * 4. Neither the name of the University nor the names of its contributors 26 * may be used to endorse or promote products derived from this software 27 * without specific prior written permission. 28 * 29 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 30 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 31 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 32 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 33 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 34 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 35 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 36 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 37 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 38 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 39 * SUCH DAMAGE. 40 * 41 * 42 * File: am-utils/conf/nfs_prot/nfs_prot_sunos5_8.h 43 * 44 */ 45 46 #ifndef _AMU_NFS_PROT_H 47 #define _AMU_NFS_PROT_H 48 49 /* 50 * Do NOT include <rpcsvc/nfs_prot.h> to get NFS V2 specs, because 51 * it will result in conflicts with <nfs/nfs.h>. The latter is a must 52 * for NFS V3 specs. 53 */ 54 55 #ifdef HAVE_NFS_NFS_H 56 # include <nfs/nfs.h> 57 #endif /* HAVE_NFS_NFS_H */ 58 59 #ifdef HAVE_RPCSVC_MOUNT_H 60 # include <rpcsvc/mount.h> 61 #endif /* HAVE_RPCSVC_MOUNT_H */ 62 63 #ifdef HAVE_RPC_RPC_H 64 # include <rpc/rpc.h> 65 #endif /* HAVE_RPC_RPC_H */ 66 67 68 /* 69 * MACROS 70 */ 71 72 #define NFS_PORT 2049 73 #define NFS_MAXDATA 8192 74 #define NFS_MAXPATHLEN 1024 75 #define NFS_MAXNAMLEN 255 76 #define NFS_FHSIZE 32 77 #define NFS_COOKIESIZE 4 78 79 #define NFSMODE_FMT 0170000 80 #define NFSMODE_DIR 0040000 81 #define NFSMODE_CHR 0020000 82 #define NFSMODE_BLK 0060000 83 #define NFSMODE_REG 0100000 84 #define NFSMODE_LNK 0120000 85 #define NFSMODE_SOCK 0140000 86 #define NFSMODE_FIFO 0010000 87 88 #define NFSPROC_NULL ((unsigned long)(0)) 89 #define NFSPROC_GETATTR ((unsigned long)(1)) 90 #define NFSPROC_SETATTR ((unsigned long)(2)) 91 #define NFSPROC_ROOT ((unsigned long)(3)) 92 #define NFSPROC_LOOKUP ((unsigned long)(4)) 93 #define NFSPROC_READLINK ((unsigned long)(5)) 94 #define NFSPROC_READ ((unsigned long)(6)) 95 #define NFSPROC_WRITECACHE ((unsigned long)(7)) 96 #define NFSPROC_WRITE ((unsigned long)(8)) 97 #define NFSPROC_CREATE ((unsigned long)(9)) 98 #define NFSPROC_REMOVE ((unsigned long)(10)) 99 #define NFSPROC_RENAME ((unsigned long)(11)) 100 #define NFSPROC_LINK ((unsigned long)(12)) 101 #define NFSPROC_SYMLINK ((unsigned long)(13)) 102 #define NFSPROC_MKDIR ((unsigned long)(14)) 103 #define NFSPROC_RMDIR ((unsigned long)(15)) 104 #define NFSPROC_READDIR ((unsigned long)(16)) 105 #define NFSPROC_STATFS ((unsigned long)(17)) 106 107 #define AUTOFS_CONFTYPE "ticotsord" 108 109 /* 110 * TYPEDEFS: 111 */ 112 113 typedef char *filename; 114 typedef char *nfspath; 115 typedef char nfscookie[NFS_COOKIESIZE]; 116 typedef enum nfsftype nfsftype; 117 typedef struct attrstat nfsattrstat; 118 typedef struct createargs nfscreateargs; 119 typedef struct dirlist nfsdirlist; 120 typedef struct diropargs nfsdiropargs; 121 typedef struct diropokres nfsdiropokres; 122 typedef struct diropres nfsdiropres; 123 typedef struct entry nfsentry; 124 typedef struct fattr nfsfattr; 125 typedef struct linkargs nfslinkargs; 126 typedef struct nfs_fh nfs_fh; 127 typedef struct nfstime nfstime; 128 typedef struct readargs nfsreadargs; 129 typedef struct readdirargs nfsreaddirargs; 130 typedef struct readdirres nfsreaddirres; 131 typedef struct readlinkres nfsreadlinkres; 132 typedef struct readokres nfsreadokres; 133 typedef struct readres nfsreadres; 134 typedef struct renameargs nfsrenameargs; 135 typedef struct sattr nfssattr; 136 typedef struct sattrargs nfssattrargs; 137 typedef struct statfsokres nfsstatfsokres; 138 typedef struct statfsres nfsstatfsres; 139 typedef struct symlinkargs nfssymlinkargs; 140 typedef struct writeargs nfswriteargs; 141 142 143 /* 144 * EXTERNALS: 145 */ 146 147 extern bool_t xdr_nfsstat(XDR *, nfsstat *); 148 extern bool_t xdr_ftype(XDR *, nfsftype *); 149 extern bool_t xdr_nfs_fh(XDR *, nfs_fh *); 150 extern bool_t xdr_nfstime(XDR *, nfstime *); 151 extern bool_t xdr_fattr(XDR *, nfsfattr *); 152 extern bool_t xdr_sattr(XDR *, nfssattr *); 153 extern bool_t xdr_filename(XDR *, filename *); 154 extern bool_t xdr_nfspath(XDR *, nfspath *); 155 extern bool_t xdr_attrstat(XDR *, nfsattrstat *); 156 extern bool_t xdr_sattrargs(XDR *, nfssattrargs *); 157 extern bool_t xdr_diropargs(XDR *, nfsdiropargs *); 158 extern bool_t xdr_diropokres(XDR *, nfsdiropokres *); 159 extern bool_t xdr_diropres(XDR *, nfsdiropres *); 160 extern bool_t xdr_readlinkres(XDR *, nfsreadlinkres *); 161 extern bool_t xdr_readargs(XDR *, nfsreadargs *); 162 extern bool_t xdr_readokres(XDR *, nfsreadokres *); 163 extern bool_t xdr_readres(XDR *, nfsreadres *); 164 extern bool_t xdr_writeargs(XDR *, nfswriteargs *); 165 extern bool_t xdr_createargs(XDR *, nfscreateargs *); 166 extern bool_t xdr_renameargs(XDR *, nfsrenameargs *); 167 extern bool_t xdr_linkargs(XDR *, nfslinkargs *); 168 extern bool_t xdr_symlinkargs(XDR *, nfssymlinkargs *); 169 extern bool_t xdr_nfscookie(XDR *, nfscookie); 170 extern bool_t xdr_readdirargs(XDR *, nfsreaddirargs *); 171 extern bool_t xdr_entry(XDR *, nfsentry *); 172 extern bool_t xdr_dirlist(XDR *, nfsdirlist *); 173 extern bool_t xdr_readdirres(XDR *, nfsreaddirres *); 174 extern bool_t xdr_statfsokres(XDR *, nfsstatfsokres *); 175 extern bool_t xdr_statfsres(XDR *, nfsstatfsres *); 176 177 extern nfsattrstat *nfsproc_getattr_2(nfs_fh *, CLIENT *); 178 extern nfsattrstat *nfsproc_getattr_2_svc(nfs_fh *, struct svc_req *); 179 extern nfsattrstat *nfsproc_setattr_2(nfssattrargs *, CLIENT *); 180 extern nfsattrstat *nfsproc_setattr_2_svc(nfssattrargs *, struct svc_req *); 181 extern nfsattrstat *nfsproc_write_2(nfswriteargs *, CLIENT *); 182 extern nfsattrstat *nfsproc_write_2_svc(nfswriteargs *, struct svc_req *); 183 extern nfsdiropres *nfsproc_create_2(nfscreateargs *, CLIENT *); 184 extern nfsdiropres *nfsproc_create_2_svc(nfscreateargs *, struct svc_req *); 185 extern nfsdiropres *nfsproc_lookup_2(nfsdiropargs *, CLIENT *); 186 extern nfsdiropres *nfsproc_lookup_2_svc(nfsdiropargs *, struct svc_req *); 187 extern nfsdiropres *nfsproc_mkdir_2(nfscreateargs *, CLIENT *); 188 extern nfsdiropres *nfsproc_mkdir_2_svc(nfscreateargs *, struct svc_req *); 189 extern nfsstat *nfsproc_link_2(nfslinkargs *, CLIENT *); 190 extern nfsstat *nfsproc_link_2_svc(nfslinkargs *, struct svc_req *); 191 extern nfsstat *nfsproc_remove_2(nfsdiropargs *, CLIENT *); 192 extern nfsstat *nfsproc_remove_2_svc(nfsdiropargs *, struct svc_req *); 193 extern nfsstat *nfsproc_rename_2(nfsrenameargs *, CLIENT *); 194 extern nfsstat *nfsproc_rename_2_svc(nfsrenameargs *, struct svc_req *); 195 extern nfsstat *nfsproc_rmdir_2(nfsdiropargs *, CLIENT *); 196 extern nfsstat *nfsproc_rmdir_2_svc(nfsdiropargs *, struct svc_req *); 197 extern nfsstat *nfsproc_symlink_2(nfssymlinkargs *, CLIENT *); 198 extern nfsstat *nfsproc_symlink_2_svc(nfssymlinkargs *, struct svc_req *); 199 extern nfsreaddirres *nfsproc_readdir_2(nfsreaddirargs *, CLIENT *); 200 extern nfsreaddirres *nfsproc_readdir_2_svc(nfsreaddirargs *, struct svc_req *); 201 extern nfsreadlinkres *nfsproc_readlink_2(nfs_fh *, CLIENT *); 202 extern nfsreadlinkres *nfsproc_readlink_2_svc(nfs_fh *, struct svc_req *); 203 extern nfsreadres *nfsproc_read_2(nfsreadargs *, CLIENT *); 204 extern nfsreadres *nfsproc_read_2_svc(nfsreadargs *, struct svc_req *); 205 extern nfsstatfsres *nfsproc_statfs_2(nfs_fh *, CLIENT *); 206 extern nfsstatfsres *nfsproc_statfs_2_svc(nfs_fh *, struct svc_req *); 207 extern void *nfsproc_null_2(void *, CLIENT *); 208 extern void *nfsproc_null_2_svc(void *, struct svc_req *); 209 extern void *nfsproc_root_2(void *, CLIENT *); 210 extern void *nfsproc_root_2_svc(void *, struct svc_req *); 211 extern void *nfsproc_writecache_2(void *, CLIENT *); 212 extern void *nfsproc_writecache_2_svc(void *, struct svc_req *); 213 extern int nfs_program_2_freeresult(SVCXPRT *, xdrproc_t, caddr_t); 214 215 216 /* 217 * ENUMS: 218 */ 219 220 221 /* 222 * STRUCTURES: 223 */ 224 225 struct nfs_fh { 226 char fh_data[NFS_FHSIZE]; 227 }; 228 229 struct nfstime { 230 u_int nt_seconds; 231 u_int nt_useconds; 232 }; 233 234 struct fattr { 235 nfsftype na_type; 236 u_int na_mode; 237 u_int na_nlink; 238 u_int na_uid; 239 u_int na_gid; 240 u_int na_size; 241 u_int na_blocksize; 242 u_int na_rdev; 243 u_int na_blocks; 244 u_int na_fsid; 245 u_int na_fileid; 246 nfstime na_atime; 247 nfstime na_mtime; 248 nfstime na_ctime; 249 }; 250 251 struct sattr { 252 u_int sa_mode; 253 u_int sa_uid; 254 u_int sa_gid; 255 u_int sa_size; 256 nfstime sa_atime; 257 nfstime sa_mtime; 258 }; 259 260 struct attrstat { 261 nfsstat ns_status; 262 union { 263 nfsfattr ns_attr_u; 264 } ns_u; 265 }; 266 267 struct sattrargs { 268 nfs_fh sag_fhandle; 269 nfssattr sag_attributes; 270 }; 271 272 struct diropargs { 273 nfs_fh da_fhandle; /* was dir */ 274 filename da_name; 275 }; 276 277 struct diropokres { 278 nfs_fh drok_fhandle; 279 nfsfattr drok_attributes; 280 }; 281 282 struct diropres { 283 nfsstat dr_status; /* was status */ 284 union { 285 nfsdiropokres dr_drok_u; /* was diropres */ 286 } dr_u; /* was diropres_u */ 287 }; 288 289 struct readlinkres { 290 nfsstat rlr_status; 291 union { 292 nfspath rlr_data_u; 293 } rlr_u; 294 }; 295 296 struct readargs { 297 nfs_fh ra_fhandle; 298 u_int ra_offset; 299 u_int ra_count; 300 u_int ra_totalcount; 301 }; 302 303 struct readokres { 304 nfsfattr raok_attributes; 305 struct { 306 u_int raok_len_u; 307 char *raok_val_u; 308 } raok_u; 309 }; 310 311 struct readres { 312 nfsstat rr_status; 313 union { 314 nfsreadokres rr_reply_u; 315 } rr_u; 316 }; 317 318 struct writeargs { 319 nfs_fh wra_fhandle; 320 u_int wra_beginoffset; 321 u_int wra_offset; 322 u_int wra_totalcount; 323 struct { 324 u_int wra_len_u; 325 char *wra_val_u; 326 } wra_u; 327 }; 328 329 struct createargs { 330 nfsdiropargs ca_where; 331 nfssattr ca_attributes; 332 }; 333 334 struct renameargs { 335 nfsdiropargs rna_from; 336 nfsdiropargs rna_to; 337 }; 338 339 struct linkargs { 340 nfs_fh la_fhandle; 341 nfsdiropargs la_to; 342 }; 343 344 struct symlinkargs { 345 nfsdiropargs sla_from; 346 nfspath sla_to; 347 nfssattr sla_attributes; 348 }; 349 350 struct readdirargs { 351 nfs_fh rda_fhandle; 352 nfscookie rda_cookie; 353 u_int rda_count; 354 }; 355 356 struct entry { 357 u_int ne_fileid; 358 filename ne_name; 359 nfscookie ne_cookie; 360 nfsentry *ne_nextentry; 361 }; 362 363 struct dirlist { 364 nfsentry *dl_entries; 365 bool_t dl_eof; 366 }; 367 368 struct readdirres { 369 nfsstat rdr_status; 370 union { 371 nfsdirlist rdr_reply_u; 372 } rdr_u; 373 }; 374 375 struct statfsokres { 376 u_int sfrok_tsize; 377 u_int sfrok_bsize; 378 u_int sfrok_blocks; 379 u_int sfrok_bfree; 380 u_int sfrok_bavail; 381 }; 382 383 struct statfsres { 384 nfsstat sfr_status; 385 union { 386 nfsstatfsokres sfr_reply_u; 387 } sfr_u; 388 }; 389 390 #endif /* not _AMU_NFS_PROT_H */ 391