export.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  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. };
  56. /* an "export key" (expkey) maps a filehandlefragement to an
  57. * svc_export for a given client. There can be several per export,
  58. * for the different fsid types.
  59. */
  60. struct svc_expkey {
  61. struct cache_head h;
  62. struct auth_domain * ek_client;
  63. int ek_fsidtype;
  64. u32 ek_fsid[6];
  65. struct path ek_path;
  66. };
  67. #define EX_ISSYNC(exp) (!((exp)->ex_flags & NFSEXP_ASYNC))
  68. #define EX_NOHIDE(exp) ((exp)->ex_flags & NFSEXP_NOHIDE)
  69. #define EX_WGATHER(exp) ((exp)->ex_flags & NFSEXP_GATHERED_WRITES)
  70. int nfsexp_flags(struct svc_rqst *rqstp, struct svc_export *exp);
  71. __be32 check_nfsd_access(struct svc_export *exp, struct svc_rqst *rqstp);
  72. /*
  73. * Function declarations
  74. */
  75. int nfsd_export_init(struct net *);
  76. void nfsd_export_shutdown(struct net *);
  77. void nfsd_export_flush(struct net *);
  78. struct svc_export * rqst_exp_get_by_name(struct svc_rqst *,
  79. struct path *);
  80. struct svc_export * rqst_exp_parent(struct svc_rqst *,
  81. struct path *);
  82. struct svc_export * rqst_find_fsidzero_export(struct svc_rqst *);
  83. int exp_rootfh(struct net *, struct auth_domain *,
  84. char *path, struct knfsd_fh *, int maxsize);
  85. __be32 exp_pseudoroot(struct svc_rqst *, struct svc_fh *);
  86. __be32 nfserrno(int errno);
  87. static inline void exp_put(struct svc_export *exp)
  88. {
  89. cache_put(&exp->h, exp->cd);
  90. }
  91. static inline struct svc_export *exp_get(struct svc_export *exp)
  92. {
  93. cache_get(&exp->h);
  94. return exp;
  95. }
  96. struct svc_export * rqst_exp_find(struct svc_rqst *, int, u32 *);
  97. #endif /* NFSD_EXPORT_H */