blob: 7898c997dfea400438f4f9700293f939f38b72ea [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * include/linux/nfsd/export.h
3 *
4 * Public declarations for NFS exports. The definitions for the
5 * syscall interface are in nfsctl.h
6 *
7 * Copyright (C) 1995-1997 Olaf Kirch <okir@monad.swb.de>
8 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07009#ifndef NFSD_EXPORT_H
10#define NFSD_EXPORT_H
11
Boaz Harrosh72579ac2009-12-03 20:28:59 +020012# include <linux/nfsd/nfsfh.h>
David Howells616d1ca2012-10-09 09:49:02 +010013#include <uapi/linux/nfsd/export.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070014
Manoj Naik933469192006-10-04 02:16:18 -070015/*
16 * FS Locations
17 */
18
19#define MAX_FS_LOCATIONS 128
20
21struct nfsd4_fs_location {
22 char *hosts; /* colon separated list of hosts */
23 char *path; /* slash separated list of path components */
24};
25
26struct nfsd4_fs_locations {
27 uint32_t locations_count;
28 struct nfsd4_fs_location *locations;
29/* If we're not actually serving this data ourselves (only providing a
30 * list of replicas that do serve it) then we set "migrated": */
31 int migrated;
32};
33
Andy Adamsone677bfe2007-07-17 04:04:42 -070034/*
35 * We keep an array of pseudoflavors with the export, in order from most
Lucas De Marchi25985ed2011-03-30 22:57:33 -030036 * to least preferred. For the foreseeable future, we don't expect more
Andy Adamsone677bfe2007-07-17 04:04:42 -070037 * than the eight pseudoflavors null, unix, krb5, krb5i, krb5p, skpm3,
38 * spkm3i, and spkm3p (and using all 8 at once should be rare).
39 */
40#define MAX_SECINFO_LIST 8
41
42struct exp_flavor_info {
43 u32 pseudoflavor;
44 u32 flags;
45};
46
Linus Torvalds1da177e2005-04-16 15:20:36 -070047struct svc_export {
48 struct cache_head h;
49 struct auth_domain * ex_client;
50 int ex_flags;
Jan Blunck54775492008-02-14 19:38:39 -080051 struct path ex_path;
Eric W. Biederman4c1e1b32013-02-02 06:42:53 -080052 kuid_t ex_anon_uid;
53 kgid_t ex_anon_gid;
Linus Torvalds1da177e2005-04-16 15:20:36 -070054 int ex_fsid;
NeilBrownaf6a4e22007-02-14 00:33:12 -080055 unsigned char * ex_uuid; /* 16 byte fsid */
Manoj Naik933469192006-10-04 02:16:18 -070056 struct nfsd4_fs_locations ex_fslocs;
Andy Adamsone677bfe2007-07-17 04:04:42 -070057 int ex_nflavors;
58 struct exp_flavor_info ex_flavors[MAX_SECINFO_LIST];
Stanislav Kinsburskydb3a3532012-03-28 19:09:08 +040059 struct cache_detail *cd;
Linus Torvalds1da177e2005-04-16 15:20:36 -070060};
61
62/* an "export key" (expkey) maps a filehandlefragement to an
NeilBrownaf6a4e22007-02-14 00:33:12 -080063 * svc_export for a given client. There can be several per export,
64 * for the different fsid types.
Linus Torvalds1da177e2005-04-16 15:20:36 -070065 */
66struct svc_expkey {
67 struct cache_head h;
68
69 struct auth_domain * ek_client;
70 int ek_fsidtype;
NeilBrownaf6a4e22007-02-14 00:33:12 -080071 u32 ek_fsid[6];
Linus Torvalds1da177e2005-04-16 15:20:36 -070072
Jan Bluncke83aece2008-02-14 19:38:41 -080073 struct path ek_path;
Linus Torvalds1da177e2005-04-16 15:20:36 -070074};
75
Linus Torvalds1da177e2005-04-16 15:20:36 -070076#define EX_ISSYNC(exp) (!((exp)->ex_flags & NFSEXP_ASYNC))
Linus Torvalds1da177e2005-04-16 15:20:36 -070077#define EX_NOHIDE(exp) ((exp)->ex_flags & NFSEXP_NOHIDE)
78#define EX_WGATHER(exp) ((exp)->ex_flags & NFSEXP_GATHERED_WRITES)
79
J. Bruce Fieldsc7d51402007-07-19 01:49:20 -070080int nfsexp_flags(struct svc_rqst *rqstp, struct svc_export *exp);
Andy Adamson32c1eb02007-07-17 04:04:48 -070081__be32 check_nfsd_access(struct svc_export *exp, struct svc_rqst *rqstp);
Linus Torvalds1da177e2005-04-16 15:20:36 -070082
83/*
84 * Function declarations
85 */
Stanislav Kinsburskyb89109b2012-04-11 15:13:14 +040086int nfsd_export_init(struct net *);
87void nfsd_export_shutdown(struct net *);
Stanislav Kinsburskyb3853e02012-04-11 15:13:21 +040088void nfsd_export_flush(struct net *);
J. Bruce Fields0989a782007-07-17 04:04:44 -070089struct svc_export * rqst_exp_get_by_name(struct svc_rqst *,
Al Viro91c9fa82009-04-18 02:42:05 -040090 struct path *);
J. Bruce Fields0989a782007-07-17 04:04:44 -070091struct svc_export * rqst_exp_parent(struct svc_rqst *,
Al Viroe64c3902009-04-18 03:00:46 -040092 struct path *);
Trond Myklebusted748aa2011-09-12 19:37:06 -040093struct svc_export * rqst_find_fsidzero_export(struct svc_rqst *);
Stanislav Kinsburskyb3853e02012-04-11 15:13:21 +040094int exp_rootfh(struct net *, struct auth_domain *,
Linus Torvalds1da177e2005-04-16 15:20:36 -070095 char *path, struct knfsd_fh *, int maxsize);
J. Bruce Fieldsdf547ef2007-07-17 04:04:43 -070096__be32 exp_pseudoroot(struct svc_rqst *, struct svc_fh *);
Al Viro63f103112006-10-19 23:28:54 -070097__be32 nfserrno(int errno);
Linus Torvalds1da177e2005-04-16 15:20:36 -070098
Linus Torvalds1da177e2005-04-16 15:20:36 -070099static inline void exp_put(struct svc_export *exp)
100{
Stanislav Kinsbursky71234972012-03-28 19:09:15 +0400101 cache_put(&exp->h, exp->cd);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700102}
103
104static inline void exp_get(struct svc_export *exp)
105{
106 cache_get(&exp->h);
107}
J. Bruce Fields0989a782007-07-17 04:04:44 -0700108struct svc_export * rqst_exp_find(struct svc_rqst *, int, u32 *);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700109
Linus Torvalds1da177e2005-04-16 15:20:36 -0700110#endif /* NFSD_EXPORT_H */