1 /* $OpenBSD: nfs_prot.h,v 1.4 2003/06/02 23:36:52 millert Exp $ */ 2 3 /* 4 * Copyright (c) 1990 Jan-Simon Pendry 5 * Copyright (c) 1990 Imperial College of Science, Technology & Medicine 6 * Copyright (c) 1990, 1993 7 * The Regents of the University of California. All rights reserved. 8 * 9 * This code is derived from software contributed to Berkeley by 10 * Jan-Simon Pendry at Imperial College, London. 11 * 12 * Redistribution and use in source and binary forms, with or without 13 * modification, are permitted provided that the following conditions 14 * are met: 15 * 1. Redistributions of source code must retain the above copyright 16 * notice, this list of conditions and the following disclaimer. 17 * 2. Redistributions in binary form must reproduce the above copyright 18 * notice, this list of conditions and the following disclaimer in the 19 * documentation and/or other materials provided with the distribution. 20 * 3. Neither the name of the University nor the names of its contributors 21 * may be used to endorse or promote products derived from this software 22 * without specific prior written permission. 23 * 24 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 25 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 26 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 27 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 28 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 30 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 31 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 32 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 33 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 34 * SUCH DAMAGE. 35 * 36 * from: @(#)nfs_prot.h 8.1 (Berkeley) 6/6/93 37 */ 38 39 #if NFS_PROTOCOL_VERSION >= 3 40 #include <nfs/nfsproto.h> 41 #endif 42 43 #define xdr_nfsstat xdr_enum 44 #define xdr_ftype xdr_enum 45 46 #define NFS_PORT 2049 47 #ifndef NFS_MAXDATA 48 #define NFS_MAXDATA 8192 49 #endif 50 #define NFS_MAXPATHLEN 1024 51 #define NFS_MAXNAMLEN 255 52 #define NFS_FHSIZE 32 53 #define NFS_COOKIESIZE 4 54 #define NFS_FIFO_DEV -1 55 #define NFSMODE_FMT 0170000 56 #define NFSMODE_DIR 0040000 57 #define NFSMODE_CHR 0020000 58 #define NFSMODE_BLK 0060000 59 #define NFSMODE_REG 0100000 60 #define NFSMODE_LNK 0120000 61 #define NFSMODE_SOCK 0140000 62 #define NFSMODE_FIFO 0010000 63 64 #if NFS_PROTOCOL_VERSION < 3 65 enum nfsstat { 66 NFS_OK = 0, 67 NFSERR_PERM = 1, 68 NFSERR_NOENT = 2, 69 NFSERR_IO = 5, 70 NFSERR_NXIO = 6, 71 NFSERR_ACCES = 13, 72 NFSERR_EXIST = 17, 73 NFSERR_NODEV = 19, 74 NFSERR_NOTDIR = 20, 75 NFSERR_ISDIR = 21, 76 NFSERR_FBIG = 27, 77 NFSERR_NOSPC = 28, 78 NFSERR_ROFS = 30, 79 NFSERR_NAMETOOLONG = 63, 80 NFSERR_NOTEMPTY = 66, 81 NFSERR_DQUOT = 69, 82 NFSERR_STALE = 70, 83 NFSERR_WFLUSH = 99 84 }; 85 typedef enum nfsstat nfsstat; 86 #else 87 typedef int nfsstat; 88 #endif 89 90 bool_t xdr_nfsstat(); 91 92 93 #if NFS_PROTOCOL_VERSION < 3 94 enum ftype { 95 NFNON = 0, 96 NFREG = 1, 97 NFDIR = 2, 98 NFBLK = 3, 99 NFCHR = 4, 100 NFLNK = 5, 101 NFSOCK = 6, 102 NFBAD = 7, 103 NFFIFO = 8 104 }; 105 typedef enum ftype ftype; 106 #else 107 typedef int ftype; 108 #endif 109 110 /* static bool_t xdr_ftype(); */ 111 112 113 struct nfs_fh { 114 char data[NFS_FHSIZE]; 115 }; 116 typedef struct nfs_fh nfs_fh; 117 bool_t xdr_nfs_fh(); 118 119 120 struct nfstime { 121 u_int seconds; 122 u_int useconds; 123 }; 124 typedef struct nfstime nfstime; 125 /* static bool_t xdr_nfstime(); */ 126 127 128 struct fattr { 129 ftype type; 130 u_int mode; 131 u_int nlink; 132 u_int uid; 133 u_int gid; 134 u_int size; 135 u_int blocksize; 136 u_int rdev; 137 u_int blocks; 138 u_int fsid; 139 u_int fileid; 140 nfstime atime; 141 nfstime mtime; 142 nfstime ctime; 143 }; 144 typedef struct fattr fattr; 145 /* static bool_t xdr_fattr(); */ 146 147 148 struct sattr { 149 u_int mode; 150 u_int uid; 151 u_int gid; 152 u_int size; 153 nfstime atime; 154 nfstime mtime; 155 }; 156 typedef struct sattr sattr; 157 /* static bool_t xdr_sattr(); */ 158 159 160 typedef char *filename; 161 /* static bool_t xdr_filename(); */ 162 163 164 typedef char *nfspath; 165 bool_t xdr_nfspath(); 166 167 168 struct attrstat { 169 nfsstat status; 170 union { 171 fattr attributes; 172 } attrstat_u; 173 }; 174 typedef struct attrstat attrstat; 175 bool_t xdr_attrstat(); 176 177 178 struct sattrargs { 179 nfs_fh file; 180 sattr attributes; 181 }; 182 typedef struct sattrargs sattrargs; 183 bool_t xdr_sattrargs(); 184 185 186 struct diropargs { 187 nfs_fh dir; 188 filename name; 189 }; 190 typedef struct diropargs diropargs; 191 bool_t xdr_diropargs(); 192 193 194 struct diropokres { 195 nfs_fh file; 196 fattr attributes; 197 }; 198 typedef struct diropokres diropokres; 199 bool_t xdr_diropokres(); 200 201 202 struct diropres { 203 nfsstat status; 204 union { 205 diropokres diropres; 206 } diropres_u; 207 }; 208 typedef struct diropres diropres; 209 bool_t xdr_diropres(); 210 211 212 struct readlinkres { 213 nfsstat status; 214 union { 215 nfspath data; 216 } readlinkres_u; 217 }; 218 typedef struct readlinkres readlinkres; 219 bool_t xdr_readlinkres(); 220 221 222 struct readargs { 223 nfs_fh file; 224 u_int offset; 225 u_int count; 226 u_int totalcount; 227 }; 228 typedef struct readargs readargs; 229 bool_t xdr_readargs(); 230 231 232 struct readokres { 233 fattr attributes; 234 struct { 235 u_int data_len; 236 char *data_val; 237 } data; 238 }; 239 typedef struct readokres readokres; 240 bool_t xdr_readokres(); 241 242 243 struct readres { 244 nfsstat status; 245 union { 246 readokres reply; 247 } readres_u; 248 }; 249 typedef struct readres readres; 250 bool_t xdr_readres(); 251 252 253 struct writeargs { 254 nfs_fh file; 255 u_int beginoffset; 256 u_int offset; 257 u_int totalcount; 258 struct { 259 u_int data_len; 260 char *data_val; 261 } data; 262 }; 263 typedef struct writeargs writeargs; 264 bool_t xdr_writeargs(); 265 266 267 struct createargs { 268 diropargs where; 269 sattr attributes; 270 }; 271 typedef struct createargs createargs; 272 bool_t xdr_createargs(); 273 274 275 struct renameargs { 276 diropargs from; 277 diropargs to; 278 }; 279 typedef struct renameargs renameargs; 280 bool_t xdr_renameargs(); 281 282 283 struct linkargs { 284 nfs_fh from; 285 diropargs to; 286 }; 287 typedef struct linkargs linkargs; 288 bool_t xdr_linkargs(); 289 290 291 struct symlinkargs { 292 diropargs from; 293 nfspath to; 294 sattr attributes; 295 }; 296 typedef struct symlinkargs symlinkargs; 297 bool_t xdr_symlinkargs(); 298 299 300 typedef char nfscookie[NFS_COOKIESIZE]; 301 /* static bool_t xdr_nfscookie(); */ 302 303 304 struct readdirargs { 305 nfs_fh dir; 306 nfscookie cookie; 307 u_int count; 308 }; 309 typedef struct readdirargs readdirargs; 310 bool_t xdr_readdirargs(); 311 312 313 struct entry { 314 u_int fileid; 315 filename name; 316 nfscookie cookie; 317 struct entry *nextentry; 318 }; 319 typedef struct entry entry; 320 /* static bool_t xdr_entry(); */ 321 322 323 struct dirlist { 324 entry *entries; 325 bool_t eof; 326 }; 327 typedef struct dirlist dirlist; 328 /* static bool_t xdr_dirlist(); */ 329 330 331 struct readdirres { 332 nfsstat status; 333 union { 334 dirlist reply; 335 } readdirres_u; 336 }; 337 typedef struct readdirres readdirres; 338 bool_t xdr_readdirres(); 339 340 341 struct statfsokres { 342 u_int tsize; 343 u_int bsize; 344 u_int blocks; 345 u_int bfree; 346 u_int bavail; 347 }; 348 typedef struct statfsokres statfsokres; 349 bool_t xdr_statfsokres(); 350 351 352 struct statfsres { 353 nfsstat status; 354 union { 355 statfsokres reply; 356 } statfsres_u; 357 }; 358 typedef struct statfsres statfsres; 359 bool_t xdr_statfsres(); 360 361 362 #define NFS_PROGRAM ((u_long)100003) 363 #define NFS_VERSION ((u_long)2) 364 365 /* Undef the version 3 ones, and define the v2 ones */ 366 #undef NFSPROC_NULL 367 #define NFSPROC_NULL ((u_long)0) 368 #undef NFSPROC_GETATTR 369 #define NFSPROC_GETATTR ((u_long)1) 370 #undef NFSPROC_SETATTR 371 #define NFSPROC_SETATTR ((u_long)2) 372 #undef NFSPROC_ROOT 373 #define NFSPROC_ROOT ((u_long)3) 374 #undef NFSPROC_LOOKUP 375 #define NFSPROC_LOOKUP ((u_long)4) 376 #undef NFSPROC_READLINK 377 #define NFSPROC_READLINK ((u_long)5) 378 #undef NFSPROC_READ 379 #define NFSPROC_READ ((u_long)6) 380 #undef NFSPROC_WRITECACHE 381 #define NFSPROC_WRITECACHE ((u_long)7) 382 #undef NFSPROC_WRITE 383 #define NFSPROC_WRITE ((u_long)8) 384 #undef NFSPROC_CREATE 385 #define NFSPROC_CREATE ((u_long)9) 386 #undef NFSPROC_REMOVE 387 #define NFSPROC_REMOVE ((u_long)10) 388 #undef NFSPROC_RENAME 389 #define NFSPROC_RENAME ((u_long)11) 390 #undef NFSPROC_LINK 391 #define NFSPROC_LINK ((u_long)12) 392 #undef NFSPROC_SYMLINK 393 #define NFSPROC_SYMLINK ((u_long)13) 394 #undef NFSPROC_MKDIR 395 #define NFSPROC_MKDIR ((u_long)14) 396 #undef NFSPROC_RMDIR 397 #define NFSPROC_RMDIR ((u_long)15) 398 #undef NFSPROC_READDIR 399 #define NFSPROC_READDIR ((u_long)16) 400 #undef NFSPROC_STATFS 401 #define NFSPROC_STATFS ((u_long)17) 402 403 extern void *nfsproc_null_2(); 404 extern attrstat *nfsproc_getattr_2(); 405 extern attrstat *nfsproc_setattr_2(); 406 extern void *nfsproc_root_2(); 407 extern diropres *nfsproc_lookup_2(); 408 extern readlinkres *nfsproc_readlink_2(); 409 extern readres *nfsproc_read_2(); 410 extern void *nfsproc_writecache_2(); 411 extern attrstat *nfsproc_write_2(); 412 extern diropres *nfsproc_create_2(); 413 extern nfsstat *nfsproc_remove_2(); 414 extern nfsstat *nfsproc_rename_2(); 415 extern nfsstat *nfsproc_link_2(); 416 extern nfsstat *nfsproc_symlink_2(); 417 extern diropres *nfsproc_mkdir_2(); 418 extern nfsstat *nfsproc_rmdir_2(); 419 extern readdirres *nfsproc_readdir_2(); 420 extern statfsres *nfsproc_statfs_2(); 421