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