1 /* $NetBSD: nfs_prot_sunos3.h,v 1.1.1.3 2015/01/17 16:34:16 christos Exp $ */ 2 3 /* 4 * Copyright (c) 1997-2014 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. Neither the name of the University nor the names of its contributors 22 * may be used to endorse or promote products derived from this software 23 * without specific prior written permission. 24 * 25 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 26 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 27 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 28 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 29 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 30 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 31 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 32 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 33 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 34 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 35 * SUCH DAMAGE. 36 * 37 * 38 * File: am-utils/conf/nfs_prot/nfs_prot_sunos3.h 39 * 40 */ 41 42 #ifndef _AMU_NFS_PROT_H 43 #define _AMU_NFS_PROT_H 44 45 #ifdef HAVE_SYS_ERRNO_H 46 #include <sys/errno.h> 47 #endif /* HAVE_SYS_ERRNO_H */ 48 #ifdef HAVE_RPC_RPC_H 49 #include <rpc/rpc.h> 50 #endif /* HAVE_RPC_RPC_H */ 51 #ifdef HAVE_NFS_NFSV2_H 52 # include <nfs/nfsv2.h> 53 #endif /* HAVE_NFS_NFSV2_H */ 54 #ifdef HAVE_NFS_RPCV2_H 55 # include <nfs/rpcv2.h> 56 #endif /* HAVE_NFS_RPCV2_H */ 57 #ifdef HAVE_NFS_NFS_H 58 # include <nfs/nfs.h> 59 #endif /* HAVE_NFS_NFS_H */ 60 # ifdef HAVE_NFS_NFS_CLNT_H 61 # include <nfs/nfs_clnt.h> 62 # endif /* HAVE_NFS_NFS_CLNT_H */ 63 #ifdef HAVE_SYS_FS_NFS_H 64 # include <sys/fs/nfs.h> 65 #endif /* HAVE_SYS_FS_NFS_H */ 66 #ifdef HAVE_RPCSVC_MOUNT_H 67 # include <rpcsvc/mount.h> 68 #endif /* HAVE_RPCSVC_MOUNT_H */ 69 70 71 /* 72 * MACROS 73 */ 74 75 #define NFS_PORT 2049 76 #define NFS_MAXDATA 8192 77 #define NFS_MAXPATHLEN 1024 78 #define NFS_MAXNAMLEN 255 79 #define NFS_FHSIZE 32 80 #define NFS_COOKIESIZE 4 81 #define MNTPATHLEN 1024 82 #define MNTNAMLEN 255 83 84 #define NFSMODE_FMT 0170000 85 #define NFSMODE_DIR 0040000 86 #define NFSMODE_CHR 0020000 87 #define NFSMODE_BLK 0060000 88 #define NFSMODE_REG 0100000 89 #define NFSMODE_LNK 0120000 90 #define NFSMODE_SOCK 0140000 91 #define NFSMODE_FIFO 0010000 92 93 #ifndef NFS_PROGRAM 94 # define NFS_PROGRAM ((u_long)100003) 95 #endif /* not NFS_PROGRAM */ 96 #ifndef NFS_VERSION 97 # define NFS_VERSION ((u_long)2) 98 #endif /* not NFS_VERSION */ 99 100 /* complete missing definition that is actually used in SunOS 3.x */ 101 #ifndef MNTOPT_DEV 102 # define MNTOPT_DEV "dev" 103 #endif /* not MNTOPT_DEV */ 104 105 #define NFSPROC_NULL ((u_long)0) 106 #define NFSPROC_GETATTR ((u_long)1) 107 #define NFSPROC_SETATTR ((u_long)2) 108 #define NFSPROC_ROOT ((u_long)3) 109 #define NFSPROC_LOOKUP ((u_long)4) 110 #define NFSPROC_READLINK ((u_long)5) 111 #define NFSPROC_READ ((u_long)6) 112 #define NFSPROC_WRITECACHE ((u_long)7) 113 #define NFSPROC_WRITE ((u_long)8) 114 #define NFSPROC_CREATE ((u_long)9) 115 #define NFSPROC_REMOVE ((u_long)10) 116 #define NFSPROC_RENAME ((u_long)11) 117 #define NFSPROC_LINK ((u_long)12) 118 #define NFSPROC_SYMLINK ((u_long)13) 119 #define NFSPROC_MKDIR ((u_long)14) 120 #define NFSPROC_RMDIR ((u_long)15) 121 #define NFSPROC_READDIR ((u_long)16) 122 #define NFSPROC_STATFS ((u_long)17) 123 124 /* map field names */ 125 #define ml_hostname ml_name 126 #define ml_directory ml_path 127 #define ml_next ml_nxt 128 #define gr_next g_next 129 #define gr_name g_name 130 #define ex_dir ex_name 131 #define na_fileid na_nodeid 132 #define la_fhandle la_from 133 #define ra_totalcount ra_totcount 134 135 136 /* 137 * TYPEDEFS: 138 */ 139 typedef char *dirpath; 140 typedef char *filename; 141 typedef char *name; 142 typedef char *nfspath; 143 typedef char nfscookie[NFS_COOKIESIZE]; 144 typedef enum nfsftype nfsftype; 145 typedef enum nfsstat nfsstat; 146 typedef char fhandle[NFS_FHSIZE]; 147 typedef struct attrstat nfsattrstat; 148 typedef struct nfscreateargs nfscreateargs; 149 typedef struct nfsdirlist nfsdirlist; 150 typedef struct nfsdiropargs nfsdiropargs; 151 typedef struct nfsdiropokres nfsdiropokres; 152 typedef struct diropres nfsdiropres; 153 typedef struct nfsentry nfsentry; 154 typedef struct exports *exports; 155 typedef struct exports exportnode; 156 typedef struct fattr nfsfattr; 157 typedef struct nfsfhstatus fhstatus; 158 typedef struct groups *groups; 159 typedef struct groups groupnode; 160 typedef struct nfslinkargs nfslinkargs; 161 typedef struct mountlist *mountlist; 162 typedef struct mountlist mountbody; 163 typedef struct nfstime nfstime; 164 typedef struct nfsreadargs nfsreadargs; 165 typedef struct nfsreaddirargs nfsreaddirargs; 166 typedef struct nfsreaddirres nfsreaddirres; 167 typedef struct nfsreadlinkres nfsreadlinkres; 168 typedef struct nfsreadokres nfsreadokres; 169 typedef struct nfsreadres nfsreadres; 170 typedef struct nfsrenameargs nfsrenameargs; 171 typedef struct sattr nfssattr; 172 typedef struct nfssattrargs nfssattrargs; 173 typedef struct nfsstatfsokres nfsstatfsokres; 174 typedef struct nfsstatfsres nfsstatfsres; 175 typedef struct nfssymlinkargs nfssymlinkargs; 176 typedef struct writeargs nfswriteargs; 177 178 179 /* 180 * EXTERNALS: 181 */ 182 183 extern void *nfsproc_null_2_svc(void *, struct svc_req *); 184 extern nfsattrstat *nfsproc_getattr_2_svc(fhandle_t *, struct svc_req *); 185 extern nfsattrstat *nfsproc_setattr_2_svc(nfssattrargs *, struct svc_req *); 186 extern void *nfsproc_root_2_svc(void *, struct svc_req *); 187 extern nfsdiropres *nfsproc_lookup_2_svc(nfsdiropargs *, struct svc_req *); 188 extern nfsreadlinkres *nfsproc_readlink_2_svc(fhandle_t *, struct svc_req *); 189 extern nfsreadres *nfsproc_read_2_svc(nfsreadargs *, struct svc_req *); 190 extern void *nfsproc_writecache_2_svc(void *, struct svc_req *); 191 extern nfsattrstat *nfsproc_write_2_svc(nfswriteargs *, struct svc_req *); 192 extern nfsdiropres *nfsproc_create_2_svc(nfscreateargs *, struct svc_req *); 193 extern nfsstat *nfsproc_remove_2_svc(nfsdiropargs *, struct svc_req *); 194 extern nfsstat *nfsproc_rename_2_svc(nfsrenameargs *, struct svc_req *); 195 extern nfsstat *nfsproc_link_2_svc(nfslinkargs *, struct svc_req *); 196 extern nfsstat *nfsproc_symlink_2_svc(nfssymlinkargs *, struct svc_req *); 197 extern nfsdiropres *nfsproc_mkdir_2_svc(nfscreateargs *, struct svc_req *); 198 extern nfsstat *nfsproc_rmdir_2_svc(nfsdiropargs *, struct svc_req *); 199 extern nfsreaddirres *nfsproc_readdir_2_svc(nfsreaddirargs *, struct svc_req *); 200 extern nfsstatfsres *nfsproc_statfs_2_svc(fhandle_t *, struct svc_req *); 201 202 extern bool_t xdr_nfsstat(XDR *, nfsstat*); 203 extern bool_t xdr_ftype(XDR *, nfsftype*); 204 extern bool_t xdr_nfs_fh(XDR *, fhandle_t*); 205 extern bool_t xdr_nfstime(XDR *, nfstime*); 206 extern bool_t xdr_fattr(XDR *, nfsfattr*); 207 extern bool_t xdr_sattr(XDR *, nfssattr*); 208 extern bool_t xdr_filename(XDR *, filename*); 209 extern bool_t xdr_nfspath(XDR *, nfspath*); 210 extern bool_t xdr_attrstat(XDR *, nfsattrstat*); 211 extern bool_t xdr_sattrargs(XDR *, nfssattrargs*); 212 extern bool_t xdr_diropargs(XDR *, nfsdiropargs*); 213 extern bool_t xdr_diropokres(XDR *, nfsdiropokres*); 214 extern bool_t xdr_diropres(XDR *, nfsdiropres*); 215 extern bool_t xdr_readlinkres(XDR *, nfsreadlinkres*); 216 extern bool_t xdr_readargs(XDR *, nfsreadargs*); 217 extern bool_t xdr_readokres(XDR *, nfsreadokres*); 218 extern bool_t xdr_readres(XDR *, nfsreadres*); 219 extern bool_t xdr_writeargs(XDR *, nfswriteargs*); 220 extern bool_t xdr_createargs(XDR *, nfscreateargs*); 221 extern bool_t xdr_renameargs(XDR *, nfsrenameargs*); 222 extern bool_t xdr_linkargs(XDR *, nfslinkargs*); 223 extern bool_t xdr_symlinkargs(XDR *, nfssymlinkargs*); 224 extern bool_t xdr_nfscookie(XDR *, nfscookie); 225 extern bool_t xdr_readdirargs(XDR *, nfsreaddirargs*); 226 extern bool_t xdr_entry(XDR *, nfsentry*); 227 extern bool_t xdr_dirlist(XDR *, nfsdirlist*); 228 extern bool_t xdr_readdirres(XDR *, nfsreaddirres*); 229 extern bool_t xdr_statfsokres(XDR *, nfsstatfsokres*); 230 extern bool_t xdr_statfsres(XDR *, nfsstatfsres*); 231 232 233 /* 234 * STRUCTURES: 235 */ 236 237 struct nfstime { 238 u_int nt_seconds; 239 u_int nt_useconds; 240 }; 241 242 struct fattr { 243 nfsftype na_type; 244 u_int na_mode; 245 u_int na_nlink; 246 u_int na_uid; 247 u_int na_gid; 248 u_int na_size; 249 u_int na_blocksize; 250 u_int na_rdev; 251 u_int na_blocks; 252 u_int na_fsid; 253 u_int na_fileid; 254 nfstime na_atime; 255 nfstime na_mtime; 256 nfstime na_ctime; 257 }; 258 259 struct sattr { 260 u_int sa_mode; 261 u_int sa_uid; 262 u_int sa_gid; 263 u_int sa_size; 264 nfstime sa_atime; 265 nfstime sa_mtime; 266 }; 267 268 struct attrstat { 269 nfsstat ns_status; 270 union { 271 nfsfattr ns_attr_u; 272 } ns_u; 273 }; 274 275 struct nfssattrargs { 276 fhandle_t sag_fhandle; 277 nfssattr sag_attributes; 278 }; 279 280 struct _nfsdiropargs { 281 fhandle_t da_fhandle; /* was dir */ 282 filename da_name; 283 }; 284 285 struct nfsdiropokres { 286 fhandle_t drok_fhandle; 287 nfsfattr drok_attributes; 288 }; 289 290 struct diropres { 291 nfsstat dr_status; /* was status */ 292 union { 293 nfsdiropokres dr_drok_u; /* was diropres */ 294 } dr_u; /* was diropres_u */ 295 }; 296 297 struct nfsreadlinkres { 298 nfsstat rlr_status; 299 union { 300 nfspath rlr_data_u; 301 } rlr_u; 302 }; 303 304 struct _nfsreadargs { 305 fhandle_t ra_fhandle; 306 u_int ra_offset; 307 u_int ra_count; 308 u_int ra_totalcount; 309 }; 310 311 struct nfsreadokres { 312 nfsfattr raok_attributes; 313 struct { 314 u_int raok_len_u; 315 char *raok_val_u; 316 } raok_u; 317 }; 318 319 struct nfsreadres { 320 nfsstat rr_status; 321 union { 322 nfsreadokres rr_reply_u; 323 } rr_u; 324 }; 325 326 struct writeargs { 327 fhandle_t wra_fhandle; 328 u_int wra_beginoffset; 329 u_int wra_offset; 330 u_int wra_totalcount; 331 struct { 332 u_int wra_len_u; 333 char *wra_val_u; 334 } wra_u; 335 }; 336 337 struct nfscreateargs { 338 nfsdiropargs ca_where; 339 nfssattr ca_attributes; 340 }; 341 342 struct nfsrenameargs { 343 nfsdiropargs rna_from; 344 nfsdiropargs rna_to; 345 }; 346 347 struct _nfslinkargs { 348 fhandle_t la_fhandle; 349 nfsdiropargs la_to; 350 }; 351 352 struct nfssymlinkargs { 353 nfsdiropargs sla_from; 354 nfspath sla_to; 355 nfssattr sla_attributes; 356 }; 357 358 struct nfsreaddirargs { 359 fhandle_t rda_fhandle; 360 nfscookie rda_cookie; 361 u_int rda_count; 362 }; 363 364 struct nfsentry { 365 u_int ne_fileid; 366 filename ne_name; 367 nfscookie ne_cookie; 368 nfsentry *ne_nextentry; 369 }; 370 371 struct nfsdirlist { 372 nfsentry *dl_entries; 373 bool_t dl_eof; 374 }; 375 376 struct nfsreaddirres { 377 nfsstat rdr_status; 378 union { 379 nfsdirlist rdr_reply_u; 380 } rdr_u; 381 }; 382 383 struct nfsstatfsokres { 384 u_int sfrok_tsize; 385 u_int sfrok_bsize; 386 u_int sfrok_blocks; 387 u_int sfrok_bfree; 388 u_int sfrok_bavail; 389 }; 390 391 struct nfsstatfsres { 392 nfsstat sfr_status; 393 union { 394 nfsstatfsokres sfr_reply_u; 395 } sfr_u; 396 }; 397 398 struct nfsfhstatus { 399 int fhs_status; 400 fhandle fhs_fh; 401 }; 402 403 #endif /* not _AMU_NFS_PROT_H */ 404