xref: /dragonfly/stand/lib/nfsv2.h (revision 7d3e9a5b)
1 /* $FreeBSD: src/lib/libstand/nfsv2.h,v 1.1.1.1.6.1 2000/05/04 13:47:51 ps Exp $ */
2 /*	$NetBSD: nfsv2.h,v 1.2 1996/02/26 23:05:23 gwr Exp $	*/
3 
4 /*
5  * Copyright (c) 1989, 1993
6  *	The Regents of the University of California.  All rights reserved.
7  *
8  * This code is derived from software contributed to Berkeley by
9  * Rick Macklem at The University of Guelph.
10  *
11  * Redistribution and use in source and binary forms, with or without
12  * modification, are permitted provided that the following conditions
13  * are met:
14  * 1. Redistributions of source code must retain the above copyright
15  *    notice, this list of conditions and the following disclaimer.
16  * 2. Redistributions in binary form must reproduce the above copyright
17  *    notice, this list of conditions and the following disclaimer in the
18  *    documentation and/or other materials provided with the distribution.
19  * 3. Neither the name of the University nor the names of its contributors
20  *    may be used to endorse or promote products derived from this software
21  *    without specific prior written permission.
22  *
23  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
24  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
27  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
28  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
29  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
32  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33  * SUCH DAMAGE.
34  *
35  *	@(#)nfsv2.h	8.1 (Berkeley) 6/10/93
36  */
37 
38 #ifndef _STAND_NFSV2_H_
39 #define	_STAND_NFSV2_H_
40 
41 /*
42  * nfs definitions as per the version 2 specs
43  */
44 
45 /*
46  * Constants as defined in the Sun NFS Version 2 spec.
47  * "NFS: Network File System Protocol Specification" RFC1094
48  */
49 
50 #define NFS_PORT	2049
51 #define	NFS_PROG	100003
52 #define NFS_VER2	2
53 #define	NFS_MAXDGRAMDATA 8192
54 #define	NFS_MAXDATA	32768
55 #define	NFS_MAXPATHLEN	1024
56 #define	NFS_MAXNAMLEN	255
57 #define	NFS_FHSIZE	32
58 #define	NFS_MAXPKTHDR	404
59 #define NFS_MAXPACKET	(NFS_MAXPKTHDR+NFS_MAXDATA)
60 #define	NFS_MINPACKET	20
61 #define	NFS_FABLKSIZE	512	/* Size in bytes of a block wrt fa_blocks */
62 #define	NFS_READDIRSIZE	1024
63 
64 /* Stat numbers for rpc returns */
65 #define	NFS_OK		0
66 #define	NFSERR_PERM	1
67 #define	NFSERR_NOENT	2
68 #define	NFSERR_IO	5
69 #define	NFSERR_NXIO	6
70 #define	NFSERR_ACCES	13
71 #define	NFSERR_EXIST	17
72 #define	NFSERR_NODEV	19
73 #define	NFSERR_NOTDIR	20
74 #define	NFSERR_ISDIR	21
75 #define	NFSERR_FBIG	27
76 #define	NFSERR_NOSPC	28
77 #define	NFSERR_ROFS	30
78 #define	NFSERR_NAMETOL	63
79 #define	NFSERR_NOTEMPTY	66
80 #define	NFSERR_DQUOT	69
81 #define	NFSERR_STALE	70
82 #define	NFSERR_WFLUSH	99
83 
84 /* Sizes in bytes of various nfs rpc components */
85 #define	NFSX_FH		32
86 #define	NFSX_UNSIGNED	4
87 #define	NFSX_FATTR	68
88 #define	NFSX_SATTR	32
89 #define NFSX_STATFS	20
90 #define	NFSX_COOKIE	4
91 
92 /* nfs rpc procedure numbers */
93 #define	NFSPROC_NULL		0
94 #define	NFSPROC_GETATTR		1
95 #define	NFSPROC_SETATTR		2
96 #define	NFSPROC_NOOP		3
97 #define	NFSPROC_ROOT		NFSPROC_NOOP	/* Obsolete */
98 #define	NFSPROC_LOOKUP		4
99 #define	NFSPROC_READLINK	5
100 #define	NFSPROC_READ		6
101 #define	NFSPROC_WRITECACHE	NFSPROC_NOOP	/* Obsolete */
102 #define	NFSPROC_WRITE		8
103 #define	NFSPROC_CREATE		9
104 #define	NFSPROC_REMOVE		10
105 #define	NFSPROC_RENAME		11
106 #define	NFSPROC_LINK		12
107 #define	NFSPROC_SYMLINK		13
108 #define	NFSPROC_MKDIR		14
109 #define	NFSPROC_RMDIR		15
110 #define	NFSPROC_READDIR		16
111 #define	NFSPROC_STATFS		17
112 
113 #define	NFS_NPROCS		18
114 
115 
116 /* File types */
117 typedef enum {
118 	NFNON=0,
119 	NFREG=1,
120 	NFDIR=2,
121 	NFBLK=3,
122 	NFCHR=4,
123 	NFLNK=5
124 } nfstype;
125 
126 /* Structs for common parts of the rpc's */
127 struct nfsv2_time {
128 	n_long	nfs_sec;
129 	n_long	nfs_usec;
130 };
131 
132 /*
133  * File attributes and setable attributes.
134  */
135 struct nfsv2_fattr {
136 	n_long	fa_type;
137 	n_long	fa_mode;
138 	n_long	fa_nlink;
139 	n_long	fa_uid;
140 	n_long	fa_gid;
141 	n_long	fa_size;
142 	n_long	fa_blocksize;
143 	n_long	fa_rdev;
144 	n_long	fa_blocks;
145 	n_long	fa_fsid;
146 	n_long	fa_fileid;
147 	struct nfsv2_time fa_atime;
148 	struct nfsv2_time fa_mtime;
149 	struct nfsv2_time fa_ctime;
150 };
151 
152 struct nfsv2_sattr {
153 	n_long	sa_mode;
154 	n_long	sa_uid;
155 	n_long	sa_gid;
156 	n_long	sa_size;
157 	struct nfsv2_time sa_atime;
158 	struct nfsv2_time sa_mtime;
159 };
160 
161 struct nfsv2_statfs {
162 	n_long	sf_tsize;
163 	n_long	sf_bsize;
164 	n_long	sf_blocks;
165 	n_long	sf_bfree;
166 	n_long	sf_bavail;
167 };
168 
169 #endif /* !_STAND_NFSVS2_H_ */
170