xref: /openbsd/sys/lib/libsa/nfsv2.h (revision 4cfece93)
1 /*	$OpenBSD: nfsv2.h,v 1.6 2014/07/13 15:31:20 mpi 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 /*
39  * nfs definitions as per the version 2 specs
40  */
41 
42 /*
43  * Constants as defined in the Sun NFS Version 2 spec.
44  * "NFS: Network File System Protocol Specification" RFC1094
45  */
46 
47 #define NFS_PORT	2049
48 #define	NFS_PROG	100003
49 #define NFS_VER2	2
50 #define	NFS_MAXDGRAMDATA 8192
51 #define	NFS_MAXDATA	32768
52 #define	NFS_MAXPATHLEN	1024
53 #define	NFS_MAXNAMLEN	255
54 #define	NFS_FHSIZE	32
55 #define	NFS_MAXPKTHDR	404
56 #define NFS_MAXPACKET	(NFS_MAXPKTHDR+NFS_MAXDATA)
57 #define	NFS_MINPACKET	20
58 #define	NFS_FABLKSIZE	512	/* Size in bytes of a block wrt fa_blocks */
59 
60 /* Stat numbers for rpc returns */
61 #define	NFS_OK		0
62 #define	NFSERR_PERM	1
63 #define	NFSERR_NOENT	2
64 #define	NFSERR_IO	5
65 #define	NFSERR_NXIO	6
66 #define	NFSERR_ACCES	13
67 #define	NFSERR_EXIST	17
68 #define	NFSERR_NODEV	19
69 #define	NFSERR_NOTDIR	20
70 #define	NFSERR_ISDIR	21
71 #define	NFSERR_FBIG	27
72 #define	NFSERR_NOSPC	28
73 #define	NFSERR_ROFS	30
74 #define	NFSERR_NAMETOL	63
75 #define	NFSERR_NOTEMPTY	66
76 #define	NFSERR_DQUOT	69
77 #define	NFSERR_STALE	70
78 #define	NFSERR_WFLUSH	99
79 
80 /* Sizes in bytes of various nfs rpc components */
81 #define	NFSX_FH		32
82 #define	NFSX_UNSIGNED	4
83 #define	NFSX_FATTR	68
84 #define	NFSX_SATTR	32
85 #define NFSX_STATFS	20
86 #define	NFSX_COOKIE	4
87 
88 /* nfs rpc procedure numbers */
89 #define	NFSPROC_NULL		0
90 #define	NFSPROC_GETATTR		1
91 #define	NFSPROC_SETATTR		2
92 #define	NFSPROC_NOOP		3
93 #define	NFSPROC_ROOT		NFSPROC_NOOP	/* Obsolete */
94 #define	NFSPROC_LOOKUP		4
95 #define	NFSPROC_READLINK	5
96 #define	NFSPROC_READ		6
97 #define	NFSPROC_WRITECACHE	NFSPROC_NOOP	/* Obsolete */
98 #define	NFSPROC_WRITE		8
99 #define	NFSPROC_CREATE		9
100 #define	NFSPROC_REMOVE		10
101 #define	NFSPROC_RENAME		11
102 #define	NFSPROC_LINK		12
103 #define	NFSPROC_SYMLINK		13
104 #define	NFSPROC_MKDIR		14
105 #define	NFSPROC_RMDIR		15
106 #define	NFSPROC_READDIR		16
107 #define	NFSPROC_STATFS		17
108 
109 #define	NFS_NPROCS		18
110 
111 
112 /* File types */
113 typedef enum {
114 	NFNON=0,
115 	NFREG=1,
116 	NFDIR=2,
117 	NFBLK=3,
118 	NFCHR=4,
119 	NFLNK=5
120 } nfstype;
121 
122 /* Structs for common parts of the rpc's */
123 struct nfsv2_time {
124 	u_int32_t	nfs_sec;
125 	u_int32_t	nfs_usec;
126 };
127 
128 /*
129  * File attributes and setable attributes.
130  */
131 struct nfsv2_fattr {
132 	u_int32_t	fa_type;
133 	u_int32_t	fa_mode;
134 	u_int32_t	fa_nlink;
135 	u_int32_t	fa_uid;
136 	u_int32_t	fa_gid;
137 	u_int32_t	fa_size;
138 	u_int32_t	fa_blocksize;
139 	u_int32_t	fa_rdev;
140 	u_int32_t	fa_blocks;
141 	u_int32_t	fa_fsid;
142 	u_int32_t	fa_fileid;
143 	struct nfsv2_time fa_atime;
144 	struct nfsv2_time fa_mtime;
145 	struct nfsv2_time fa_ctime;
146 };
147 
148 struct nfsv2_sattr {
149 	u_int32_t	sa_mode;
150 	u_int32_t	sa_uid;
151 	u_int32_t	sa_gid;
152 	u_int32_t	sa_size;
153 	struct nfsv2_time sa_atime;
154 	struct nfsv2_time sa_mtime;
155 };
156 
157 struct nfsv2_statfs {
158 	u_int32_t	sf_tsize;
159 	u_int32_t	sf_bsize;
160 	u_int32_t	sf_blocks;
161 	u_int32_t	sf_bfree;
162 	u_int32_t	sf_bavail;
163 };
164