138414Smckusick /* 238414Smckusick * Copyright (c) 1989 The Regents of the University of California. 338414Smckusick * All rights reserved. 438414Smckusick * 538414Smckusick * This code is derived from software contributed to Berkeley by 638414Smckusick * Rick Macklem at The University of Guelph. 738414Smckusick * 838414Smckusick * Redistribution and use in source and binary forms are permitted 938414Smckusick * provided that the above copyright notice and this paragraph are 1038414Smckusick * duplicated in all such forms and that any documentation, 1138414Smckusick * advertising materials, and other materials related to such 1238414Smckusick * distribution and use acknowledge that the software was developed 1338414Smckusick * by the University of California, Berkeley. The name of the 1438414Smckusick * University may not be used to endorse or promote products derived 1538414Smckusick * from this software without specific prior written permission. 1638414Smckusick * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR 1738414Smckusick * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED 1838414Smckusick * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 1938414Smckusick * 20*40151Smckusick * @(#)nfsproto.h 7.4 (Berkeley) 02/17/90 2138414Smckusick */ 2238414Smckusick 2338414Smckusick /* 2438414Smckusick * nfs definitions as per the version 2 specs 2538414Smckusick */ 2638414Smckusick 2738414Smckusick /* 2838414Smckusick * Constants as defined in the Sun NFS Version 2 spec. 2939746Smckusick * "NFS: Network File System Protocol Specification" RFC1094 3038414Smckusick */ 3138414Smckusick 3238414Smckusick #define NFS_PORT 2049 3338414Smckusick #define NFS_PROG 100003 3438414Smckusick #define NFS_VER2 2 3538414Smckusick #define NFS_MAXDATA 8192 3638414Smckusick #define NFS_MAXPATHLEN 1024 3738414Smckusick #define NFS_MAXNAMLEN 255 3838414Smckusick #define NFS_FHSIZE 32 3938414Smckusick #define NFS_NPROCS 18 4038414Smckusick 4138414Smckusick /* Stat numbers for rpc returns */ 4238414Smckusick #define NFS_OK 0 4338414Smckusick #define NFSERR_PERM 1 4438414Smckusick #define NFSERR_NOENT 2 4538414Smckusick #define NFSERR_IO 5 4638414Smckusick #define NFSERR_NXIO 6 4738414Smckusick #define NFSERR_ACCES 13 4838414Smckusick #define NFSERR_EXIST 17 4938414Smckusick #define NFSERR_NODEV 19 5038414Smckusick #define NFSERR_NOTDIR 20 5138414Smckusick #define NFSERR_ISDIR 21 5238414Smckusick #define NFSERR_FBIG 27 5338414Smckusick #define NFSERR_NOSPC 28 5438414Smckusick #define NFSERR_ROFS 30 5538414Smckusick #define NFSERR_NAMETOOLONG 63 5638414Smckusick #define NFSERR_NOTEMPTY 66 5738414Smckusick #define NFSERR_DQUOT 69 5838414Smckusick #define NFSERR_STALE 70 5938414Smckusick #define NFSERR_WFLUSH 99 6038414Smckusick 6138414Smckusick /* Sizes in bytes of various nfs rpc components */ 6238414Smckusick #define NFSX_FH 32 6338414Smckusick #define NFSX_UNSIGNED 4 6438414Smckusick #define NFSX_FATTR 68 6538414Smckusick #define NFSX_SATTR 32 6638414Smckusick #define NFSX_COOKIE 4 6738414Smckusick #define NFSX_STATFS 20 6838414Smckusick 6938414Smckusick /* nfs rpc procedure numbers */ 7038414Smckusick #define NFSPROC_NULL 0 7138414Smckusick #define NFSPROC_GETATTR 1 7238414Smckusick #define NFSPROC_SETATTR 2 7338414Smckusick #define NFSPROC_ROOT 3 /* Obsolete */ 7438414Smckusick #define NFSPROC_LOOKUP 4 7538414Smckusick #define NFSPROC_READLINK 5 7638414Smckusick #define NFSPROC_READ 6 7738414Smckusick #define NFSPROC_WRITECACHE 7 /* Obsolete */ 7838414Smckusick #define NFSPROC_WRITE 8 7938414Smckusick #define NFSPROC_CREATE 9 8038414Smckusick #define NFSPROC_REMOVE 10 8138414Smckusick #define NFSPROC_RENAME 11 8238414Smckusick #define NFSPROC_LINK 12 8338414Smckusick #define NFSPROC_SYMLINK 13 8438414Smckusick #define NFSPROC_MKDIR 14 8538414Smckusick #define NFSPROC_RMDIR 15 8638414Smckusick #define NFSPROC_READDIR 16 8738414Smckusick #define NFSPROC_STATFS 17 8838414Smckusick 8938414Smckusick /* Conversion macros */ 90*40151Smckusick extern int vttoif_tab[]; 91*40151Smckusick #define vtonfs_mode(t,m) txdr_unsigned((int)(vttoif_tab[(int)(t)] | (m))) 9238414Smckusick #define nfstov_mode(a) (fxdr_unsigned(u_short, (a))&07777) 9338414Smckusick #define vtonfs_type(a) txdr_unsigned(nfs_type[((long)(a))]) 9438414Smckusick #define nfstov_type(a) v_type[fxdr_unsigned(u_long, (a))] 9538414Smckusick 9638414Smckusick /* File types */ 9738414Smckusick typedef enum { NFNON=0, NFREG=1, NFDIR=2, NFBLK=3, NFCHR=4, NFLNK=5 } nfstype; 9838884Smacklem 9938884Smacklem /* Structs for common parts of the rpc's */ 10038884Smacklem struct nfsv2_time { 10138884Smacklem u_long tv_sec; 10238884Smacklem u_long tv_usec; 10338884Smacklem }; 10438884Smacklem 10538884Smacklem struct nfsv2_fattr { 10638884Smacklem u_long fa_type; 10738884Smacklem u_long fa_mode; 10838884Smacklem u_long fa_nlink; 10938884Smacklem u_long fa_uid; 11038884Smacklem u_long fa_gid; 11138884Smacklem u_long fa_size; 11238884Smacklem u_long fa_blocksize; 11338884Smacklem u_long fa_rdev; 11438884Smacklem u_long fa_blocks; 11538884Smacklem u_long fa_fsid; 11638884Smacklem u_long fa_fileid; 11738884Smacklem struct nfsv2_time fa_atime; 11838884Smacklem struct nfsv2_time fa_mtime; 11938884Smacklem struct nfsv2_time fa_ctime; 12038884Smacklem }; 12138884Smacklem 12238884Smacklem struct nfsv2_sattr { 12338884Smacklem u_long sa_mode; 12438884Smacklem u_long sa_uid; 12538884Smacklem u_long sa_gid; 12638884Smacklem u_long sa_size; 12738884Smacklem struct nfsv2_time sa_atime; 12838884Smacklem struct nfsv2_time sa_mtime; 12938884Smacklem }; 13038884Smacklem 13138884Smacklem struct nfsv2_statfs { 13238884Smacklem u_long sf_tsize; 13338884Smacklem u_long sf_bsize; 13438884Smacklem u_long sf_blocks; 13538884Smacklem u_long sf_bfree; 13638884Smacklem u_long sf_bavail; 13738884Smacklem }; 138