1 /* $NetBSD: nfs_prot_osf4.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_osf4.h 39 * 40 */ 41 42 #ifndef _AMU_NFS_PROT_H 43 #define _AMU_NFS_PROT_H 44 45 #ifdef HAVE_RPCSVC_NFS_PROT_H 46 # include <rpcsvc/nfs_prot.h> 47 #endif /* HAVE_RPCSVC_NFS_PROT_H */ 48 #ifdef HAVE_NFS_NFS_H 49 # include <nfs/nfs.h> 50 #endif /* HAVE_NFS_NFS_H */ 51 #ifdef HAVE_RPCSVC_MOUNTV3_H 52 # include <rpcsvc/mountv3.h> 53 #endif /* HAVE_RPCSVC_MOUNTV3_H */ 54 #ifdef HAVE_RPC_RPC_H 55 # include <rpc/rpc.h> 56 #endif /* HAVE_RPC_RPC_H */ 57 58 /* avoid conflicts with Irix's EFS */ 59 #undef MOUNT_EFS /* DCE Episode FS */ 60 61 /* 62 * MACROS 63 */ 64 65 #define NFS_PORT 2049 66 #define NFS_MAXDATA 8192 67 #define NFS_MAXPATHLEN 1024 68 #define NFS_MAXNAMLEN 255 69 #define NFS_FHSIZE 32 70 #define NFS_COOKIESIZE 4 71 #define MNTPATHLEN 1024 72 #define MNTNAMLEN 255 73 74 #define NFSMODE_FMT 0170000 75 #define NFSMODE_DIR 0040000 76 #define NFSMODE_CHR 0020000 77 #define NFSMODE_BLK 0060000 78 #define NFSMODE_REG 0100000 79 #define NFSMODE_LNK 0120000 80 #define NFSMODE_SOCK 0140000 81 #define NFSMODE_FIFO 0010000 82 83 #ifndef NFS_PROGRAM 84 # define NFS_PROGRAM ((u_long)100003) 85 #endif /* not NFS_PROGRAM */ 86 #ifndef NFS_VERSION 87 # define NFS_VERSION ((u_long)2) 88 #endif /* not NFS_VERSION */ 89 90 #define NFSPROC_NULL ((u_long)0) 91 #define NFSPROC_GETATTR ((u_long)1) 92 #define NFSPROC_SETATTR ((u_long)2) 93 #define NFSPROC_ROOT ((u_long)3) 94 #define NFSPROC_LOOKUP ((u_long)4) 95 #define NFSPROC_READLINK ((u_long)5) 96 #define NFSPROC_READ ((u_long)6) 97 #define NFSPROC_WRITECACHE ((u_long)7) 98 #define NFSPROC_WRITE ((u_long)8) 99 #define NFSPROC_CREATE ((u_long)9) 100 #define NFSPROC_REMOVE ((u_long)10) 101 #define NFSPROC_RENAME ((u_long)11) 102 #define NFSPROC_LINK ((u_long)12) 103 #define NFSPROC_SYMLINK ((u_long)13) 104 #define NFSPROC_MKDIR ((u_long)14) 105 #define NFSPROC_RMDIR ((u_long)15) 106 #define NFSPROC_READDIR ((u_long)16) 107 #define NFSPROC_STATFS ((u_long)17) 108 109 /* map field names */ 110 #define ml_hostname ml_name 111 #define ml_directory ml_path 112 #define ml_next ml_nxt 113 #define gr_next g_next 114 #define gr_name g_name 115 #define ex_dir ex_name 116 117 #define drok_attributes drok_attr 118 #define na_fileid na_nodeid 119 #define la_fhandle la_from 120 #define nt_seconds tv_sec 121 #define nt_useconds tv_usec 122 #define ra_totalcount ra_totcount 123 #define sla_to sla_tnm 124 #define sla_attributes sla_sa 125 #define sag_fhandle saa_fh 126 #define sag_attributes saa_sa 127 #define sfrok_tsize fsok_tsize 128 #define sfrok_bsize fsok_bsize 129 #define sfrok_blocks fsok_blocks 130 #define sfrok_bfree fsok_bfree 131 #define sfrok_bavail fsok_bavail 132 #define sfr_status fs_status 133 #define sfr_u fs_u 134 #define sfr_reply_u fs_fsok_u 135 #define wra_fhandle wa_fhandle 136 #define wra_beginoffset wa_begoff 137 #define wra_offset wa_offset 138 #define wra_totalcount wa_totcount 139 #define wra_u wa_mbuf->m_hdr 140 #define wra_val_u mh_data 141 #define wra_len_u mh_len 142 143 144 /* 145 * TYPEDEFS: 146 */ 147 typedef char *dirpath; 148 typedef char *filename; 149 typedef char *name; 150 typedef char *nfspath; 151 typedef char nfscookie[NFS_COOKIESIZE]; 152 typedef enum nfsftype nfsftype; 153 typedef enum nfsstat nfsstat; 154 typedef struct nfssvcfh fhandle; 155 typedef struct nfsattrstat nfsattrstat; 156 typedef struct nfscreateargs nfscreateargs; 157 typedef struct nfsdirlist nfsdirlist; 158 typedef struct nfsdiropargs nfsdiropargs; 159 typedef struct nfsdrok nfsdiropokres; 160 typedef struct nfsdiropres nfsdiropres; 161 typedef struct nfsentry nfsentry; 162 typedef struct exports *exports; 163 typedef struct exports exportnode; 164 typedef struct nfsfattr nfsfattr; 165 typedef struct fhstatus fhstatus; 166 typedef struct groups *groups; 167 typedef struct groups groupnode; 168 typedef struct nfslinkargs nfslinkargs; 169 typedef struct mountlist *mountlist; 170 typedef struct mountlist mountbody; 171 typedef struct _nfs_fh _nfs_fh; 172 typedef struct timeval nfstime; 173 typedef struct nfsreadargs nfsreadargs; 174 typedef struct nfsreaddirargs nfsreaddirargs; 175 typedef struct nfsreaddirres nfsreaddirres; 176 typedef struct nfsreadlinkres nfsreadlinkres; 177 typedef struct nfsreadokres nfsreadokres; 178 typedef struct nfsreadres nfsreadres; 179 typedef struct nfsrenameargs nfsrenameargs; 180 typedef struct nfssattr nfssattr; 181 typedef struct nfssaargs nfssattrargs; 182 typedef struct nfsstatfsok nfsstatfsokres; 183 typedef struct nfsstatfs nfsstatfsres; 184 typedef struct nfsslargs nfssymlinkargs; 185 typedef struct nfswriteargs nfswriteargs; 186 187 188 /* 189 * EXTERNALS: (some are missing from system headers) 190 */ 191 192 extern void *nfsproc_null_2_svc(void *, struct svc_req *); 193 extern nfsattrstat *nfsproc_getattr_2_svc(struct nfssvcfh *, struct svc_req *); 194 extern nfsattrstat *nfsproc_setattr_2_svc(nfssattrargs *, struct svc_req *); 195 extern void *nfsproc_root_2_svc(void *, struct svc_req *); 196 extern nfsdiropres *nfsproc_lookup_2_svc(nfsdiropargs *, struct svc_req *); 197 extern nfsreadlinkres *nfsproc_readlink_2_svc(struct nfssvcfh *, struct svc_req *); 198 extern nfsreadres *nfsproc_read_2_svc(nfsreadargs *, struct svc_req *); 199 extern void *nfsproc_writecache_2_svc(void *, struct svc_req *); 200 extern nfsattrstat *nfsproc_write_2_svc(nfswriteargs *, struct svc_req *); 201 extern nfsdiropres *nfsproc_create_2_svc(nfscreateargs *, struct svc_req *); 202 extern nfsstat *nfsproc_remove_2_svc(nfsdiropargs *, struct svc_req *); 203 extern nfsstat *nfsproc_rename_2_svc(nfsrenameargs *, struct svc_req *); 204 extern nfsstat *nfsproc_link_2_svc(nfslinkargs *, struct svc_req *); 205 extern nfsstat *nfsproc_symlink_2_svc(nfssymlinkargs *, struct svc_req *); 206 extern nfsdiropres *nfsproc_mkdir_2_svc(nfscreateargs *, struct svc_req *); 207 extern nfsstat *nfsproc_rmdir_2_svc(nfsdiropargs *, struct svc_req *); 208 extern nfsreaddirres *nfsproc_readdir_2_svc(nfsreaddirargs *, struct svc_req *); 209 extern nfsstatfsres *nfsproc_statfs_2_svc(struct nfssvcfh *, struct svc_req *); 210 extern int plock(int op); 211 extern const char *hstrerror(int err); 212 extern int getmntinfo(struct statfs **mntbufp, int flags); 213 214 extern bool_t xdr_nfsstat(XDR *, nfsstat*); 215 extern bool_t xdr_ftype(XDR *, nfsftype*); 216 extern bool_t xdr_nfs_fh(XDR *, struct nfssvcfh*); 217 extern bool_t xdr_nfstime(XDR *, nfstime*); 218 extern bool_t xdr_fattr(XDR *, nfsfattr*); 219 extern bool_t xdr_sattr(XDR *, nfssattr*); 220 extern bool_t xdr_filename(XDR *, filename*); 221 extern bool_t xdr_nfspath(XDR *, nfspath*); 222 extern bool_t xdr_attrstat(XDR *, nfsattrstat*); 223 extern bool_t xdr_sattrargs(XDR *, nfssattrargs*); 224 extern bool_t xdr_diropargs(XDR *, nfsdiropargs*); 225 extern bool_t xdr_diropokres(XDR *, nfsdiropokres*); 226 extern bool_t xdr_diropres(XDR *, nfsdiropres*); 227 extern bool_t xdr_readlinkres(XDR *, nfsreadlinkres*); 228 extern bool_t xdr_readargs(XDR *, nfsreadargs*); 229 extern bool_t xdr_readokres(XDR *, nfsreadokres*); 230 extern bool_t xdr_readres(XDR *, nfsreadres*); 231 extern bool_t xdr_writeargs(XDR *, nfswriteargs*); 232 extern bool_t xdr_createargs(XDR *, nfscreateargs*); 233 extern bool_t xdr_renameargs(XDR *, nfsrenameargs*); 234 extern bool_t xdr_linkargs(XDR *, nfslinkargs*); 235 extern bool_t xdr_symlinkargs(XDR *, nfssymlinkargs*); 236 extern bool_t xdr_nfscookie(XDR *, nfscookie); 237 extern bool_t xdr_readdirargs(XDR *, nfsreaddirargs*); 238 extern bool_t xdr_entry(XDR *, nfsentry*); 239 extern bool_t xdr_dirlist(XDR *, nfsdirlist*); 240 extern bool_t xdr_readdirres(XDR *, nfsreaddirres*); 241 extern bool_t xdr_statfsokres(XDR *, nfsstatfsokres*); 242 extern bool_t xdr_statfsres(XDR *, nfsstatfsres*); 243 extern bool_t xdr_exportnode (XDR *, exportnode*); 244 extern bool_t xdr_groups (XDR *, groups*); 245 246 247 248 /* 249 * STRUCTURES: 250 */ 251 252 struct _nfs_fh { 253 char data[NFS_FHSIZE]; 254 }; 255 256 struct nfstime { 257 u_int nt_seconds; 258 u_int nt_useconds; 259 }; 260 261 struct _fattr { 262 nfsftype na_type; 263 u_int na_mode; 264 u_int na_nlink; 265 u_int na_uid; 266 u_int na_gid; 267 u_int na_size; 268 u_int na_blocksize; 269 u_int na_rdev; 270 u_int na_blocks; 271 u_int na_fsid; 272 u_int na_fileid; 273 nfstime na_atime; 274 nfstime na_mtime; 275 nfstime na_ctime; 276 }; 277 278 struct _sattr { 279 u_int sa_mode; 280 u_int sa_uid; 281 u_int sa_gid; 282 u_int sa_size; 283 nfstime sa_atime; 284 nfstime sa_mtime; 285 }; 286 287 struct _attrstat { 288 nfsstat ns_status; 289 union { 290 nfsfattr ns_attr_u; 291 } ns_u; 292 }; 293 294 struct _sattrargs { 295 struct nfssvcfh sag_fhandle; 296 nfssattr sag_attributes; 297 }; 298 299 struct _diropargs { 300 struct nfssvcfh da_fhandle; /* was dir */ 301 filename da_name; 302 }; 303 304 struct _diropokres { 305 struct nfssvcfh drok_fhandle; 306 nfsfattr drok_attributes; 307 }; 308 309 struct _diropres { 310 nfsstat dr_status; /* was status */ 311 union { 312 nfsdiropokres dr_drok_u; /* was diropres */ 313 } dr_u; /* was diropres_u */ 314 }; 315 316 struct nfsreadlinkres { 317 nfsstat rlr_status; 318 union { 319 nfspath rlr_data_u; 320 } rlr_u; 321 }; 322 323 struct _readargs { 324 struct nfssvcfh ra_fhandle; 325 u_int ra_offset; 326 u_int ra_count; 327 u_int ra_totalcount; 328 }; 329 330 struct nfsreadokres { 331 nfsfattr raok_attributes; 332 struct { 333 u_int raok_len_u; 334 char *raok_val_u; 335 } raok_u; 336 }; 337 338 struct nfsreadres { 339 nfsstat rr_status; 340 union { 341 nfsreadokres rr_reply_u; 342 } rr_u; 343 }; 344 345 #if 0 346 struct _writeargs { 347 struct nfssvcfh wra_fhandle; 348 u_int wra_beginoffset; 349 u_int wra_offset; 350 u_int wra_totalcount; 351 struct { 352 u_int wra_len_u; 353 char *wra_val_u; 354 } wra_u; 355 }; 356 #endif /* 0 */ 357 358 struct nfscreateargs { 359 nfsdiropargs ca_where; 360 nfssattr ca_attributes; 361 }; 362 363 struct nfsrenameargs { 364 nfsdiropargs rna_from; 365 nfsdiropargs rna_to; 366 }; 367 368 struct _linkargs { 369 struct nfssvcfh la_fhandle; 370 nfsdiropargs la_to; 371 }; 372 373 struct _symlinkargs { 374 nfsdiropargs sla_from; 375 nfspath sla_to; 376 nfssattr sla_attributes; 377 }; 378 379 struct nfsreaddirargs { 380 struct nfssvcfh rda_fhandle; 381 nfscookie rda_cookie; 382 u_int rda_count; 383 }; 384 385 struct nfsentry { 386 u_int ne_fileid; 387 filename ne_name; 388 nfscookie ne_cookie; 389 nfsentry *ne_nextentry; 390 }; 391 392 struct nfsdirlist { 393 nfsentry *dl_entries; 394 bool_t dl_eof; 395 }; 396 397 struct nfsreaddirres { 398 nfsstat rdr_status; 399 union { 400 nfsdirlist rdr_reply_u; 401 } rdr_u; 402 }; 403 404 struct _statfsokres { 405 u_int sfrok_tsize; 406 u_int sfrok_bsize; 407 u_int sfrok_blocks; 408 u_int sfrok_bfree; 409 u_int sfrok_bavail; 410 }; 411 412 struct _statfsres { 413 nfsstat sfr_status; 414 union { 415 nfsstatfsokres sfr_reply_u; 416 } sfr_u; 417 }; 418 419 #endif /* not _AMU_NFS_PROT_H */ 420