Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2 | * Copyright (C) 1995-1997 Olaf Kirch <okir@monad.swb.de> |
| 3 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4 | #ifndef NFSD_EXPORT_H |
| 5 | #define NFSD_EXPORT_H |
| 6 | |
Christoph Hellwig | 9c69de4 | 2014-05-06 19:37:13 +0200 | [diff] [blame] | 7 | #include <linux/sunrpc/cache.h> |
David Howells | 616d1ca | 2012-10-09 09:49:02 +0100 | [diff] [blame] | 8 | #include <uapi/linux/nfsd/export.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 9 | |
Christoph Hellwig | 9c69de4 | 2014-05-06 19:37:13 +0200 | [diff] [blame] | 10 | struct knfsd_fh; |
| 11 | struct svc_fh; |
| 12 | struct svc_rqst; |
| 13 | |
Manoj Naik | 93346919 | 2006-10-04 02:16:18 -0700 | [diff] [blame] | 14 | /* |
| 15 | * FS Locations |
| 16 | */ |
| 17 | |
| 18 | #define MAX_FS_LOCATIONS 128 |
| 19 | |
| 20 | struct nfsd4_fs_location { |
| 21 | char *hosts; /* colon separated list of hosts */ |
| 22 | char *path; /* slash separated list of path components */ |
| 23 | }; |
| 24 | |
| 25 | struct nfsd4_fs_locations { |
| 26 | uint32_t locations_count; |
| 27 | struct nfsd4_fs_location *locations; |
| 28 | /* If we're not actually serving this data ourselves (only providing a |
| 29 | * list of replicas that do serve it) then we set "migrated": */ |
| 30 | int migrated; |
| 31 | }; |
| 32 | |
Andy Adamson | e677bfe | 2007-07-17 04:04:42 -0700 | [diff] [blame] | 33 | /* |
| 34 | * We keep an array of pseudoflavors with the export, in order from most |
Lucas De Marchi | 25985ed | 2011-03-30 22:57:33 -0300 | [diff] [blame] | 35 | * to least preferred. For the foreseeable future, we don't expect more |
Andy Adamson | e677bfe | 2007-07-17 04:04:42 -0700 | [diff] [blame] | 36 | * than the eight pseudoflavors null, unix, krb5, krb5i, krb5p, skpm3, |
| 37 | * spkm3i, and spkm3p (and using all 8 at once should be rare). |
| 38 | */ |
| 39 | #define MAX_SECINFO_LIST 8 |
Kinglong Mee | 94eb368 | 2014-05-23 20:00:19 +0800 | [diff] [blame] | 40 | #define EX_UUID_LEN 16 |
Andy Adamson | e677bfe | 2007-07-17 04:04:42 -0700 | [diff] [blame] | 41 | |
| 42 | struct exp_flavor_info { |
| 43 | u32 pseudoflavor; |
| 44 | u32 flags; |
| 45 | }; |
| 46 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 47 | struct svc_export { |
| 48 | struct cache_head h; |
| 49 | struct auth_domain * ex_client; |
| 50 | int ex_flags; |
Jan Blunck | 5477549 | 2008-02-14 19:38:39 -0800 | [diff] [blame] | 51 | struct path ex_path; |
Eric W. Biederman | 4c1e1b3 | 2013-02-02 06:42:53 -0800 | [diff] [blame] | 52 | kuid_t ex_anon_uid; |
| 53 | kgid_t ex_anon_gid; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 54 | int ex_fsid; |
NeilBrown | af6a4e2 | 2007-02-14 00:33:12 -0800 | [diff] [blame] | 55 | unsigned char * ex_uuid; /* 16 byte fsid */ |
Manoj Naik | 93346919 | 2006-10-04 02:16:18 -0700 | [diff] [blame] | 56 | struct nfsd4_fs_locations ex_fslocs; |
Kinglong Mee | 1f53146 | 2014-05-24 11:26:49 +0800 | [diff] [blame] | 57 | uint32_t ex_nflavors; |
Andy Adamson | e677bfe | 2007-07-17 04:04:42 -0700 | [diff] [blame] | 58 | struct exp_flavor_info ex_flavors[MAX_SECINFO_LIST]; |
Stanislav Kinsbursky | db3a353 | 2012-03-28 19:09:08 +0400 | [diff] [blame] | 59 | struct cache_detail *cd; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 60 | }; |
| 61 | |
| 62 | /* an "export key" (expkey) maps a filehandlefragement to an |
NeilBrown | af6a4e2 | 2007-02-14 00:33:12 -0800 | [diff] [blame] | 63 | * svc_export for a given client. There can be several per export, |
| 64 | * for the different fsid types. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 65 | */ |
| 66 | struct svc_expkey { |
| 67 | struct cache_head h; |
| 68 | |
| 69 | struct auth_domain * ek_client; |
| 70 | int ek_fsidtype; |
NeilBrown | af6a4e2 | 2007-02-14 00:33:12 -0800 | [diff] [blame] | 71 | u32 ek_fsid[6]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 72 | |
Jan Blunck | e83aece | 2008-02-14 19:38:41 -0800 | [diff] [blame] | 73 | struct path ek_path; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 74 | }; |
| 75 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 76 | #define EX_ISSYNC(exp) (!((exp)->ex_flags & NFSEXP_ASYNC)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 77 | #define EX_NOHIDE(exp) ((exp)->ex_flags & NFSEXP_NOHIDE) |
| 78 | #define EX_WGATHER(exp) ((exp)->ex_flags & NFSEXP_GATHERED_WRITES) |
| 79 | |
J. Bruce Fields | c7d5140 | 2007-07-19 01:49:20 -0700 | [diff] [blame] | 80 | int nfsexp_flags(struct svc_rqst *rqstp, struct svc_export *exp); |
Andy Adamson | 32c1eb0 | 2007-07-17 04:04:48 -0700 | [diff] [blame] | 81 | __be32 check_nfsd_access(struct svc_export *exp, struct svc_rqst *rqstp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 82 | |
| 83 | /* |
| 84 | * Function declarations |
| 85 | */ |
Stanislav Kinsbursky | b89109b | 2012-04-11 15:13:14 +0400 | [diff] [blame] | 86 | int nfsd_export_init(struct net *); |
| 87 | void nfsd_export_shutdown(struct net *); |
Stanislav Kinsbursky | b3853e0 | 2012-04-11 15:13:21 +0400 | [diff] [blame] | 88 | void nfsd_export_flush(struct net *); |
J. Bruce Fields | 0989a78 | 2007-07-17 04:04:44 -0700 | [diff] [blame] | 89 | struct svc_export * rqst_exp_get_by_name(struct svc_rqst *, |
Al Viro | 91c9fa8 | 2009-04-18 02:42:05 -0400 | [diff] [blame] | 90 | struct path *); |
J. Bruce Fields | 0989a78 | 2007-07-17 04:04:44 -0700 | [diff] [blame] | 91 | struct svc_export * rqst_exp_parent(struct svc_rqst *, |
Al Viro | e64c390 | 2009-04-18 03:00:46 -0400 | [diff] [blame] | 92 | struct path *); |
Trond Myklebust | ed748aa | 2011-09-12 19:37:06 -0400 | [diff] [blame] | 93 | struct svc_export * rqst_find_fsidzero_export(struct svc_rqst *); |
Stanislav Kinsbursky | b3853e0 | 2012-04-11 15:13:21 +0400 | [diff] [blame] | 94 | int exp_rootfh(struct net *, struct auth_domain *, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 95 | char *path, struct knfsd_fh *, int maxsize); |
J. Bruce Fields | df547ef | 2007-07-17 04:04:43 -0700 | [diff] [blame] | 96 | __be32 exp_pseudoroot(struct svc_rqst *, struct svc_fh *); |
Al Viro | 63f10311 | 2006-10-19 23:28:54 -0700 | [diff] [blame] | 97 | __be32 nfserrno(int errno); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 98 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 99 | static inline void exp_put(struct svc_export *exp) |
| 100 | { |
Stanislav Kinsbursky | 7123497 | 2012-03-28 19:09:15 +0400 | [diff] [blame] | 101 | cache_put(&exp->h, exp->cd); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 102 | } |
| 103 | |
| 104 | static inline void exp_get(struct svc_export *exp) |
| 105 | { |
| 106 | cache_get(&exp->h); |
| 107 | } |
J. Bruce Fields | 0989a78 | 2007-07-17 04:04:44 -0700 | [diff] [blame] | 108 | struct svc_export * rqst_exp_find(struct svc_rqst *, int, u32 *); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 109 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 110 | #endif /* NFSD_EXPORT_H */ |