xref: /csrg-svn/sys/nfs/nfsproto.h (revision 43347)
1 /*
2  * Copyright (c) 1989 The Regents of the University of California.
3  * All rights reserved.
4  *
5  * This code is derived from software contributed to Berkeley by
6  * Rick Macklem at The University of Guelph.
7  *
8  * Redistribution and use in source and binary forms are permitted
9  * provided that the above copyright notice and this paragraph are
10  * duplicated in all such forms and that any documentation,
11  * advertising materials, and other materials related to such
12  * distribution and use acknowledge that the software was developed
13  * by the University of California, Berkeley.  The name of the
14  * University may not be used to endorse or promote products derived
15  * from this software without specific prior written permission.
16  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
17  * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
18  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
19  *
20  *	@(#)nfsproto.h	7.7 (Berkeley) 06/21/90
21  */
22 
23 /*
24  * nfs definitions as per the version 2 specs
25  */
26 
27 /*
28  * Constants as defined in the Sun NFS Version 2 spec.
29  * "NFS: Network File System Protocol Specification" RFC1094
30  */
31 
32 #define NFS_PORT	2049
33 #define	NFS_PROG	100003
34 #define NFS_VER2	2
35 #define	NFS_MAXDGRAMDATA 8192
36 #define	NFS_MAXDATA	32768
37 #define	NFS_MAXPATHLEN	1024
38 #define	NFS_MAXNAMLEN	255
39 #define	NFS_FHSIZE	32
40 #define	NFS_MAXPKTHDR	404
41 #define NFS_MAXPACKET	(NFS_MAXPKTHDR+NFS_MAXDATA)
42 #define	NFS_NPROCS	18
43 #define	NFS_FABLKSIZE	512	/* Size in bytes of a block wrt fa_blocks */
44 
45 /* Stat numbers for rpc returns */
46 #define	NFS_OK		0
47 #define	NFSERR_PERM	1
48 #define	NFSERR_NOENT	2
49 #define	NFSERR_IO	5
50 #define	NFSERR_NXIO	6
51 #define	NFSERR_ACCES	13
52 #define	NFSERR_EXIST	17
53 #define	NFSERR_NODEV	19
54 #define	NFSERR_NOTDIR	20
55 #define	NFSERR_ISDIR	21
56 #define	NFSERR_FBIG	27
57 #define	NFSERR_NOSPC	28
58 #define	NFSERR_ROFS	30
59 #define	NFSERR_NAMETOOLONG	63
60 #define	NFSERR_NOTEMPTY	66
61 #define	NFSERR_DQUOT	69
62 #define	NFSERR_STALE	70
63 #define	NFSERR_WFLUSH	99
64 
65 /* Sizes in bytes of various nfs rpc components */
66 #define	NFSX_FH		32
67 #define	NFSX_UNSIGNED	4
68 #define	NFSX_FATTR	68
69 #define	NFSX_SATTR	32
70 #define	NFSX_COOKIE	4
71 #define NFSX_STATFS	20
72 
73 /* nfs rpc procedure numbers */
74 #define	NFSPROC_NULL		0
75 #define	NFSPROC_GETATTR		1
76 #define	NFSPROC_SETATTR		2
77 #define	NFSPROC_ROOT		3		/* Obsolete */
78 #define	NFSPROC_LOOKUP		4
79 #define	NFSPROC_READLINK	5
80 #define	NFSPROC_READ		6
81 #define	NFSPROC_WRITECACHE	7		/* Obsolete */
82 #define	NFSPROC_WRITE		8
83 #define	NFSPROC_CREATE		9
84 #define	NFSPROC_REMOVE		10
85 #define	NFSPROC_RENAME		11
86 #define	NFSPROC_LINK		12
87 #define	NFSPROC_SYMLINK		13
88 #define	NFSPROC_MKDIR		14
89 #define	NFSPROC_RMDIR		15
90 #define	NFSPROC_READDIR		16
91 #define	NFSPROC_STATFS		17
92 
93 /* Conversion macros */
94 extern int		vttoif_tab[];
95 #define	vtonfs_mode(t,m) \
96 		txdr_unsigned(((t) == VFIFO) ? MAKEIMODE(VCHR, (m)) : \
97 				MAKEIMODE((t), (m)))
98 #define	nfstov_mode(a)	(fxdr_unsigned(u_short, (a))&07777)
99 #define	vtonfs_type(a)	txdr_unsigned(nfs_type[((long)(a))])
100 #define	nfstov_type(a)	ntov_type[fxdr_unsigned(u_long,(a))&0x7]
101 
102 /* File types */
103 typedef enum { NFNON=0, NFREG=1, NFDIR=2, NFBLK=3, NFCHR=4, NFLNK=5 } nfstype;
104 
105 /* Structs for common parts of the rpc's */
106 struct nfsv2_time {
107 	u_long	tv_sec;
108 	u_long	tv_usec;
109 };
110 
111 struct nfsv2_fattr {
112 	u_long	fa_type;
113 	u_long	fa_mode;
114 	u_long	fa_nlink;
115 	u_long	fa_uid;
116 	u_long	fa_gid;
117 	u_long	fa_size;
118 	u_long	fa_blocksize;
119 	u_long	fa_rdev;
120 	u_long	fa_blocks;
121 	u_long	fa_fsid;
122 	u_long	fa_fileid;
123 	struct nfsv2_time fa_atime;
124 	struct nfsv2_time fa_mtime;
125 	struct nfsv2_time fa_ctime;
126 };
127 
128 struct nfsv2_sattr {
129 	u_long	sa_mode;
130 	u_long	sa_uid;
131 	u_long	sa_gid;
132 	u_long	sa_size;
133 	struct nfsv2_time sa_atime;
134 	struct nfsv2_time sa_mtime;
135 };
136 
137 struct nfsv2_statfs {
138 	u_long	sf_tsize;
139 	u_long	sf_bsize;
140 	u_long	sf_blocks;
141 	u_long	sf_bfree;
142 	u_long	sf_bavail;
143 };
144