export.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /*
  3. * Copyright (C) 1995-1997 Olaf Kirch <okir@monad.swb.de>
  4. */
  5. #ifndef NFSD_EXPORT_H
  6. #define NFSD_EXPORT_H
  7. #include <linux/sunrpc/cache.h>
  8. #include <uapi/linux/nfsd/export.h>
  9. #include <linux/nfs4.h>
  10. struct knfsd_fh;
  11. struct svc_fh;
  12. struct svc_rqst;
  13. /*
  14. * FS Locations
  15. */
  16. #define MAX_FS_LOCATIONS 128
  17. struct nfsd4_fs_location {
  18. char *hosts; /* colon separated list of hosts */
  19. char *path; /* slash separated list of path components */
  20. };
  21. struct nfsd4_fs_locations {
  22. uint32_t locations_count;
  23. struct nfsd4_fs_location *locations;
  24. /* If we're not actually serving this data ourselves (only providing a
  25. * list of replicas that do serve it) then we set "migrated": */
  26. int migrated;
  27. };
  28. /*
  29. * We keep an array of pseudoflavors with the export, in order from most
  30. * to least preferred. For the foreseeable future, we don't expect more
  31. * than the eight pseudoflavors null, unix, krb5, krb5i, krb5p, skpm3,
  32. * spkm3i, and spkm3p (and using all 8 at once should be rare).
  33. */
  34. #define MAX_SECINFO_LIST 8
  35. #define EX_UUID_LEN 16
  36. struct exp_flavor_info {
  37. u32 pseudoflavor;
  38. u32 flags;
  39. };
  40. struct svc_export {
  41. struct cache_head h;
  42. struct auth_domain * ex_client;
  43. int ex_flags;
  44. struct path ex_path;
  45. kuid_t ex_anon_uid;
  46. kgid_t ex_anon_gid;
  47. int ex_fsid;
  48. unsigned char * ex_uuid; /* 16 byte fsid */
  49. struct nfsd4_fs_locations ex_fslocs;
  50. uint32_t ex_nflavors;
  51. struct exp_flavor_info ex_flavors[MAX_SECINFO_LIST];
  52. u32 ex_layout_types;
  53. struct nfsd4_deviceid_map *ex_devid_map;
  54. struct cache_detail *cd;
  55. struct rcu_head ex_rcu;
  56. };
  57. /* an "export key" (expkey) maps a filehandlefragement to an
  58. * svc_export for a given client. There can be several per export,
  59. * for the different fsid types.
  60. */
  61. struct svc_expkey {
  62. struct cache_head h;
  63. struct auth_domain * ek_client;
  64. int ek_fsidtype;
  65. u32 ek_fsid[6];
  66. struct path ek_path;
  67. struct rcu_head ek_rcu;
  68. };
  69. #define EX_ISSYNC(exp) (!((exp)->ex_flags & NFSEXP_ASYNC))
  70. #define EX_NOHIDE(exp) ((exp)->ex_flags & NFSEXP_NOHIDE)
  71. #define EX_WGATHER(exp) ((exp)->ex_flags & NFSEXP_GATHERED_WRITES)
  72. int nfsexp_flags(struct svc_rqst *rqstp, struct svc_export *exp);
  73. __be32 check_nfsd_access(struct svc_export *exp, struct svc_rqst *rqstp);
  74. /*
  75. * Function declarations
  76. */
  77. int nfsd_export_init(struct net *);
  78. void nfsd_export_shutdown(struct net *);
  79. void nfsd_export_flush(struct net *);
  80. struct svc_export * rqst_exp_get_by_name(struct svc_rqst *,
  81. struct path *);
  82. struct svc_export * rqst_exp_parent(struct svc_rqst *,
  83. struct path *);
  84. struct svc_export * rqst_find_fsidzero_export(struct svc_rqst *);
  85. int exp_rootfh(struct net *, struct auth_domain *,
  86. char *path, struct knfsd_fh *, int maxsize);
  87. __be32 exp_pseudoroot(struct svc_rqst *, struct svc_fh *);
  88. __be32 nfserrno(int errno);
  89. static inline void exp_put(struct svc_export *exp)
  90. {
  91. cache_put(&exp->h, exp->cd);
  92. }
  93. static inline struct svc_export *exp_get(struct svc_export *exp)
  94. {
  95. cache_get(&exp->h);
  96. return exp;
  97. }
  98. struct svc_export * rqst_exp_find(struct svc_rqst *, int, u32 *);
  99. #endif /* NFSD_EXPORT_H */