export.h 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  1. /*
  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. */
  9. #ifndef NFSD_EXPORT_H
  10. #define NFSD_EXPORT_H
  11. # include <linux/types.h>
  12. #ifdef __KERNEL__
  13. # include <linux/nfsd/nfsfh.h>
  14. #endif
  15. /*
  16. * Important limits for the exports stuff.
  17. */
  18. #define NFSCLNT_IDMAX 1024
  19. #define NFSCLNT_ADDRMAX 16
  20. #define NFSCLNT_KEYMAX 32
  21. /*
  22. * Export flags.
  23. */
  24. #define NFSEXP_READONLY 0x0001
  25. #define NFSEXP_INSECURE_PORT 0x0002
  26. #define NFSEXP_ROOTSQUASH 0x0004
  27. #define NFSEXP_ALLSQUASH 0x0008
  28. #define NFSEXP_ASYNC 0x0010
  29. #define NFSEXP_GATHERED_WRITES 0x0020
  30. /* 40 80 100 currently unused */
  31. #define NFSEXP_NOHIDE 0x0200
  32. #define NFSEXP_NOSUBTREECHECK 0x0400
  33. #define NFSEXP_NOAUTHNLM 0x0800 /* Don't authenticate NLM requests - just trust */
  34. #define NFSEXP_MSNFS 0x1000 /* do silly things that MS clients expect; no longer supported */
  35. #define NFSEXP_FSID 0x2000
  36. #define NFSEXP_CROSSMOUNT 0x4000
  37. #define NFSEXP_NOACL 0x8000 /* reserved for possible ACL related use */
  38. /*
  39. * The NFSEXP_V4ROOT flag causes the kernel to give access only to NFSv4
  40. * clients, and only to the single directory that is the root of the
  41. * export; further lookup and readdir operations are treated as if every
  42. * subdirectory was a mountpoint, and ignored if they are not themselves
  43. * exported. This is used by nfsd and mountd to construct the NFSv4
  44. * pseudofilesystem, which provides access only to paths leading to each
  45. * exported filesystem.
  46. */
  47. #define NFSEXP_V4ROOT 0x10000
  48. /* All flags that we claim to support. (Note we don't support NOACL.) */
  49. #define NFSEXP_ALLFLAGS 0x17E3F
  50. /* The flags that may vary depending on security flavor: */
  51. #define NFSEXP_SECINFO_FLAGS (NFSEXP_READONLY | NFSEXP_ROOTSQUASH \
  52. | NFSEXP_ALLSQUASH \
  53. | NFSEXP_INSECURE_PORT)
  54. #ifdef __KERNEL__
  55. /*
  56. * FS Locations
  57. */
  58. #define MAX_FS_LOCATIONS 128
  59. struct nfsd4_fs_location {
  60. char *hosts; /* colon separated list of hosts */
  61. char *path; /* slash separated list of path components */
  62. };
  63. struct nfsd4_fs_locations {
  64. uint32_t locations_count;
  65. struct nfsd4_fs_location *locations;
  66. /* If we're not actually serving this data ourselves (only providing a
  67. * list of replicas that do serve it) then we set "migrated": */
  68. int migrated;
  69. };
  70. /*
  71. * We keep an array of pseudoflavors with the export, in order from most
  72. * to least preferred. For the forseeable future, we don't expect more
  73. * than the eight pseudoflavors null, unix, krb5, krb5i, krb5p, skpm3,
  74. * spkm3i, and spkm3p (and using all 8 at once should be rare).
  75. */
  76. #define MAX_SECINFO_LIST 8
  77. struct exp_flavor_info {
  78. u32 pseudoflavor;
  79. u32 flags;
  80. };
  81. struct svc_export {
  82. struct cache_head h;
  83. struct auth_domain * ex_client;
  84. int ex_flags;
  85. struct path ex_path;
  86. char *ex_pathname;
  87. uid_t ex_anon_uid;
  88. gid_t ex_anon_gid;
  89. int ex_fsid;
  90. unsigned char * ex_uuid; /* 16 byte fsid */
  91. struct nfsd4_fs_locations ex_fslocs;
  92. int ex_nflavors;
  93. struct exp_flavor_info ex_flavors[MAX_SECINFO_LIST];
  94. };
  95. /* an "export key" (expkey) maps a filehandlefragement to an
  96. * svc_export for a given client. There can be several per export,
  97. * for the different fsid types.
  98. */
  99. struct svc_expkey {
  100. struct cache_head h;
  101. struct auth_domain * ek_client;
  102. int ek_fsidtype;
  103. u32 ek_fsid[6];
  104. struct path ek_path;
  105. };
  106. #define EX_ISSYNC(exp) (!((exp)->ex_flags & NFSEXP_ASYNC))
  107. #define EX_NOHIDE(exp) ((exp)->ex_flags & NFSEXP_NOHIDE)
  108. #define EX_WGATHER(exp) ((exp)->ex_flags & NFSEXP_GATHERED_WRITES)
  109. int nfsexp_flags(struct svc_rqst *rqstp, struct svc_export *exp);
  110. __be32 check_nfsd_access(struct svc_export *exp, struct svc_rqst *rqstp);
  111. /*
  112. * Function declarations
  113. */
  114. int nfsd_export_init(void);
  115. void nfsd_export_shutdown(void);
  116. void nfsd_export_flush(void);
  117. void exp_readlock(void);
  118. void exp_readunlock(void);
  119. struct svc_export * rqst_exp_get_by_name(struct svc_rqst *,
  120. struct path *);
  121. struct svc_export * rqst_exp_parent(struct svc_rqst *,
  122. struct path *);
  123. int exp_rootfh(struct auth_domain *,
  124. char *path, struct knfsd_fh *, int maxsize);
  125. __be32 exp_pseudoroot(struct svc_rqst *, struct svc_fh *);
  126. __be32 nfserrno(int errno);
  127. extern struct cache_detail svc_export_cache;
  128. static inline void exp_put(struct svc_export *exp)
  129. {
  130. cache_put(&exp->h, &svc_export_cache);
  131. }
  132. static inline void exp_get(struct svc_export *exp)
  133. {
  134. cache_get(&exp->h);
  135. }
  136. struct svc_export * rqst_exp_find(struct svc_rqst *, int, u32 *);
  137. #endif /* __KERNEL__ */
  138. #endif /* NFSD_EXPORT_H */