1/*	$NetBSD$	*/
2
3/*
4 * Copyright (c) 1997-2009 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. All advertising materials mentioning features or use of this software
22 *    must display the following acknowledgment:
23 *      This product includes software developed by the University of
24 *      California, Berkeley and its contributors.
25 * 4. Neither the name of the University nor the names of its contributors
26 *    may be used to endorse or promote products derived from this software
27 *    without specific prior written permission.
28 *
29 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
30 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
31 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
32 * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
33 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
34 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
35 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
36 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
37 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
38 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
39 * SUCH DAMAGE.
40 *
41 *
42 * File: am-utils/conf/nfs_prot/nfs_prot_osf5.h
43 *
44 */
45
46#ifndef _AMU_NFS_PROT_H
47#define _AMU_NFS_PROT_H
48
49#ifdef HAVE_RPCSVC_NFS_PROT_H
50# include <rpcsvc/nfs_prot.h>
51#endif /* HAVE_RPCSVC_NFS_PROT_H */
52#ifdef HAVE_NFS_NFS_H
53# include <nfs/nfs.h>
54#endif /* HAVE_NFS_NFS_H */
55#ifdef HAVE_RPCSVC_MOUNTV3_H
56# include <rpcsvc/mountv3.h>
57#endif /* HAVE_RPCSVC_MOUNTV3_H */
58#ifdef HAVE_RPC_RPC_H
59# include <rpc/rpc.h>
60#endif /* HAVE_RPC_RPC_H */
61
62/* avoid conflicts with Irix's EFS */
63#undef MOUNT_EFS		/* DCE Episode FS */
64
65/*
66 * The NFSMNT_AUTO flag in Tru64 UNIX V5 has two effects: it causes df and
67 * mount not to display this mount point without the -e switch, as it did in
68 * previous releases.  Unfortunately it also ignores the timeo mount option,
69 * disables the usual timeout backof and enforces a timeout of NFS_MAXTIMO
70 * (20 seconds) instead.  This breaks amd which can sometimes take longer to
71 * respond to an NFS request, causing `nfs server not responding still trying'
72 * messages.
73 *
74 * To avoid this, we need to completely disable this flag on automount points,
75 * with the unfortunate side effect that they are no longer hidden in df and
76 * mount output.
77 */
78#undef MNT2_NFS_OPT_AUTO
79
80/*
81 * MACROS
82 */
83
84#define NFS_PORT 2049
85#define NFS_MAXDATA 8192
86#define NFS_MAXPATHLEN 1024
87#define NFS_MAXNAMLEN 255
88#define NFS_FHSIZE 32
89#define NFS_COOKIESIZE 4
90#define	MNTPATHLEN 1024
91#define	MNTNAMLEN 255
92
93#define NFSMODE_FMT 0170000
94#define NFSMODE_DIR 0040000
95#define NFSMODE_CHR 0020000
96#define NFSMODE_BLK 0060000
97#define NFSMODE_REG 0100000
98#define NFSMODE_LNK 0120000
99#define NFSMODE_SOCK 0140000
100#define NFSMODE_FIFO 0010000
101
102#ifndef NFS_PROGRAM
103# define NFS_PROGRAM ((u_long)100003)
104#endif /* not NFS_PROGRAM */
105#ifndef NFS_VERSION
106# define NFS_VERSION ((u_long)2)
107#endif /* not NFS_VERSION */
108
109#define NFSPROC_NULL ((u_long)0)
110#define NFSPROC_GETATTR ((u_long)1)
111#define NFSPROC_SETATTR ((u_long)2)
112#define NFSPROC_ROOT ((u_long)3)
113#define NFSPROC_LOOKUP ((u_long)4)
114#define NFSPROC_READLINK ((u_long)5)
115#define NFSPROC_READ ((u_long)6)
116#define NFSPROC_WRITECACHE ((u_long)7)
117#define NFSPROC_WRITE ((u_long)8)
118#define NFSPROC_CREATE ((u_long)9)
119#define NFSPROC_REMOVE ((u_long)10)
120#define NFSPROC_RENAME ((u_long)11)
121#define NFSPROC_LINK ((u_long)12)
122#define NFSPROC_SYMLINK ((u_long)13)
123#define NFSPROC_MKDIR ((u_long)14)
124#define NFSPROC_RMDIR ((u_long)15)
125#define NFSPROC_READDIR ((u_long)16)
126#define NFSPROC_STATFS ((u_long)17)
127
128/* map field names */
129#define ml_hostname	ml_name
130#define ml_directory	ml_path
131#define ml_next		ml_nxt
132#define	gr_next		g_next
133#define gr_name		g_name
134#define ex_dir		ex_name
135
136#define drok_attributes	drok_attr
137#define na_fileid	na_nodeid
138#define la_fhandle	la_from
139#define nt_seconds	tv_sec
140#define nt_useconds	tv_usec
141#define ra_totalcount	ra_totcount
142#define sla_to		sla_tnm
143#define sla_attributes	sla_sa
144#define sag_fhandle	saa_fh
145#define sag_attributes	saa_sa
146#define sfrok_tsize	fsok_tsize
147#define sfrok_bsize	fsok_bsize
148#define sfrok_blocks	fsok_blocks
149#define sfrok_bfree	fsok_bfree
150#define sfrok_bavail	fsok_bavail
151#define sfr_status	fs_status
152#define sfr_u		fs_u
153#define sfr_reply_u	fs_fsok_u
154#define wra_fhandle	wa_fhandle
155#define wra_beginoffset	wa_begoff
156#define wra_offset	wa_offset
157#define wra_totalcount	wa_totcount
158#define wra_u		wa_mbuf->m_hdr
159#define wra_val_u	mh_data
160#define wra_len_u	mh_len
161
162
163/*
164 * TYPEDEFS:
165 */
166typedef char *dirpath;
167typedef char *filename;
168typedef char *name;
169typedef char *nfspath;
170typedef char nfscookie[NFS_COOKIESIZE];
171typedef enum nfsftype nfsftype;
172typedef enum nfsstat nfsstat;
173typedef struct nfssvcfh fhandle;
174typedef struct nfsattrstat nfsattrstat;
175typedef struct nfscreateargs nfscreateargs;
176typedef struct nfsdirlist nfsdirlist;
177typedef struct nfsdiropargs nfsdiropargs;
178typedef struct nfsdrok nfsdiropokres;
179typedef struct nfsdiropres nfsdiropres;
180typedef struct nfsentry nfsentry;
181typedef struct exports *exports;
182typedef struct exports exportnode;
183typedef struct nfsfattr nfsfattr;
184typedef struct fhstatus fhstatus;
185typedef struct groups *groups;
186typedef struct groups groupnode;
187typedef struct nfslinkargs nfslinkargs;
188typedef struct mountlist *mountlist;
189typedef struct mountlist mountbody;
190typedef struct _nfs_fh _nfs_fh;
191typedef struct timeval nfstime;
192typedef struct nfsreadargs nfsreadargs;
193typedef struct nfsreaddirargs nfsreaddirargs;
194typedef struct nfsreaddirres nfsreaddirres;
195typedef struct nfsreadlinkres nfsreadlinkres;
196typedef struct nfsreadokres nfsreadokres;
197typedef struct nfsreadres nfsreadres;
198typedef struct nfsrenameargs nfsrenameargs;
199typedef struct nfssattr nfssattr;
200typedef struct nfssaargs nfssattrargs;
201typedef struct nfsstatfsok nfsstatfsokres;
202typedef struct nfsstatfs nfsstatfsres;
203typedef struct nfsslargs nfssymlinkargs;
204typedef struct nfswriteargs nfswriteargs;
205
206
207/*
208 * EXTERNALS:
209 */
210
211extern void *nfsproc_null_2_svc(void *, struct svc_req *);
212extern nfsattrstat *nfsproc_getattr_2_svc(struct nfssvcfh *, struct svc_req *);
213extern nfsattrstat *nfsproc_setattr_2_svc(nfssattrargs *, struct svc_req *);
214extern void *nfsproc_root_2_svc(void *, struct svc_req *);
215extern nfsdiropres *nfsproc_lookup_2_svc(nfsdiropargs *, struct svc_req *);
216extern nfsreadlinkres *nfsproc_readlink_2_svc(struct nfssvcfh *, struct svc_req *);
217extern nfsreadres *nfsproc_read_2_svc(nfsreadargs *, struct svc_req *);
218extern void *nfsproc_writecache_2_svc(void *, struct svc_req *);
219extern nfsattrstat *nfsproc_write_2_svc(nfswriteargs *, struct svc_req *);
220extern nfsdiropres *nfsproc_create_2_svc(nfscreateargs *, struct svc_req *);
221extern nfsstat *nfsproc_remove_2_svc(nfsdiropargs *, struct svc_req *);
222extern nfsstat *nfsproc_rename_2_svc(nfsrenameargs *, struct svc_req *);
223extern nfsstat *nfsproc_link_2_svc(nfslinkargs *, struct svc_req *);
224extern nfsstat *nfsproc_symlink_2_svc(nfssymlinkargs *, struct svc_req *);
225extern nfsdiropres *nfsproc_mkdir_2_svc(nfscreateargs *, struct svc_req *);
226extern nfsstat *nfsproc_rmdir_2_svc(nfsdiropargs *, struct svc_req *);
227extern nfsreaddirres *nfsproc_readdir_2_svc(nfsreaddirargs *, struct svc_req *);
228extern nfsstatfsres *nfsproc_statfs_2_svc(struct nfssvcfh *, struct svc_req *);
229
230extern bool_t xdr_nfsstat(XDR *, nfsstat*);
231extern bool_t xdr_ftype(XDR *, nfsftype*);
232extern bool_t xdr_nfs_fh(XDR *, struct nfssvcfh*);
233extern bool_t xdr_nfstime(XDR *, nfstime*);
234extern bool_t xdr_fattr(XDR *, nfsfattr*);
235extern bool_t xdr_sattr(XDR *, nfssattr*);
236extern bool_t xdr_filename(XDR *, filename*);
237extern bool_t xdr_nfspath(XDR *, nfspath*);
238extern bool_t xdr_attrstat(XDR *, nfsattrstat*);
239extern bool_t xdr_sattrargs(XDR *, nfssattrargs*);
240extern bool_t xdr_diropargs(XDR *, nfsdiropargs*);
241extern bool_t xdr_diropokres(XDR *, nfsdiropokres*);
242extern bool_t xdr_diropres(XDR *, nfsdiropres*);
243extern bool_t xdr_readlinkres(XDR *, nfsreadlinkres*);
244extern bool_t xdr_readargs(XDR *, nfsreadargs*);
245extern bool_t xdr_readokres(XDR *, nfsreadokres*);
246extern bool_t xdr_readres(XDR *, nfsreadres*);
247extern bool_t xdr_writeargs(XDR *, nfswriteargs*);
248extern bool_t xdr_createargs(XDR *, nfscreateargs*);
249extern bool_t xdr_renameargs(XDR *, nfsrenameargs*);
250extern bool_t xdr_linkargs(XDR *, nfslinkargs*);
251extern bool_t xdr_symlinkargs(XDR *, nfssymlinkargs*);
252extern bool_t xdr_nfscookie(XDR *, nfscookie);
253extern bool_t xdr_readdirargs(XDR *, nfsreaddirargs*);
254extern bool_t xdr_entry(XDR *, nfsentry*);
255extern bool_t xdr_dirlist(XDR *, nfsdirlist*);
256extern bool_t xdr_readdirres(XDR *, nfsreaddirres*);
257extern bool_t xdr_statfsokres(XDR *, nfsstatfsokres*);
258extern bool_t xdr_statfsres(XDR *, nfsstatfsres*);
259
260
261/*
262 * STRUCTURES:
263 */
264
265struct _nfs_fh {
266  char data[NFS_FHSIZE];
267};
268
269struct nfstime {
270  u_int nt_seconds;
271  u_int nt_useconds;
272};
273
274struct _fattr {
275  nfsftype na_type;
276  u_int na_mode;
277  u_int na_nlink;
278  u_int na_uid;
279  u_int na_gid;
280  u_int na_size;
281  u_int na_blocksize;
282  u_int na_rdev;
283  u_int na_blocks;
284  u_int na_fsid;
285  u_int na_fileid;
286  nfstime na_atime;
287  nfstime na_mtime;
288  nfstime na_ctime;
289};
290
291struct _sattr {
292  u_int sa_mode;
293  u_int sa_uid;
294  u_int sa_gid;
295  u_int sa_size;
296  nfstime sa_atime;
297  nfstime sa_mtime;
298};
299
300struct _attrstat {
301  nfsstat ns_status;
302  union {
303    nfsfattr ns_attr_u;
304  } ns_u;
305};
306
307struct _sattrargs {
308  struct nfssvcfh sag_fhandle;
309  nfssattr sag_attributes;
310};
311
312struct _diropargs {
313  struct nfssvcfh da_fhandle;		/* was dir */
314  filename da_name;
315};
316
317struct _diropokres {
318  struct nfssvcfh drok_fhandle;
319  nfsfattr drok_attributes;
320};
321
322struct _diropres {
323  nfsstat dr_status;		/* was status */
324  union {
325    nfsdiropokres dr_drok_u;	/* was diropres */
326  } dr_u;			/* was diropres_u */
327};
328
329struct nfsreadlinkres {
330  nfsstat rlr_status;
331  union {
332    nfspath rlr_data_u;
333  } rlr_u;
334};
335
336struct _readargs {
337  struct nfssvcfh ra_fhandle;
338  u_int ra_offset;
339  u_int ra_count;
340  u_int ra_totalcount;
341};
342
343struct nfsreadokres {
344  nfsfattr raok_attributes;
345  struct {
346    u_int raok_len_u;
347    char *raok_val_u;
348  } raok_u;
349};
350
351struct nfsreadres {
352  nfsstat rr_status;
353  union {
354    nfsreadokres rr_reply_u;
355  } rr_u;
356};
357
358#if 0
359struct _writeargs {
360  struct nfssvcfh wra_fhandle;
361  u_int wra_beginoffset;
362  u_int wra_offset;
363  u_int wra_totalcount;
364  struct {
365    u_int wra_len_u;
366    char *wra_val_u;
367  } wra_u;
368};
369#endif /* 0 */
370
371struct nfscreateargs {
372  nfsdiropargs ca_where;
373  nfssattr ca_attributes;
374};
375
376struct nfsrenameargs {
377  nfsdiropargs rna_from;
378  nfsdiropargs rna_to;
379};
380
381struct _linkargs {
382  struct nfssvcfh la_fhandle;
383  nfsdiropargs la_to;
384};
385
386struct _symlinkargs {
387  nfsdiropargs sla_from;
388  nfspath sla_to;
389  nfssattr sla_attributes;
390};
391
392struct nfsreaddirargs {
393  struct nfssvcfh rda_fhandle;
394  nfscookie rda_cookie;
395  u_int rda_count;
396};
397
398struct nfsentry {
399  u_int ne_fileid;
400  filename ne_name;
401  nfscookie ne_cookie;
402  nfsentry *ne_nextentry;
403};
404
405struct nfsdirlist {
406  nfsentry *dl_entries;
407  bool_t dl_eof;
408};
409
410struct nfsreaddirres {
411  nfsstat rdr_status;
412  union {
413    nfsdirlist rdr_reply_u;
414  } rdr_u;
415};
416
417struct _statfsokres {
418  u_int sfrok_tsize;
419  u_int sfrok_bsize;
420  u_int sfrok_blocks;
421  u_int sfrok_bfree;
422  u_int sfrok_bavail;
423};
424
425struct _statfsres {
426  nfsstat sfr_status;
427  union {
428    nfsstatfsokres sfr_reply_u;
429  } sfr_u;
430};
431
432/*
433 **************************************************************************
434 * Tru64 5.1's autofs is not ported or tested yet...
435 * For now, undefine it or define dummy entries.
436 **************************************************************************
437 */
438#ifdef MNTTYPE_AUTOFS
439# undef MNTTYPE_AUTOFS
440#endif /* MNTTYPE_AUTOFS */
441#ifdef MNTTAB_TYPE_AUTOFS
442# undef MNTTAB_TYPE_AUTOFS
443#endif /* MNTTAB_TYPE_AUTOFS */
444#ifdef HAVE_FS_AUTOFS
445# undef HAVE_FS_AUTOFS
446#endif /* HAVE_FS_AUTOFS */
447
448#endif /* not _AMU_NFS_PROT_H */
449