1 /* $NetBSD: nfs_prot_hpux.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_hpux.h 39 * 40 */ 41 42 #ifndef _AMU_NFS_PROT_H 43 #define _AMU_NFS_PROT_H 44 45 #ifdef HAVE_NFS_EXPORT_H_not 46 /* don't include this b/c it'll get included twice */ 47 # include <nfs/export.h> 48 #endif /* HAVE_NFS_EXPORT_H */ 49 #ifdef HAVE_NFS_NFSV2_H 50 # include <nfs/nfsv2.h> 51 #endif /* HAVE_NFS_NFSV2_H */ 52 #ifdef HAVE_NFS_RPCV2_H 53 # include <nfs/rpcv2.h> 54 #endif /* HAVE_NFS_RPCV2_H */ 55 #ifdef HAVE_NFS_NFS_H 56 # include <nfs/nfs.h> 57 #endif /* HAVE_NFS_NFS_H */ 58 #ifdef HAVE_SYS_FS_NFS_H 59 # include <sys/fs/nfs.h> 60 #endif /* HAVE_SYS_FS_NFS_H */ 61 #ifdef HAVE_RPCSVC_MOUNT_H 62 # include <rpcsvc/mount.h> 63 #endif /* HAVE_RPCSVC_MOUNT_H */ 64 65 #ifdef HAVE_NETDB_H 66 extern int h_errno; /* missing from older hpux10 systems */ 67 #endif /* HAVE_NETDB_H */ 68 69 70 /* 71 * Turn off NFS V.3 support to avoid confusing am-utils. 72 * 10.20 with some patches has incomplete support. 73 */ 74 #undef MNTTYPE_NFS3 75 #undef MNTTAB_TYPE_NFS3 76 #undef HAVE_FS_NFS3 77 78 79 /* 80 * MACROS 81 */ 82 83 #define NFS_PORT 2049 84 #define NFS_MAXDATA 8192 85 #define NFS_MAXPATHLEN 1024 86 #define NFS_MAXNAMLEN 255 87 #define NFS_FHSIZE 32 88 #define NFS_COOKIESIZE 4 89 #define MNTPATHLEN 1024 90 #define MNTNAMLEN 255 91 92 #define NFSMODE_FMT 0170000 93 #define NFSMODE_DIR 0040000 94 #define NFSMODE_CHR 0020000 95 #define NFSMODE_BLK 0060000 96 #define NFSMODE_REG 0100000 97 #define NFSMODE_LNK 0120000 98 #define NFSMODE_SOCK 0140000 99 #define NFSMODE_FIFO 0010000 100 101 #ifndef NFS_PROGRAM 102 # define NFS_PROGRAM ((u_long)100003) 103 #endif /* not NFS_PROGRAM */ 104 #ifndef NFS_VERSION 105 # define NFS_VERSION ((u_long)2) 106 #endif /* not NFS_VERSION */ 107 108 #define NFSPROC_NULL ((u_long)0) 109 #define NFSPROC_GETATTR ((u_long)1) 110 #define NFSPROC_SETATTR ((u_long)2) 111 #define NFSPROC_ROOT ((u_long)3) 112 #define NFSPROC_LOOKUP ((u_long)4) 113 #define NFSPROC_READLINK ((u_long)5) 114 #define NFSPROC_READ ((u_long)6) 115 #define NFSPROC_WRITECACHE ((u_long)7) 116 #define NFSPROC_WRITE ((u_long)8) 117 #define NFSPROC_CREATE ((u_long)9) 118 #define NFSPROC_REMOVE ((u_long)10) 119 #define NFSPROC_RENAME ((u_long)11) 120 #define NFSPROC_LINK ((u_long)12) 121 #define NFSPROC_SYMLINK ((u_long)13) 122 #define NFSPROC_MKDIR ((u_long)14) 123 #define NFSPROC_RMDIR ((u_long)15) 124 #define NFSPROC_READDIR ((u_long)16) 125 #define NFSPROC_STATFS ((u_long)17) 126 127 /* map field names */ 128 #define ml_hostname ml_name 129 #define ml_directory ml_path 130 #define ml_next ml_nxt 131 #define gr_next g_next 132 #define gr_name g_name 133 #define ex_dir ex_name 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 #ifndef HAVE_FHANDLE 147 typedef fhandle_t fhandle; 148 #endif /* not HAVE_FHANDLE */ 149 typedef struct attrstat nfsattrstat; 150 typedef struct createargs nfscreateargs; 151 typedef struct dirlist nfsdirlist; 152 typedef struct diropargs nfsdiropargs; 153 typedef struct diropokres nfsdiropokres; 154 typedef struct diropres nfsdiropres; 155 typedef struct entry nfsentry; 156 typedef struct exports *exports; 157 typedef struct exports exportnode; 158 typedef struct fattr nfsfattr; 159 typedef struct fhstatus fhstatus; 160 typedef struct groups *groups; 161 typedef struct groups groupnode; 162 typedef struct linkargs nfslinkargs; 163 typedef struct mountlist *mountlist; 164 typedef struct mountlist mountbody; 165 typedef struct nfstime nfstime; 166 typedef struct readargs nfsreadargs; 167 typedef struct readdirargs nfsreaddirargs; 168 typedef struct readdirres nfsreaddirres; 169 typedef struct readlinkres nfsreadlinkres; 170 typedef struct readokres nfsreadokres; 171 typedef struct readres nfsreadres; 172 typedef struct renameargs nfsrenameargs; 173 typedef struct sattr nfssattr; 174 typedef struct sattrargs nfssattrargs; 175 typedef struct statfsokres nfsstatfsokres; 176 typedef struct statfsres nfsstatfsres; 177 typedef struct symlinkargs nfssymlinkargs; 178 typedef struct writeargs nfswriteargs; 179 180 181 /* 182 * EXTERNALS: 183 */ 184 185 extern void *nfsproc_null_2_svc(void *, struct svc_req *); 186 extern nfsattrstat *nfsproc_getattr_2_svc(fhandle_t *, struct svc_req *); 187 extern nfsattrstat *nfsproc_setattr_2_svc(nfssattrargs *, struct svc_req *); 188 extern void *nfsproc_root_2_svc(void *, struct svc_req *); 189 extern nfsdiropres *nfsproc_lookup_2_svc(nfsdiropargs *, struct svc_req *); 190 extern nfsreadlinkres *nfsproc_readlink_2_svc(fhandle_t *, struct svc_req *); 191 extern nfsreadres *nfsproc_read_2_svc(nfsreadargs *, struct svc_req *); 192 extern void *nfsproc_writecache_2_svc(void *, struct svc_req *); 193 extern nfsattrstat *nfsproc_write_2_svc(nfswriteargs *, struct svc_req *); 194 extern nfsdiropres *nfsproc_create_2_svc(nfscreateargs *, struct svc_req *); 195 extern nfsstat *nfsproc_remove_2_svc(nfsdiropargs *, struct svc_req *); 196 extern nfsstat *nfsproc_rename_2_svc(nfsrenameargs *, struct svc_req *); 197 extern nfsstat *nfsproc_link_2_svc(nfslinkargs *, struct svc_req *); 198 extern nfsstat *nfsproc_symlink_2_svc(nfssymlinkargs *, struct svc_req *); 199 extern nfsdiropres *nfsproc_mkdir_2_svc(nfscreateargs *, struct svc_req *); 200 extern nfsstat *nfsproc_rmdir_2_svc(nfsdiropargs *, struct svc_req *); 201 extern nfsreaddirres *nfsproc_readdir_2_svc(nfsreaddirargs *, struct svc_req *); 202 extern nfsstatfsres *nfsproc_statfs_2_svc(fhandle_t *, struct svc_req *); 203 204 extern bool_t xdr_nfsstat(XDR *, nfsstat*); 205 extern bool_t xdr_ftype(XDR *, nfsftype*); 206 extern bool_t xdr_nfs_fh(XDR *, fhandle_t*); 207 extern bool_t xdr_nfstime(XDR *, nfstime*); 208 extern bool_t xdr_fattr(XDR *, nfsfattr*); 209 extern bool_t xdr_sattr(XDR *, nfssattr*); 210 extern bool_t xdr_filename(XDR *, filename*); 211 extern bool_t xdr_nfspath(XDR *, nfspath*); 212 extern bool_t xdr_attrstat(XDR *, nfsattrstat*); 213 extern bool_t xdr_sattrargs(XDR *, nfssattrargs*); 214 extern bool_t xdr_diropargs(XDR *, nfsdiropargs*); 215 extern bool_t xdr_diropokres(XDR *, nfsdiropokres*); 216 extern bool_t xdr_diropres(XDR *, nfsdiropres*); 217 extern bool_t xdr_readlinkres(XDR *, nfsreadlinkres*); 218 extern bool_t xdr_readargs(XDR *, nfsreadargs*); 219 extern bool_t xdr_readokres(XDR *, nfsreadokres*); 220 extern bool_t xdr_readres(XDR *, nfsreadres*); 221 extern bool_t xdr_writeargs(XDR *, nfswriteargs*); 222 extern bool_t xdr_createargs(XDR *, nfscreateargs*); 223 extern bool_t xdr_renameargs(XDR *, nfsrenameargs*); 224 extern bool_t xdr_linkargs(XDR *, nfslinkargs*); 225 extern bool_t xdr_symlinkargs(XDR *, nfssymlinkargs*); 226 extern bool_t xdr_nfscookie(XDR *, nfscookie); 227 extern bool_t xdr_readdirargs(XDR *, nfsreaddirargs*); 228 extern bool_t xdr_entry(XDR *, nfsentry*); 229 extern bool_t xdr_dirlist(XDR *, nfsdirlist*); 230 extern bool_t xdr_readdirres(XDR *, nfsreaddirres*); 231 extern bool_t xdr_statfsokres(XDR *, nfsstatfsokres*); 232 extern bool_t xdr_statfsres(XDR *, nfsstatfsres*); 233 234 235 /* 236 * STRUCTURES: 237 */ 238 239 struct nfstime { 240 u_int nt_seconds; 241 u_int nt_useconds; 242 }; 243 244 struct fattr { 245 nfsftype na_type; 246 u_int na_mode; 247 u_int na_nlink; 248 u_int na_uid; 249 u_int na_gid; 250 u_int na_size; 251 u_int na_blocksize; 252 u_int na_rdev; 253 u_int na_blocks; 254 u_int na_fsid; 255 u_int na_fileid; 256 nfstime na_atime; 257 nfstime na_mtime; 258 nfstime na_ctime; 259 }; 260 261 struct sattr { 262 u_int sa_mode; 263 u_int sa_uid; 264 u_int sa_gid; 265 u_int sa_size; 266 nfstime sa_atime; 267 nfstime sa_mtime; 268 }; 269 270 struct attrstat { 271 nfsstat ns_status; 272 union { 273 nfsfattr ns_attr_u; 274 } ns_u; 275 }; 276 277 struct sattrargs { 278 fhandle_t sag_fhandle; 279 nfssattr sag_attributes; 280 }; 281 282 struct diropargs { 283 fhandle_t da_fhandle; /* was dir */ 284 filename da_name; 285 }; 286 287 struct diropokres { 288 fhandle_t drok_fhandle; 289 nfsfattr drok_attributes; 290 }; 291 292 struct diropres { 293 nfsstat dr_status; /* was status */ 294 union { 295 nfsdiropokres dr_drok_u; /* was diropres */ 296 } dr_u; /* was diropres_u */ 297 }; 298 299 struct readlinkres { 300 nfsstat rlr_status; 301 union { 302 nfspath rlr_data_u; 303 } rlr_u; 304 }; 305 306 struct readargs { 307 fhandle_t ra_fhandle; 308 u_int ra_offset; 309 u_int ra_count; 310 u_int ra_totalcount; 311 }; 312 313 struct readokres { 314 nfsfattr raok_attributes; 315 struct { 316 u_int raok_len_u; 317 char *raok_val_u; 318 } raok_u; 319 }; 320 321 struct readres { 322 nfsstat rr_status; 323 union { 324 nfsreadokres rr_reply_u; 325 } rr_u; 326 }; 327 328 struct writeargs { 329 fhandle_t wra_fhandle; 330 u_int wra_beginoffset; 331 u_int wra_offset; 332 u_int wra_totalcount; 333 struct { 334 u_int wra_len_u; 335 char *wra_val_u; 336 } wra_u; 337 }; 338 339 struct createargs { 340 nfsdiropargs ca_where; 341 nfssattr ca_attributes; 342 }; 343 344 struct renameargs { 345 nfsdiropargs rna_from; 346 nfsdiropargs rna_to; 347 }; 348 349 struct linkargs { 350 fhandle_t la_fhandle; 351 nfsdiropargs la_to; 352 }; 353 354 struct symlinkargs { 355 nfsdiropargs sla_from; 356 nfspath sla_to; 357 nfssattr sla_attributes; 358 }; 359 360 struct readdirargs { 361 fhandle_t rda_fhandle; 362 nfscookie rda_cookie; 363 u_int rda_count; 364 }; 365 366 struct entry { 367 u_int ne_fileid; 368 filename ne_name; 369 nfscookie ne_cookie; 370 nfsentry *ne_nextentry; 371 }; 372 373 struct dirlist { 374 nfsentry *dl_entries; 375 bool_t dl_eof; 376 }; 377 378 struct readdirres { 379 nfsstat rdr_status; 380 union { 381 nfsdirlist rdr_reply_u; 382 } rdr_u; 383 }; 384 385 struct statfsokres { 386 u_int sfrok_tsize; 387 u_int sfrok_bsize; 388 u_int sfrok_blocks; 389 u_int sfrok_bfree; 390 u_int sfrok_bavail; 391 }; 392 393 struct statfsres { 394 nfsstat sfr_status; 395 union { 396 nfsstatfsokres sfr_reply_u; 397 } sfr_u; 398 }; 399 400 #endif /* not _AMU_NFS_PROT_H */ 401