xref: /netbsd-src/external/bsd/am-utils/dist/conf/nfs_prot/nfs_prot_irix5.h (revision 8bae5d409deb915cf7c8f0539fae22ff2cb8a313)
1 /*	$NetBSD: nfs_prot_irix5.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_irix5.h
39  *
40  */
41 
42 #ifndef _AMU_NFS_PROT_H
43 #define _AMU_NFS_PROT_H
44 
45 #ifdef HAVE_NFS_NFSV2_H
46 # include <nfs/nfsv2.h>
47 #endif /* HAVE_NFS_NFSV2_H */
48 #ifdef HAVE_RPC_RPC_H
49 # include <rpc/rpc.h>
50 #endif /* HAVE_RPC_RPC_H */
51 #ifdef HAVE_NFS_RPCV2_H
52 # include <nfs/rpcv2.h>
53 #endif /* HAVE_NFS_RPCV2_H */
54 #ifdef HAVE_NFS_NFS_H
55 # include <nfs/nfs.h>
56 #endif /* HAVE_NFS_NFS_H */
57 #ifdef HAVE_SYS_UIO_H
58 # define _KMEMUSER
59 # include <sys/uio.h>
60 # undef _KMEMUSER
61 #endif /* HAVE_SYS_UIO_H */
62 #ifdef HAVE_SYS_VNODE_H
63 # include <sys/vnode.h>
64 #endif /* HAVE_SYS_VNODE_H */
65 #ifdef HAVE_SYS_FS_NFS_H
66 # include <sys/fs/nfs.h>
67 #endif /* HAVE_SYS_FS_NFS_H */
68 
69 #ifdef HAVE_RPCSVC_MOUNT_H
70 # include <rpcsvc/mount.h>
71 #endif /* HAVE_RPCSVC_MOUNT_H */
72 #ifdef HAVE_SYS_FSTYP_H
73 # include <sys/fstyp.h>
74 #endif /* HAVE_SYS_FSTYP_H */
75 
76 /* XFS isn't really supported in 5.3, but the header files are confusing */
77 #undef MNTTYPE_XFS
78 #undef MNTTAB_TYPE_XFS
79 
80 /****************************************************************************/
81 /*
82  * NFS V3 SUPPORT:
83  *
84  * IRIX5.3 requires the fh_len field to be added to the struct nfs_args
85  * defined in <sys/fs/nfs_clnt.h> for NFS3 mounts (it doesn't hurt for
86  * NFS2 mounts).  The mount syscall however always expects the argument
87  * structure size to be sizeof(struct nfs_args).
88  * So we need to use an extended struct nfs_args in amd/ops_nfs.c,
89  * while using the original struct nfs_arg in libamu/mountutil.c.
90  * 							-- stolcke 7/4/97
91  */
92 
93 /*
94  * NFS arguments to the mount system call.
95  */
96 struct irix5_nfs_args {
97   struct sockaddr_in	*addr;		/* file server address */
98   fhandle_t		*fh;		/* File handle to be mounted */
99   int			flags;		/* flags */
100   u_int			wsize;		/* write size in bytes */
101   u_int			rsize;		/* read size in bytes */
102   u_int			timeo;		/* initial timeout in .1 secs */
103   u_int			retrans;	/* times to retry send */
104   char			*hostname;	/* server's name */
105   u_int			acregmin;	/* attr cache file min secs */
106   u_int			acregmax;	/* attr cache file max secs */
107   u_int			acdirmin;	/* attr cache dir min secs */
108   u_int			acdirmax;	/* attr cache dir max secs */
109   u_int			symttl;		/* symlink cache time-to-live */
110   char			base[FSTYPSZ];	/* base type for statvfs */
111   u_int			namemax;	/* name length for statvfs */
112   u_int			fh_len;		/* length for a v3 filehandle */
113 };
114 
115 #ifndef MNTOPT_PROTO
116 # define MNTOPT_PROTO "proto"
117 #endif /* not MNTOPT_PROTO */
118 #ifndef MNTOPT_VERS
119 # define MNTOPT_VERS "vers"
120 #endif /* not MNTOPT_VERS */
121 
122 /****************************************************************************/
123 
124 
125 /*
126  * MACROS
127  */
128 
129 #define NFS_PORT 2049
130 #define NFS_MAXDATA 8192
131 #define NFS_MAXPATHLEN 1024
132 #define NFS_MAXNAMLEN 255
133 #define NFS_FHSIZE 32
134 #ifndef FHSIZE
135 /* Irix 5.2 is missing the definition for FHSIZE */
136 # define FHSIZE NFS_FHSIZE
137 #endif /* not FHSIZE */
138 #define NFS_COOKIESIZE 4
139 #define	MNTPATHLEN 1024
140 #define	MNTNAMLEN 255
141 
142 #define NFSMODE_FMT 0170000
143 #define NFSMODE_DIR 0040000
144 #define NFSMODE_CHR 0020000
145 #define NFSMODE_BLK 0060000
146 #define NFSMODE_REG 0100000
147 #define NFSMODE_LNK 0120000
148 #define NFSMODE_SOCK 0140000
149 #define NFSMODE_FIFO 0010000
150 
151 #ifndef NFS_PROGRAM
152 # define NFS_PROGRAM ((u_long)100003)
153 #endif /* not NFS_PROGRAM */
154 #ifndef NFS_VERSION
155 # define NFS_VERSION ((u_long)2)
156 #endif /* not NFS_VERSION */
157 
158 #define NFSPROC_NULL ((u_long)0)
159 #define NFSPROC_GETATTR ((u_long)1)
160 #define NFSPROC_SETATTR ((u_long)2)
161 #define NFSPROC_ROOT ((u_long)3)
162 #define NFSPROC_LOOKUP ((u_long)4)
163 #define NFSPROC_READLINK ((u_long)5)
164 #define NFSPROC_READ ((u_long)6)
165 #define NFSPROC_WRITECACHE ((u_long)7)
166 #define NFSPROC_WRITE ((u_long)8)
167 #define NFSPROC_CREATE ((u_long)9)
168 #define NFSPROC_REMOVE ((u_long)10)
169 #define NFSPROC_RENAME ((u_long)11)
170 #define NFSPROC_LINK ((u_long)12)
171 #define NFSPROC_SYMLINK ((u_long)13)
172 #define NFSPROC_MKDIR ((u_long)14)
173 #define NFSPROC_RMDIR ((u_long)15)
174 #define NFSPROC_READDIR ((u_long)16)
175 #define NFSPROC_STATFS ((u_long)17)
176 
177 /* map field names */
178 #define ml_hostname ml_name
179 #define ml_directory ml_path
180 #define ml_next ml_nxt
181 #define gr_next g_next
182 #define gr_name g_name
183 #define ex_dir ex_name
184 
185 
186 /*
187  * TYPEDEFS:
188  */
189 typedef char *dirpath;
190 typedef char *filename;
191 typedef char *name;
192 typedef char *nfspath;
193 typedef char nfscookie[NFS_COOKIESIZE];
194 typedef enum nfsftype nfsftype;
195 typedef enum nfsstat nfsstat;
196 typedef struct attrstat nfsattrstat;
197 typedef struct createargs nfscreateargs;
198 typedef struct dirlist nfsdirlist;
199 typedef struct diropargs nfsdiropargs;
200 typedef struct diropokres nfsdiropokres;
201 typedef struct diropres nfsdiropres;
202 typedef struct entry nfsentry;
203 typedef struct exports *exports;
204 typedef struct exports exportnode;
205 typedef struct fattr nfsfattr;
206 typedef struct fhstatus fhstatus;
207 typedef struct groups *groups;
208 typedef struct groups groupnode;
209 typedef struct linkargs nfslinkargs;
210 typedef struct mountlist *mountlist;
211 typedef struct mountlist mountbody;
212 typedef struct nfs_fh nfs_fh;
213 typedef struct nfstime nfstime;
214 typedef struct readargs nfsreadargs;
215 typedef struct readdirargs nfsreaddirargs;
216 typedef struct readdirres nfsreaddirres;
217 typedef struct readlinkres nfsreadlinkres;
218 typedef struct readokres nfsreadokres;
219 typedef struct readres nfsreadres;
220 typedef struct renameargs nfsrenameargs;
221 typedef struct sattr nfssattr;
222 typedef struct sattrargs nfssattrargs;
223 typedef struct statfsokres nfsstatfsokres;
224 typedef struct statfsres nfsstatfsres;
225 typedef struct symlinkargs nfssymlinkargs;
226 typedef struct writeargs nfswriteargs;
227 
228 
229 /*
230  * EXTERNALS:
231  */
232 
233 extern void *nfsproc_null_2_svc(void *, struct svc_req *);
234 extern nfsattrstat *nfsproc_getattr_2_svc(nfs_fh *, struct svc_req *);
235 extern nfsattrstat *nfsproc_setattr_2_svc(nfssattrargs *, struct svc_req *);
236 extern void *nfsproc_root_2_svc(void *, struct svc_req *);
237 extern nfsdiropres *nfsproc_lookup_2_svc(nfsdiropargs *, struct svc_req *);
238 extern nfsreadlinkres *nfsproc_readlink_2_svc(nfs_fh *, struct svc_req *);
239 extern nfsreadres *nfsproc_read_2_svc(nfsreadargs *, struct svc_req *);
240 extern void *nfsproc_writecache_2_svc(void *, struct svc_req *);
241 extern nfsattrstat *nfsproc_write_2_svc(nfswriteargs *, struct svc_req *);
242 extern nfsdiropres *nfsproc_create_2_svc(nfscreateargs *, struct svc_req *);
243 extern nfsstat *nfsproc_remove_2_svc(nfsdiropargs *, struct svc_req *);
244 extern nfsstat *nfsproc_rename_2_svc(nfsrenameargs *, struct svc_req *);
245 extern nfsstat *nfsproc_link_2_svc(nfslinkargs *, struct svc_req *);
246 extern nfsstat *nfsproc_symlink_2_svc(nfssymlinkargs *, struct svc_req *);
247 extern nfsdiropres *nfsproc_mkdir_2_svc(nfscreateargs *, struct svc_req *);
248 extern nfsstat *nfsproc_rmdir_2_svc(nfsdiropargs *, struct svc_req *);
249 extern nfsreaddirres *nfsproc_readdir_2_svc(nfsreaddirargs *, struct svc_req *);
250 extern nfsstatfsres *nfsproc_statfs_2_svc(nfs_fh *, struct svc_req *);
251 
252 extern bool_t xdr_nfsstat(XDR *, nfsstat*);
253 extern bool_t xdr_ftype(XDR *, nfsftype*);
254 extern bool_t xdr_nfs_fh(XDR *, nfs_fh*);
255 extern bool_t xdr_nfstime(XDR *, nfstime*);
256 extern bool_t xdr_fattr(XDR *, nfsfattr*);
257 extern bool_t xdr_sattr(XDR *, nfssattr*);
258 extern bool_t xdr_filename(XDR *, filename*);
259 extern bool_t xdr_nfspath(XDR *, nfspath*);
260 extern bool_t xdr_attrstat(XDR *, nfsattrstat*);
261 extern bool_t xdr_sattrargs(XDR *, nfssattrargs*);
262 extern bool_t xdr_diropargs(XDR *, nfsdiropargs*);
263 extern bool_t xdr_diropokres(XDR *, nfsdiropokres*);
264 extern bool_t xdr_diropres(XDR *, nfsdiropres*);
265 extern bool_t xdr_readlinkres(XDR *, nfsreadlinkres*);
266 extern bool_t xdr_readargs(XDR *, nfsreadargs*);
267 extern bool_t xdr_readokres(XDR *, nfsreadokres*);
268 extern bool_t xdr_readres(XDR *, nfsreadres*);
269 extern bool_t xdr_writeargs(XDR *, nfswriteargs*);
270 extern bool_t xdr_createargs(XDR *, nfscreateargs*);
271 extern bool_t xdr_renameargs(XDR *, nfsrenameargs*);
272 extern bool_t xdr_linkargs(XDR *, nfslinkargs*);
273 extern bool_t xdr_symlinkargs(XDR *, nfssymlinkargs*);
274 extern bool_t xdr_nfscookie(XDR *, nfscookie);
275 extern bool_t xdr_readdirargs(XDR *, nfsreaddirargs*);
276 extern bool_t xdr_entry(XDR *, nfsentry*);
277 extern bool_t xdr_dirlist(XDR *, nfsdirlist*);
278 extern bool_t xdr_readdirres(XDR *, nfsreaddirres*);
279 extern bool_t xdr_statfsokres(XDR *, nfsstatfsokres*);
280 extern bool_t xdr_statfsres(XDR *, nfsstatfsres*);
281 
282 
283 /*
284  * STRUCTURES:
285  */
286 
287 struct nfs_fh {
288   char fh_data[NFS_FHSIZE];
289 };
290 
291 struct nfstime {
292   u_int nt_seconds;
293   u_int nt_useconds;
294 };
295 
296 struct fattr {
297   nfsftype na_type;
298   u_int na_mode;
299   u_int na_nlink;
300   u_int na_uid;
301   u_int na_gid;
302   u_int na_size;
303   u_int na_blocksize;
304   u_int na_rdev;
305   u_int na_blocks;
306   u_int na_fsid;
307   u_int na_fileid;
308   nfstime na_atime;
309   nfstime na_mtime;
310   nfstime na_ctime;
311 };
312 
313 struct sattr {
314   u_int sa_mode;
315   u_int sa_uid;
316   u_int sa_gid;
317   u_int sa_size;
318   nfstime sa_atime;
319   nfstime sa_mtime;
320 };
321 
322 struct attrstat {
323   nfsstat ns_status;
324   union {
325     nfsfattr ns_attr_u;
326   } ns_u;
327 };
328 
329 struct sattrargs {
330   nfs_fh sag_fhandle;
331   nfssattr sag_attributes;
332 };
333 
334 struct diropargs {
335   nfs_fh da_fhandle;		/* was dir */
336   filename da_name;
337 };
338 
339 struct diropokres {
340   nfs_fh drok_fhandle;
341   nfsfattr drok_attributes;
342 };
343 
344 struct diropres {
345   nfsstat dr_status;		/* was status */
346   union {
347     nfsdiropokres dr_drok_u;	/* was diropres */
348   } dr_u;			/* was diropres_u */
349 };
350 
351 struct readlinkres {
352   nfsstat rlr_status;
353   union {
354     nfspath rlr_data_u;
355   } rlr_u;
356 };
357 
358 struct readargs {
359   nfs_fh ra_fhandle;
360   u_int ra_offset;
361   u_int ra_count;
362   u_int ra_totalcount;
363 };
364 
365 struct readokres {
366   nfsfattr raok_attributes;
367   struct {
368     u_int raok_len_u;
369     char *raok_val_u;
370   } raok_u;
371 };
372 
373 struct readres {
374   nfsstat rr_status;
375   union {
376     nfsreadokres rr_reply_u;
377   } rr_u;
378 };
379 
380 struct writeargs {
381   nfs_fh wra_fhandle;
382   u_int wra_beginoffset;
383   u_int wra_offset;
384   u_int wra_totalcount;
385   struct {
386     u_int wra_len_u;
387     char *wra_val_u;
388   } wra_u;
389 };
390 
391 struct createargs {
392   nfsdiropargs ca_where;
393   nfssattr ca_attributes;
394 };
395 
396 struct renameargs {
397   nfsdiropargs rna_from;
398   nfsdiropargs rna_to;
399 };
400 
401 struct linkargs {
402   nfs_fh la_fhandle;
403   nfsdiropargs la_to;
404 };
405 
406 struct symlinkargs {
407   nfsdiropargs sla_from;
408   nfspath sla_to;
409   nfssattr sla_attributes;
410 };
411 
412 struct readdirargs {
413   nfs_fh rda_fhandle;
414   nfscookie rda_cookie;
415   u_int rda_count;
416 };
417 
418 struct entry {
419   u_int ne_fileid;
420   filename ne_name;
421   nfscookie ne_cookie;
422   nfsentry *ne_nextentry;
423 };
424 
425 struct dirlist {
426   nfsentry *dl_entries;
427   bool_t dl_eof;
428 };
429 
430 struct readdirres {
431   nfsstat rdr_status;
432   union {
433     nfsdirlist rdr_reply_u;
434   } rdr_u;
435 };
436 
437 struct statfsokres {
438   u_int sfrok_tsize;
439   u_int sfrok_bsize;
440   u_int sfrok_blocks;
441   u_int sfrok_bfree;
442   u_int sfrok_bavail;
443 };
444 
445 struct statfsres {
446   nfsstat sfr_status;
447   union {
448     nfsstatfsokres sfr_reply_u;
449   } sfr_u;
450 };
451 
452 #endif /* not _AMU_NFS_PROT_H */
453