1/*	$NetBSD: nfs_prot_osf2.h,v 1.1.1.2 2009/03/20 20:26:51 christos Exp $	*/
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_osf2.h
43 *
44 */
45
46#ifndef _AMU_NFS_PROT_H
47#define _AMU_NFS_PROT_H
48
49#ifdef HAVE_SYS_ERRNO_H
50# include <sys/errno.h>
51#endif /* HAVE_SYS_ERRNO_H */
52#ifdef HAVE_NFS_NFS_H
53# include <nfs/nfs.h>
54#endif /* HAVE_NFS_NFS_H */
55#ifdef HAVE_RPC_RPC_H
56# include <rpc/rpc.h>
57#endif /* HAVE_RPC_RPC_H */
58
59/* avoid conflicts with Irix's EFS */
60#undef MOUNT_EFS		/* DCE Episode FS */
61/* <sys/fs_types.h> includes a global symbol in every module! */
62#define _SYS_FS_TYPES_H_
63
64/*
65 * MACROS
66 */
67
68#define NFS_PORT 2049
69#define NFS_MAXDATA 8192
70#define NFS_MAXPATHLEN 1024
71#define NFS_MAXNAMLEN 255
72#define NFS_FHSIZE 32
73#define NFS_COOKIESIZE 4
74#define	MNTPATHLEN 1024
75#define	MNTNAMLEN 255
76
77#define NFSMODE_FMT 0170000
78#define NFSMODE_DIR 0040000
79#define NFSMODE_CHR 0020000
80#define NFSMODE_BLK 0060000
81#define NFSMODE_REG 0100000
82#define NFSMODE_LNK 0120000
83#define NFSMODE_SOCK 0140000
84#define NFSMODE_FIFO 0010000
85
86#ifndef NFS_PROGRAM
87# define NFS_PROGRAM ((u_long)100003)
88#endif /* not NFS_PROGRAM */
89#ifndef NFS_VERSION
90# define NFS_VERSION ((u_long)2)
91#endif /* not NFS_VERSION */
92
93#define NFSPROC_NULL ((u_long)0)
94#define NFSPROC_GETATTR ((u_long)1)
95#define NFSPROC_SETATTR ((u_long)2)
96#define NFSPROC_ROOT ((u_long)3)
97#define NFSPROC_LOOKUP ((u_long)4)
98#define NFSPROC_READLINK ((u_long)5)
99#define NFSPROC_READ ((u_long)6)
100#define NFSPROC_WRITECACHE ((u_long)7)
101#define NFSPROC_WRITE ((u_long)8)
102#define NFSPROC_CREATE ((u_long)9)
103#define NFSPROC_REMOVE ((u_long)10)
104#define NFSPROC_RENAME ((u_long)11)
105#define NFSPROC_LINK ((u_long)12)
106#define NFSPROC_SYMLINK ((u_long)13)
107#define NFSPROC_MKDIR ((u_long)14)
108#define NFSPROC_RMDIR ((u_long)15)
109#define NFSPROC_READDIR ((u_long)16)
110#define NFSPROC_STATFS ((u_long)17)
111
112/* map field names */
113#define fh_data		fh_bytes
114
115#define ml_hostname	ml_name
116#define ml_directory	ml_path
117#define ml_next		ml_nxt
118#define	gr_next		g_next
119#define gr_name		g_name
120#define ex_dir		ex_name
121
122#define drok_attributes	drok_attr
123#define na_fileid	na_nodeid
124#define la_fhandle	la_from
125#define nt_seconds	tv_sec
126#define nt_useconds	tv_usec
127#define ra_totalcount	ra_totcount
128#define sla_to		sla_tnm
129#define sla_attributes	sla_sa
130#define sag_fhandle	saa_fh
131#define sag_attributes	saa_sa
132#define sfrok_tsize	fsok_tsize
133#define sfrok_bsize	fsok_bsize
134#define sfrok_blocks	fsok_blocks
135#define sfrok_bfree	fsok_bfree
136#define sfrok_bavail	fsok_bavail
137#define sfr_status	fs_status
138#define sfr_u		fs_u
139#define sfr_reply_u	fs_fsok_u
140#define wra_fhandle	wa_fhandle
141#define wra_beginoffset	wa_begoff
142#define wra_offset	wa_offset
143#define wra_totalcount	wa_totcount
144#define wra_u		wa_mbuf->m_hdr
145#define wra_val_u	mh_data
146#define wra_len_u	mh_len
147
148
149/*
150 * TYPEDEFS:
151 */
152typedef char *dirpath;
153typedef char *filename;
154typedef char *name;
155typedef char *nfspath;
156typedef char nfscookie[NFS_COOKIESIZE];
157typedef enum nfsftype nfsftype;
158typedef enum nfsstat nfsstat;
159typedef struct nfssvcfh fhandle;
160typedef struct nfsattrstat nfsattrstat;
161typedef struct nfscreateargs nfscreateargs;
162typedef struct nfsdirlist nfsdirlist;
163typedef struct nfsdiropargs nfsdiropargs;
164typedef struct nfsdrok nfsdiropokres;
165typedef struct nfsdiropres nfsdiropres;
166typedef struct nfsentry nfsentry;
167typedef struct exports *exports;
168typedef struct exports exportnode;
169typedef struct nfsfattr nfsfattr;
170typedef struct fhstatus fhstatus;
171typedef struct groups *groups;
172typedef struct groups groupnode;
173typedef struct nfslinkargs nfslinkargs;
174typedef struct mountlist *mountlist;
175typedef struct mountlist mountbody;
176typedef struct _nfs_fh _nfs_fh;
177typedef struct timeval nfstime;
178typedef struct nfsreadargs nfsreadargs;
179typedef struct nfsreaddirargs nfsreaddirargs;
180typedef struct nfsreaddirres nfsreaddirres;
181typedef struct nfsreadlinkres nfsreadlinkres;
182typedef struct nfsreadokres nfsreadokres;
183typedef struct nfsreadres nfsreadres;
184typedef struct nfsrenameargs nfsrenameargs;
185typedef struct nfssattr nfssattr;
186typedef struct nfssaargs nfssattrargs;
187typedef struct nfsstatfsok nfsstatfsokres;
188typedef struct nfsstatfs nfsstatfsres;
189typedef struct nfsslargs nfssymlinkargs;
190typedef struct nfswriteargs nfswriteargs;
191
192
193/*
194 * EXTERNALS:
195 */
196
197extern void *nfsproc_null_2_svc(void *, struct svc_req *);
198extern nfsattrstat *nfsproc_setattr_2_svc(nfssattrargs *, struct svc_req *);
199extern void *nfsproc_root_2_svc(void *, struct svc_req *);
200extern nfsdiropres *nfsproc_lookup_2_svc(nfsdiropargs *, struct svc_req *);
201extern nfsreadres *nfsproc_read_2_svc(nfsreadargs *, struct svc_req *);
202extern void *nfsproc_writecache_2_svc(void *, struct svc_req *);
203extern nfsattrstat *nfsproc_write_2_svc(nfswriteargs *, struct svc_req *);
204extern nfsdiropres *nfsproc_create_2_svc(nfscreateargs *, struct svc_req *);
205extern nfsstat *nfsproc_remove_2_svc(nfsdiropargs *, struct svc_req *);
206extern nfsstat *nfsproc_rename_2_svc(nfsrenameargs *, struct svc_req *);
207extern nfsstat *nfsproc_link_2_svc(nfslinkargs *, struct svc_req *);
208extern nfsstat *nfsproc_symlink_2_svc(nfssymlinkargs *, struct svc_req *);
209extern nfsdiropres *nfsproc_mkdir_2_svc(nfscreateargs *, struct svc_req *);
210extern nfsstat *nfsproc_rmdir_2_svc(nfsdiropargs *, struct svc_req *);
211extern nfsreaddirres *nfsproc_readdir_2_svc(nfsreaddirargs *, struct svc_req *);
212
213extern bool_t xdr_nfsstat(XDR *, nfsstat*);
214extern bool_t xdr_ftype(XDR *, nfsftype*);
215extern bool_t xdr_nfstime(XDR *, nfstime*);
216extern bool_t xdr_fattr(XDR *, nfsfattr*);
217extern bool_t xdr_sattr(XDR *, nfssattr*);
218extern bool_t xdr_filename(XDR *, filename*);
219extern bool_t xdr_nfspath(XDR *, nfspath*);
220extern bool_t xdr_attrstat(XDR *, nfsattrstat*);
221extern bool_t xdr_sattrargs(XDR *, nfssattrargs*);
222extern bool_t xdr_diropargs(XDR *, nfsdiropargs*);
223extern bool_t xdr_diropokres(XDR *, nfsdiropokres*);
224extern bool_t xdr_diropres(XDR *, nfsdiropres*);
225extern bool_t xdr_readlinkres(XDR *, nfsreadlinkres*);
226extern bool_t xdr_readargs(XDR *, nfsreadargs*);
227extern bool_t xdr_readokres(XDR *, nfsreadokres*);
228extern bool_t xdr_readres(XDR *, nfsreadres*);
229extern bool_t xdr_writeargs(XDR *, nfswriteargs*);
230extern bool_t xdr_createargs(XDR *, nfscreateargs*);
231extern bool_t xdr_renameargs(XDR *, nfsrenameargs*);
232extern bool_t xdr_linkargs(XDR *, nfslinkargs*);
233extern bool_t xdr_symlinkargs(XDR *, nfssymlinkargs*);
234extern bool_t xdr_nfscookie(XDR *, nfscookie);
235extern bool_t xdr_readdirargs(XDR *, nfsreaddirargs*);
236extern bool_t xdr_entry(XDR *, nfsentry*);
237extern bool_t xdr_dirlist(XDR *, nfsdirlist*);
238extern bool_t xdr_readdirres(XDR *, nfsreaddirres*);
239extern bool_t xdr_statfsokres(XDR *, nfsstatfsokres*);
240extern bool_t xdr_statfsres(XDR *, nfsstatfsres*);
241
242
243/*
244 * STRUCTURES:
245 */
246
247struct _nfs_fh {
248  char data[NFS_FHSIZE];
249};
250
251struct nfstime {
252  u_int nt_seconds;
253  u_int nt_useconds;
254};
255
256struct nfsreadlinkres {
257  nfsstat rlr_status;
258  union {
259    nfspath rlr_data_u;
260  } rlr_u;
261};
262
263struct nfsreadokres {
264  nfsfattr raok_attributes;
265  struct {
266    u_int raok_len_u;
267    char *raok_val_u;
268  } raok_u;
269};
270
271struct nfsreadres {
272  nfsstat rr_status;
273  union {
274    nfsreadokres rr_reply_u;
275  } rr_u;
276};
277
278struct nfscreateargs {
279  nfsdiropargs ca_where;
280  nfssattr ca_attributes;
281};
282
283struct nfsrenameargs {
284  nfsdiropargs rna_from;
285  nfsdiropargs rna_to;
286};
287
288struct nfsreaddirargs {
289  nfsv2fh_t rda_fhandle;
290  nfscookie rda_cookie;
291  u_int rda_count;
292};
293
294struct nfsentry {
295  u_int ne_fileid;
296  filename ne_name;
297  nfscookie ne_cookie;
298  nfsentry *ne_nextentry;
299};
300
301struct nfsdirlist {
302  nfsentry *dl_entries;
303  bool_t dl_eof;
304};
305
306struct nfsreaddirres {
307  nfsstat rdr_status;
308  union {
309    nfsdirlist rdr_reply_u;
310  } rdr_u;
311};
312
313#endif /* not _AMU_NFS_PROT_H */
314