xref: /netbsd-src/external/bsd/am-utils/dist/conf/nfs_prot/nfs_prot_ultrix.h (revision 8bae5d409deb915cf7c8f0539fae22ff2cb8a313)
1 /*	$NetBSD: nfs_prot_ultrix.h,v 1.1.1.3 2015/01/17 16:34:16 christos Exp $	*/
2 
3 /*
4  * Copyright (c) 1997-2014 Erez Zadok
5  * Copyright (c) 1990 Jan-Simon Pendry
6  * Copyright (c) 1990 Imperial College of Science, Technology & Medicine
7  * Copyright (c) 1990 The Regents of the University of California.
8  * All rights reserved.
9  *
10  * This code is derived from software contributed to Berkeley by
11  * Jan-Simon Pendry at Imperial College, London.
12  *
13  * Redistribution and use in source and binary forms, with or without
14  * modification, are permitted provided that the following conditions
15  * are met:
16  * 1. Redistributions of source code must retain the above copyright
17  *    notice, this list of conditions and the following disclaimer.
18  * 2. Redistributions in binary form must reproduce the above copyright
19  *    notice, this list of conditions and the following disclaimer in the
20  *    documentation and/or other materials provided with the distribution.
21  * 3. Neither the name of the University nor the names of its contributors
22  *    may be used to endorse or promote products derived from this software
23  *    without specific prior written permission.
24  *
25  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
26  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
28  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
29  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
30  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
31  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
32  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
33  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
34  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
35  * SUCH DAMAGE.
36  *
37  *
38  * File: am-utils/conf/nfs_prot/nfs_prot_ultrix.h
39  *
40  */
41 
42 #ifndef _AMU_NFS_PROT_H
43 #define _AMU_NFS_PROT_H
44 
45 #ifdef HAVE_NFS_NFS_H
46 # include <nfs/nfs.h>
47 #endif /* HAVE_NFS_NFS_H */
48 
49 /*
50  * MACROS
51  */
52 
53 #if 0
54 /* <nfs/nfs.h> */
55 #define NFS_PORT 2049
56 #define NFS_MAXDATA 8192
57 #define NFS_MAXPATHLEN 1024
58 #define NFS_MAXNAMLEN 255
59 #define NFS_FHSIZE 32
60 #endif /* 0 */
61 /* sizeof(u_long) */
62 #define NFS_COOKIESIZE 4
63 #if 0
64 /* defaults: libamu/amu.h */
65 #define	MNTPATHLEN 1024
66 #define	MNTNAMLEN 255
67 #endif /* 0 */
68 
69 #define NFSMODE_FMT 0170000
70 #define NFSMODE_DIR 0040000
71 #define NFSMODE_CHR 0020000
72 #define NFSMODE_BLK 0060000
73 #define NFSMODE_REG 0100000
74 #define NFSMODE_LNK 0120000
75 #define NFSMODE_SOCK 0140000
76 #define NFSMODE_FIFO 0010000
77 
78 #if 0
79 /* <nfs/nfs.h> */
80 #ifndef NFS_PROGRAM
81 # define NFS_PROGRAM ((u_long)100003)
82 #endif /* not NFS_PROGRAM */
83 #ifndef NFS_VERSION
84 # define NFS_VERSION ((u_long)2)
85 #endif /* not NFS_VERSION */
86 #endif /* 0 */
87 
88 /* could use (u_long)RFS_* with RFS_* from <nfs/nfs.h> */
89 #define NFSPROC_NULL ((u_long)0)
90 #define NFSPROC_GETATTR ((u_long)1)
91 #define NFSPROC_SETATTR ((u_long)2)
92 #define NFSPROC_ROOT ((u_long)3)
93 #define NFSPROC_LOOKUP ((u_long)4)
94 #define NFSPROC_READLINK ((u_long)5)
95 #define NFSPROC_READ ((u_long)6)
96 #define NFSPROC_WRITECACHE ((u_long)7)
97 #define NFSPROC_WRITE ((u_long)8)
98 #define NFSPROC_CREATE ((u_long)9)
99 #define NFSPROC_REMOVE ((u_long)10)
100 #define NFSPROC_RENAME ((u_long)11)
101 #define NFSPROC_LINK ((u_long)12)
102 #define NFSPROC_SYMLINK ((u_long)13)
103 #define NFSPROC_MKDIR ((u_long)14)
104 #define NFSPROC_RMDIR ((u_long)15)
105 #define NFSPROC_READDIR ((u_long)16)
106 #define NFSPROC_STATFS ((u_long)17)
107 
108 /* map field names */
109 #define ml_hostname	ml_name
110 #define ml_directory	ml_path
111 #define ml_next		ml_nxt
112 #define	gr_next		g_next
113 #define gr_name		g_name
114 #define ex_dir		ex_name
115 
116 #define ca_where	ca_da
117 #define ca_attributes	ca_sa
118 #define drok_attributes	drok_attr
119 #define fh_data		fh_pad
120 #define na_fileid	na_nodeid
121 #define la_fhandle	la_from
122 #define nt_seconds	tv_sec
123 #define nt_useconds	tv_usec
124 #define ra_totalcount	ra_totcount
125 #define rlr_status	rl_status
126 #define rlr_u		rl_u
127 #define sla_to		sla_tnm
128 #define sla_attributes	sla_sa
129 #define sag_fhandle	saa_fh
130 #define sag_attributes	saa_sa
131 
132 
133 /*
134  * TYPEDEFS:
135  */
136 typedef char *dirpath;
137 typedef char *filename;
138 typedef char *name;
139 typedef char *nfspath;
140 typedef char nfscookie[NFS_COOKIESIZE];
141 typedef enum nfsftype nfsftype;
142 typedef enum nfsstat nfsstat;
143 typedef fhandle_t fhandle;
144 typedef struct nfsattrstat nfsattrstat;
145 typedef struct nfscreatargs nfscreateargs;
146 typedef struct nfsdirlist nfsdirlist;
147 typedef struct nfsdiropargs nfsdiropargs;
148 typedef struct nfsdrok nfsdiropokres;
149 typedef struct nfsdiropres nfsdiropres;
150 typedef struct nfsentry nfsentry;
151 typedef struct exports *exports;
152 typedef struct exports exportnode;
153 typedef struct nfsfattr nfsfattr;
154 typedef struct fhstatus fhstatus;
155 typedef struct groups *groups;
156 typedef struct groups groupnode;
157 typedef struct nfslinkargs nfslinkargs;
158 typedef struct mountlist *mountlist;
159 typedef struct mountlist mountbody;
160 typedef struct timeval nfstime;
161 typedef struct nfsreadargs nfsreadargs;
162 typedef struct nfsreaddirargs nfsreaddirargs;
163 typedef struct nfsreaddirres nfsreaddirres;
164 typedef struct nfsreadlinkres nfsreadlinkres;
165 typedef struct nfsreadokres nfsreadokres;
166 typedef struct nfsreadres nfsreadres;
167 typedef struct nfsrnmargs nfsrenameargs;
168 typedef struct nfssattr nfssattr;
169 typedef struct nfssaargs nfssattrargs;
170 typedef struct nfsstatfsokres nfsstatfsokres;
171 typedef struct nfsstatfsres nfsstatfsres;
172 typedef struct nfsslargs nfssymlinkargs;
173 typedef struct writeargs nfswriteargs;
174 
175 
176 /*
177  * EXTERNALS:
178  */
179 
180 extern void *nfsproc_null_2_svc(void *, struct svc_req *);
181 extern nfsattrstat *nfsproc_getattr_2_svc(fhandle_t *, struct svc_req *);
182 extern nfsattrstat *nfsproc_setattr_2_svc(nfssattrargs *, struct svc_req *);
183 extern void *nfsproc_root_2_svc(void *, struct svc_req *);
184 extern nfsdiropres *nfsproc_lookup_2_svc(nfsdiropargs *, struct svc_req *);
185 extern nfsreadlinkres *nfsproc_readlink_2_svc(fhandle_t *, struct svc_req *);
186 extern nfsreadres *nfsproc_read_2_svc(nfsreadargs *, struct svc_req *);
187 extern void *nfsproc_writecache_2_svc(void *, struct svc_req *);
188 extern nfsattrstat *nfsproc_write_2_svc(nfswriteargs *, struct svc_req *);
189 extern nfsdiropres *nfsproc_create_2_svc(nfscreateargs *, struct svc_req *);
190 extern nfsstat *nfsproc_remove_2_svc(nfsdiropargs *, struct svc_req *);
191 extern nfsstat *nfsproc_rename_2_svc(nfsrenameargs *, struct svc_req *);
192 extern nfsstat *nfsproc_link_2_svc(nfslinkargs *, struct svc_req *);
193 extern nfsstat *nfsproc_symlink_2_svc(nfssymlinkargs *, struct svc_req *);
194 extern nfsdiropres *nfsproc_mkdir_2_svc(nfscreateargs *, struct svc_req *);
195 extern nfsstat *nfsproc_rmdir_2_svc(nfsdiropargs *, struct svc_req *);
196 extern nfsreaddirres *nfsproc_readdir_2_svc(nfsreaddirargs *, struct svc_req *);
197 extern nfsstatfsres *nfsproc_statfs_2_svc(fhandle_t *, struct svc_req *);
198 
199 extern bool_t xdr_nfsstat(XDR *, nfsstat*);
200 extern bool_t xdr_ftype(XDR *, nfsftype*);
201 extern bool_t xdr_nfs_fh(XDR *, fhandle_t*);
202 extern bool_t xdr_nfstime(XDR *, nfstime*);
203 extern bool_t xdr_fattr(XDR *, nfsfattr*);
204 extern bool_t xdr_sattr(XDR *, nfssattr*);
205 extern bool_t xdr_filename(XDR *, filename*);
206 extern bool_t xdr_nfspath(XDR *, nfspath*);
207 extern bool_t xdr_attrstat(XDR *, nfsattrstat*);
208 extern bool_t xdr_sattrargs(XDR *, nfssattrargs*);
209 extern bool_t xdr_diropargs(XDR *, nfsdiropargs*);
210 extern bool_t xdr_diropokres(XDR *, nfsdiropokres*);
211 extern bool_t xdr_diropres(XDR *, nfsdiropres*);
212 extern bool_t xdr_readlinkres(XDR *, nfsreadlinkres*);
213 extern bool_t xdr_readargs(XDR *, nfsreadargs*);
214 extern bool_t xdr_readokres(XDR *, nfsreadokres*);
215 extern bool_t xdr_readres(XDR *, nfsreadres*);
216 extern bool_t xdr_writeargs(XDR *, nfswriteargs*);
217 extern bool_t xdr_createargs(XDR *, nfscreateargs*);
218 extern bool_t xdr_renameargs(XDR *, nfsrenameargs*);
219 extern bool_t xdr_linkargs(XDR *, nfslinkargs*);
220 extern bool_t xdr_symlinkargs(XDR *, nfssymlinkargs*);
221 extern bool_t xdr_nfscookie(XDR *, nfscookie);
222 extern bool_t xdr_readdirargs(XDR *, nfsreaddirargs*);
223 extern bool_t xdr_entry(XDR *, nfsentry*);
224 extern bool_t xdr_dirlist(XDR *, nfsdirlist*);
225 extern bool_t xdr_readdirres(XDR *, nfsreaddirres*);
226 extern bool_t xdr_statfsokres(XDR *, nfsstatfsokres*);
227 extern bool_t xdr_statfsres(XDR *, nfsstatfsres*);
228 
229 
230 /*
231  * STRUCTURES:
232  */
233 
234 struct nfsreadlinkres {
235   nfsstat rlr_status;
236   union {
237     nfspath rlr_data_u;
238   } rlr_u;
239 };
240 
241 struct nfsreadokres {
242   nfsfattr raok_attributes;
243   struct {
244     u_int raok_len_u;
245     char *raok_val_u;
246   } raok_u;
247 };
248 
249 struct nfsreadres {
250   nfsstat rr_status;
251   union {
252     nfsreadokres rr_reply_u;
253   } rr_u;
254 };
255 
256 struct writeargs {
257   fhandle_t wra_fhandle;
258   u_int wra_beginoffset;
259   u_int wra_offset;
260   u_int wra_totalcount;
261   struct {
262     u_int wra_len_u;
263     char *wra_val_u;
264   } wra_u;
265 };
266 
267 struct nfsreaddirargs {
268   fhandle_t rda_fhandle;
269   nfscookie rda_cookie;
270   u_int rda_count;
271 };
272 
273 struct nfsentry {
274   u_int ne_fileid;
275   filename ne_name;
276   nfscookie ne_cookie;
277   nfsentry *ne_nextentry;
278 };
279 
280 struct nfsdirlist {
281   nfsentry *dl_entries;
282   bool_t dl_eof;
283 };
284 
285 struct nfsreaddirres {
286   nfsstat rdr_status;
287   union {
288     nfsdirlist rdr_reply_u;
289   } rdr_u;
290 };
291 
292 struct nfsstatfsokres {
293   u_int sfrok_tsize;
294   u_int sfrok_bsize;
295   u_int sfrok_blocks;
296   u_int sfrok_bfree;
297   u_int sfrok_bavail;
298 };
299 
300 struct nfsstatfsres {
301   nfsstat sfr_status;
302   union {
303     nfsstatfsokres sfr_reply_u;
304   } sfr_u;
305 };
306 #endif /* not _AMU_NFS_PROT_H */
307