1/*
2 * linux/include/linux/nfsd/nfsd.h
3 *
4 * Hodge-podge collection of knfsd-related stuff.
5 * I will sort this out later.
6 *
7 * Copyright (C) 1995-1997 Olaf Kirch <okir@monad.swb.de>
8 */
9
10#ifndef LINUX_NFSD_NFSD_H
11#define LINUX_NFSD_NFSD_H
12
13#include <linux/config.h>
14#include <linux/types.h>
15#include <linux/unistd.h>
16#include <linux/dirent.h>
17#include <linux/fs.h>
18
19#include <linux/nfsd/debug.h>
20#include <linux/nfsd/nfsfh.h>
21#include <linux/nfsd/export.h>
22#include <linux/nfsd/auth.h>
23#include <linux/nfsd/stats.h>
24#include <linux/nfsd/interface.h>
25/*
26 * nfsd version
27 */
28#define NFSD_VERSION		"0.5"
29
30#ifdef __KERNEL__
31/*
32 * Special flags for nfsd_permission. These must be different from MAY_READ,
33 * MAY_WRITE, and MAY_EXEC.
34 */
35#define MAY_NOP			0
36#define MAY_SATTR		8
37#define MAY_TRUNC		16
38#define MAY_LOCK		32
39#define MAY_OWNER_OVERRIDE	64
40#define _NFSD_IRIX_BOGOSITY	128
41#if (MAY_SATTR | MAY_TRUNC | MAY_LOCK | MAY_OWNER_OVERRIDE | _NFSD_IRIX_BOGOSITY) & (MAY_READ | MAY_WRITE | MAY_EXEC)
42# error "please use a different value for MAY_SATTR or MAY_TRUNC or MAY_LOCK or MAY_OWNER_OVERRIDE."
43#endif
44#define MAY_CREATE		(MAY_EXEC|MAY_WRITE)
45#define MAY_REMOVE		(MAY_EXEC|MAY_WRITE|MAY_TRUNC)
46
47/*
48 * Callback function for readdir
49 */
50struct readdir_cd {
51	struct svc_rqst *	rqstp;
52	struct svc_fh *		dirfh;
53	u32 *			buffer;
54	int			buflen;
55	u32 *			offset;		/* previous dirent->d_next */
56	char			plus;		/* readdirplus */
57	char			eob;		/* end of buffer */
58	char			dotonly;
59};
60typedef int		(*encode_dent_fn)(struct readdir_cd *, const char *,
61						int, loff_t, ino_t, unsigned int);
62typedef int (*nfsd_dirop_t)(struct inode *, struct dentry *, int, int);
63
64/*
65 * Procedure table for NFSv2
66 */
67extern struct svc_procedure	nfsd_procedures2[];
68#ifdef CONFIG_NFSD_V3
69extern struct svc_procedure	nfsd_procedures3[];
70#endif /* CONFIG_NFSD_V3 */
71extern struct svc_program	nfsd_program;
72
73/*
74 * Function prototypes.
75 */
76int		nfsd_svc(unsigned short port, int nrservs);
77
78/* nfsd/vfs.c */
79int		fh_lock_parent(struct svc_fh *, struct dentry *);
80int		nfsd_racache_init(int);
81void		nfsd_racache_shutdown(void);
82int		nfsd_lookup(struct svc_rqst *, struct svc_fh *,
83				const char *, int, struct svc_fh *);
84int		nfsd_setattr(struct svc_rqst *, struct svc_fh *,
85				struct iattr *, int, time_t);
86int		nfsd_create(struct svc_rqst *, struct svc_fh *,
87				char *name, int len, struct iattr *attrs,
88				int type, dev_t rdev, struct svc_fh *res);
89#ifdef CONFIG_NFSD_V3
90int		nfsd_access(struct svc_rqst *, struct svc_fh *, u32 *);
91int		nfsd_create_v3(struct svc_rqst *, struct svc_fh *,
92				char *name, int len, struct iattr *attrs,
93				struct svc_fh *res, int createmode,
94				u32 *verifier);
95int		nfsd_commit(struct svc_rqst *, struct svc_fh *,
96				off_t, unsigned long);
97#endif /* CONFIG_NFSD_V3 */
98int		nfsd_open(struct svc_rqst *, struct svc_fh *, int,
99				int, struct file *);
100void		nfsd_close(struct file *);
101int		nfsd_read(struct svc_rqst *, struct svc_fh *,
102				loff_t, char *, unsigned long *);
103int		nfsd_write(struct svc_rqst *, struct svc_fh *,
104				loff_t, char *, unsigned long, int *);
105int		nfsd_readlink(struct svc_rqst *, struct svc_fh *,
106				char *, int *);
107int		nfsd_symlink(struct svc_rqst *, struct svc_fh *,
108				char *name, int len, char *path, int plen,
109				struct svc_fh *res, struct iattr *);
110int		nfsd_link(struct svc_rqst *, struct svc_fh *,
111				char *, int, struct svc_fh *);
112int		nfsd_rename(struct svc_rqst *,
113				struct svc_fh *, char *, int,
114				struct svc_fh *, char *, int);
115int		nfsd_remove(struct svc_rqst *,
116				struct svc_fh *, char *, int);
117int		nfsd_unlink(struct svc_rqst *, struct svc_fh *, int type,
118				char *name, int len);
119int		nfsd_truncate(struct svc_rqst *, struct svc_fh *,
120				unsigned long size);
121int		nfsd_readdir(struct svc_rqst *, struct svc_fh *,
122				loff_t, encode_dent_fn,
123				u32 *buffer, int *countp, u32 *verf);
124int		nfsd_statfs(struct svc_rqst *, struct svc_fh *,
125				struct statfs *);
126
127int		nfsd_notify_change(struct inode *, struct iattr *);
128int		nfsd_permission(struct svc_export *, struct dentry *, int);
129
130
131/*
132 * lockd binding
133 */
134void		nfsd_lockd_init(void);
135void		nfsd_lockd_shutdown(void);
136void		nfsd_lockd_unexport(struct svc_client *);
137
138
139/*
140 * These macros provide pre-xdr'ed values for faster operation.
141 */
142#define	nfs_ok			__constant_htonl(NFS_OK)
143#define	nfserr_perm		__constant_htonl(NFSERR_PERM)
144#define	nfserr_noent		__constant_htonl(NFSERR_NOENT)
145#define	nfserr_io		__constant_htonl(NFSERR_IO)
146#define	nfserr_nxio		__constant_htonl(NFSERR_NXIO)
147#define	nfserr_eagain		__constant_htonl(NFSERR_EAGAIN)
148#define	nfserr_acces		__constant_htonl(NFSERR_ACCES)
149#define	nfserr_exist		__constant_htonl(NFSERR_EXIST)
150#define	nfserr_xdev		__constant_htonl(NFSERR_XDEV)
151#define	nfserr_nodev		__constant_htonl(NFSERR_NODEV)
152#define	nfserr_notdir		__constant_htonl(NFSERR_NOTDIR)
153#define	nfserr_isdir		__constant_htonl(NFSERR_ISDIR)
154#define	nfserr_inval		__constant_htonl(NFSERR_INVAL)
155#define	nfserr_fbig		__constant_htonl(NFSERR_FBIG)
156#define	nfserr_nospc		__constant_htonl(NFSERR_NOSPC)
157#define	nfserr_rofs		__constant_htonl(NFSERR_ROFS)
158#define	nfserr_mlink		__constant_htonl(NFSERR_MLINK)
159#define	nfserr_opnotsupp	__constant_htonl(NFSERR_OPNOTSUPP)
160#define	nfserr_nametoolong	__constant_htonl(NFSERR_NAMETOOLONG)
161#define	nfserr_notempty		__constant_htonl(NFSERR_NOTEMPTY)
162#define	nfserr_dquot		__constant_htonl(NFSERR_DQUOT)
163#define	nfserr_stale		__constant_htonl(NFSERR_STALE)
164#define	nfserr_remote		__constant_htonl(NFSERR_REMOTE)
165#define	nfserr_wflush		__constant_htonl(NFSERR_WFLUSH)
166#define	nfserr_badhandle	__constant_htonl(NFSERR_BADHANDLE)
167#define	nfserr_notsync		__constant_htonl(NFSERR_NOT_SYNC)
168#define	nfserr_badcookie	__constant_htonl(NFSERR_BAD_COOKIE)
169#define	nfserr_notsupp		__constant_htonl(NFSERR_NOTSUPP)
170#define	nfserr_toosmall		__constant_htonl(NFSERR_TOOSMALL)
171#define	nfserr_serverfault	__constant_htonl(NFSERR_SERVERFAULT)
172#define	nfserr_badtype		__constant_htonl(NFSERR_BADTYPE)
173#define	nfserr_jukebox		__constant_htonl(NFSERR_JUKEBOX)
174
175/* error code for internal use - if a request fails due to
176 * kmalloc failure, it gets dropped.  Client should resend eventually
177 */
178#define	nfserr_dropit		__constant_htonl(30000)
179
180/* Check for dir entries '.' and '..' */
181#define isdotent(n, l)	(l < 3 && n[0] == '.' && (l == 1 || n[1] == '.'))
182
183/*
184 * Time of server startup
185 */
186extern struct timeval	nfssvc_boot;
187
188#endif /* __KERNEL__ */
189
190#endif /* LINUX_NFSD_NFSD_H */
191