vfs.h 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /*
  3. * Copyright (C) 1995-1997 Olaf Kirch <okir@monad.swb.de>
  4. */
  5. #ifndef LINUX_NFSD_VFS_H
  6. #define LINUX_NFSD_VFS_H
  7. #include <linux/fs.h>
  8. #include <linux/posix_acl.h>
  9. #include "nfsfh.h"
  10. #include "nfsd.h"
  11. /*
  12. * Flags for nfsd_permission
  13. */
  14. #define NFSD_MAY_NOP 0
  15. #define NFSD_MAY_EXEC 0x001 /* == MAY_EXEC */
  16. #define NFSD_MAY_WRITE 0x002 /* == MAY_WRITE */
  17. #define NFSD_MAY_READ 0x004 /* == MAY_READ */
  18. #define NFSD_MAY_SATTR 0x008
  19. #define NFSD_MAY_TRUNC 0x010
  20. #define NFSD_MAY_NLM 0x020 /* request is from lockd */
  21. #define NFSD_MAY_MASK 0x03f
  22. /* extra hints to permission and open routines: */
  23. #define NFSD_MAY_OWNER_OVERRIDE 0x040
  24. #define NFSD_MAY_LOCAL_ACCESS 0x080 /* for device special files */
  25. #define NFSD_MAY_BYPASS_GSS_ON_ROOT 0x100
  26. #define NFSD_MAY_NOT_BREAK_LEASE 0x200
  27. #define NFSD_MAY_BYPASS_GSS 0x400
  28. #define NFSD_MAY_READ_IF_EXEC 0x800
  29. #define NFSD_MAY_64BIT_COOKIE 0x1000 /* 64 bit readdir cookies for >= NFSv3 */
  30. #define NFSD_MAY_LOCALIO 0x2000 /* for tracing, reflects when localio used */
  31. #define NFSD_MAY_CREATE (NFSD_MAY_EXEC|NFSD_MAY_WRITE)
  32. #define NFSD_MAY_REMOVE (NFSD_MAY_EXEC|NFSD_MAY_WRITE|NFSD_MAY_TRUNC)
  33. struct nfsd_file;
  34. /*
  35. * Callback function for readdir
  36. */
  37. typedef int (*nfsd_filldir_t)(void *, const char *, int, loff_t, u64, unsigned);
  38. /* nfsd/vfs.c */
  39. struct nfsd_attrs {
  40. struct iattr *na_iattr; /* input */
  41. struct xdr_netobj *na_seclabel; /* input */
  42. struct posix_acl *na_pacl; /* input */
  43. struct posix_acl *na_dpacl; /* input */
  44. int na_labelerr; /* output */
  45. int na_dpaclerr; /* output */
  46. int na_paclerr; /* output */
  47. };
  48. static inline void nfsd_attrs_free(struct nfsd_attrs *attrs)
  49. {
  50. posix_acl_release(attrs->na_pacl);
  51. posix_acl_release(attrs->na_dpacl);
  52. }
  53. static inline bool nfsd_attrs_valid(struct nfsd_attrs *attrs)
  54. {
  55. struct iattr *iap = attrs->na_iattr;
  56. return (iap->ia_valid || (attrs->na_seclabel &&
  57. attrs->na_seclabel->len) ||
  58. attrs->na_pacl || attrs->na_dpacl);
  59. }
  60. __be32 nfserrno (int errno);
  61. int nfsd_cross_mnt(struct svc_rqst *rqstp, struct dentry **dpp,
  62. struct svc_export **expp);
  63. __be32 nfsd_lookup(struct svc_rqst *, struct svc_fh *,
  64. const char *, unsigned int, struct svc_fh *);
  65. __be32 nfsd_lookup_dentry(struct svc_rqst *, struct svc_fh *,
  66. const char *, unsigned int,
  67. struct svc_export **, struct dentry **);
  68. __be32 nfsd_setattr(struct svc_rqst *, struct svc_fh *,
  69. struct nfsd_attrs *, const struct timespec64 *);
  70. int nfsd_mountpoint(struct dentry *, struct svc_export *);
  71. #ifdef CONFIG_NFSD_V4
  72. __be32 nfsd4_vfs_fallocate(struct svc_rqst *, struct svc_fh *,
  73. struct file *, loff_t, loff_t, int);
  74. __be32 nfsd4_clone_file_range(struct svc_rqst *rqstp,
  75. struct nfsd_file *nf_src, u64 src_pos,
  76. struct nfsd_file *nf_dst, u64 dst_pos,
  77. u64 count, bool sync);
  78. #endif /* CONFIG_NFSD_V4 */
  79. __be32 nfsd_create_locked(struct svc_rqst *, struct svc_fh *,
  80. struct nfsd_attrs *attrs, int type, dev_t rdev,
  81. struct svc_fh *res);
  82. __be32 nfsd_create(struct svc_rqst *, struct svc_fh *,
  83. char *name, int len, struct nfsd_attrs *attrs,
  84. int type, dev_t rdev, struct svc_fh *res);
  85. __be32 nfsd_access(struct svc_rqst *, struct svc_fh *, u32 *, u32 *);
  86. __be32 nfsd_create_setattr(struct svc_rqst *rqstp, struct svc_fh *fhp,
  87. struct svc_fh *resfhp, struct nfsd_attrs *iap);
  88. __be32 nfsd_commit(struct svc_rqst *rqst, struct svc_fh *fhp,
  89. struct nfsd_file *nf, u64 offset, u32 count,
  90. __be32 *verf);
  91. #ifdef CONFIG_NFSD_V4
  92. __be32 nfsd_getxattr(struct svc_rqst *rqstp, struct svc_fh *fhp,
  93. char *name, void **bufp, int *lenp);
  94. __be32 nfsd_listxattr(struct svc_rqst *rqstp, struct svc_fh *fhp,
  95. char **bufp, int *lenp);
  96. __be32 nfsd_removexattr(struct svc_rqst *rqstp, struct svc_fh *fhp,
  97. char *name);
  98. __be32 nfsd_setxattr(struct svc_rqst *rqstp, struct svc_fh *fhp,
  99. char *name, void *buf, u32 len, u32 flags);
  100. #endif
  101. int nfsd_open_break_lease(struct inode *, int);
  102. __be32 nfsd_open(struct svc_rqst *, struct svc_fh *, umode_t,
  103. int, struct file **);
  104. int nfsd_open_verified(struct svc_fh *fhp, umode_t type, int may_flags,
  105. struct file **filp);
  106. __be32 nfsd_splice_read(struct svc_rqst *rqstp, struct svc_fh *fhp,
  107. struct file *file, loff_t offset,
  108. unsigned long *count,
  109. u32 *eof);
  110. __be32 nfsd_iter_read(struct svc_rqst *rqstp, struct svc_fh *fhp,
  111. struct nfsd_file *nf, loff_t offset,
  112. unsigned long *count, unsigned int base,
  113. u32 *eof);
  114. bool nfsd_read_splice_ok(struct svc_rqst *rqstp);
  115. __be32 nfsd_read(struct svc_rqst *rqstp, struct svc_fh *fhp,
  116. loff_t offset, unsigned long *count,
  117. u32 *eof);
  118. __be32 nfsd_write(struct svc_rqst *rqstp, struct svc_fh *fhp,
  119. loff_t offset, const struct xdr_buf *payload,
  120. unsigned long *cnt, int stable, __be32 *verf);
  121. __be32 nfsd_vfs_write(struct svc_rqst *rqstp, struct svc_fh *fhp,
  122. struct nfsd_file *nf, loff_t offset,
  123. const struct xdr_buf *payload,
  124. unsigned long *cnt, int stable, __be32 *verf);
  125. __be32 nfsd_readlink(struct svc_rqst *, struct svc_fh *,
  126. char *, int *);
  127. __be32 nfsd_symlink(struct svc_rqst *, struct svc_fh *,
  128. char *name, int len, char *path,
  129. struct nfsd_attrs *attrs,
  130. struct svc_fh *res);
  131. __be32 nfsd_link(struct svc_rqst *, struct svc_fh *,
  132. char *, int, struct svc_fh *);
  133. ssize_t nfsd_copy_file_range(struct file *, u64,
  134. struct file *, u64, u64);
  135. __be32 nfsd_rename(struct svc_rqst *,
  136. struct svc_fh *, char *, int,
  137. struct svc_fh *, char *, int);
  138. __be32 nfsd_unlink(struct svc_rqst *, struct svc_fh *, int type,
  139. char *name, int len);
  140. __be32 nfsd_readdir(struct svc_rqst *, struct svc_fh *,
  141. loff_t *, struct readdir_cd *, nfsd_filldir_t);
  142. __be32 nfsd_statfs(struct svc_rqst *, struct svc_fh *,
  143. struct kstatfs *, int access);
  144. __be32 nfsd_permission(struct svc_cred *cred, struct svc_export *exp,
  145. struct dentry *dentry, int acc);
  146. void nfsd_filp_close(struct file *fp);
  147. #endif /* LINUX_NFSD_VFS_H */