internal.h 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244
  1. /* SPDX-License-Identifier: GPL-2.0-or-later */
  2. /* fs/ internal definitions
  3. *
  4. * Copyright (C) 2006 Red Hat, Inc. All Rights Reserved.
  5. * Written by David Howells ([email protected])
  6. */
  7. struct super_block;
  8. struct file_system_type;
  9. struct iomap;
  10. struct iomap_ops;
  11. struct linux_binprm;
  12. struct path;
  13. struct mount;
  14. struct shrink_control;
  15. struct fs_context;
  16. struct user_namespace;
  17. struct pipe_inode_info;
  18. struct iov_iter;
  19. /*
  20. * block/bdev.c
  21. */
  22. #ifdef CONFIG_BLOCK
  23. extern void __init bdev_cache_init(void);
  24. void emergency_thaw_bdev(struct super_block *sb);
  25. #else
  26. static inline void bdev_cache_init(void)
  27. {
  28. }
  29. static inline int emergency_thaw_bdev(struct super_block *sb)
  30. {
  31. return 0;
  32. }
  33. #endif /* CONFIG_BLOCK */
  34. /*
  35. * buffer.c
  36. */
  37. int __block_write_begin_int(struct folio *folio, loff_t pos, unsigned len,
  38. get_block_t *get_block, const struct iomap *iomap);
  39. /*
  40. * char_dev.c
  41. */
  42. extern void __init chrdev_init(void);
  43. /*
  44. * fs_context.c
  45. */
  46. extern const struct fs_context_operations legacy_fs_context_ops;
  47. extern int parse_monolithic_mount_data(struct fs_context *, void *);
  48. extern void vfs_clean_context(struct fs_context *fc);
  49. extern int finish_clean_context(struct fs_context *fc);
  50. /*
  51. * namei.c
  52. */
  53. extern int filename_lookup(int dfd, struct filename *name, unsigned flags,
  54. struct path *path, struct path *root);
  55. extern int vfs_path_lookup(struct dentry *, struct vfsmount *,
  56. const char *, unsigned int, struct path *);
  57. int do_rmdir(int dfd, struct filename *name);
  58. int do_unlinkat(int dfd, struct filename *name);
  59. int may_linkat(struct user_namespace *mnt_userns, const struct path *link);
  60. int do_renameat2(int olddfd, struct filename *oldname, int newdfd,
  61. struct filename *newname, unsigned int flags);
  62. int do_mkdirat(int dfd, struct filename *name, umode_t mode);
  63. int do_symlinkat(struct filename *from, int newdfd, struct filename *to);
  64. int do_linkat(int olddfd, struct filename *old, int newdfd,
  65. struct filename *new, int flags);
  66. /*
  67. * namespace.c
  68. */
  69. extern struct vfsmount *lookup_mnt(const struct path *);
  70. extern int finish_automount(struct vfsmount *, const struct path *);
  71. extern int sb_prepare_remount_readonly(struct super_block *);
  72. extern void __init mnt_init(void);
  73. extern int __mnt_want_write_file(struct file *);
  74. extern void __mnt_drop_write_file(struct file *);
  75. extern void dissolve_on_fput(struct vfsmount *);
  76. extern bool may_mount(void);
  77. int path_mount(const char *dev_name, struct path *path,
  78. const char *type_page, unsigned long flags, void *data_page);
  79. int path_umount(struct path *path, int flags);
  80. /*
  81. * fs_struct.c
  82. */
  83. extern void chroot_fs_refs(const struct path *, const struct path *);
  84. /*
  85. * file_table.c
  86. */
  87. extern struct file *alloc_empty_file(int, const struct cred *);
  88. extern struct file *alloc_empty_file_noaccount(int, const struct cred *);
  89. static inline void put_file_access(struct file *file)
  90. {
  91. if ((file->f_mode & (FMODE_READ | FMODE_WRITE)) == FMODE_READ) {
  92. i_readcount_dec(file->f_inode);
  93. } else if (file->f_mode & FMODE_WRITER) {
  94. put_write_access(file->f_inode);
  95. __mnt_drop_write(file->f_path.mnt);
  96. }
  97. }
  98. /*
  99. * super.c
  100. */
  101. extern int reconfigure_super(struct fs_context *);
  102. extern bool trylock_super(struct super_block *sb);
  103. struct super_block *user_get_super(dev_t, bool excl);
  104. void put_super(struct super_block *sb);
  105. extern bool mount_capable(struct fs_context *);
  106. /*
  107. * open.c
  108. */
  109. struct open_flags {
  110. int open_flag;
  111. umode_t mode;
  112. int acc_mode;
  113. int intent;
  114. int lookup_flags;
  115. };
  116. extern struct file *do_filp_open(int dfd, struct filename *pathname,
  117. const struct open_flags *op);
  118. extern struct file *do_file_open_root(const struct path *,
  119. const char *, const struct open_flags *);
  120. extern struct open_how build_open_how(int flags, umode_t mode);
  121. extern int build_open_flags(const struct open_how *how, struct open_flags *op);
  122. extern struct file *__close_fd_get_file(unsigned int fd);
  123. long do_sys_ftruncate(unsigned int fd, loff_t length, int small);
  124. int chmod_common(const struct path *path, umode_t mode);
  125. int do_fchownat(int dfd, const char __user *filename, uid_t user, gid_t group,
  126. int flag);
  127. int chown_common(const struct path *path, uid_t user, gid_t group);
  128. extern int vfs_open(const struct path *, struct file *);
  129. /*
  130. * inode.c
  131. */
  132. extern long prune_icache_sb(struct super_block *sb, struct shrink_control *sc);
  133. int dentry_needs_remove_privs(struct user_namespace *, struct dentry *dentry);
  134. bool in_group_or_capable(struct user_namespace *mnt_userns,
  135. const struct inode *inode, vfsgid_t vfsgid);
  136. void lock_two_inodes(struct inode *inode1, struct inode *inode2,
  137. unsigned subclass1, unsigned subclass2);
  138. /*
  139. * fs-writeback.c
  140. */
  141. extern long get_nr_dirty_inodes(void);
  142. extern int invalidate_inodes(struct super_block *, bool);
  143. /*
  144. * dcache.c
  145. */
  146. extern int d_set_mounted(struct dentry *dentry);
  147. extern long prune_dcache_sb(struct super_block *sb, struct shrink_control *sc);
  148. extern struct dentry *d_alloc_cursor(struct dentry *);
  149. extern struct dentry * d_alloc_pseudo(struct super_block *, const struct qstr *);
  150. extern char *simple_dname(struct dentry *, char *, int);
  151. extern void dput_to_list(struct dentry *, struct list_head *);
  152. extern void shrink_dentry_list(struct list_head *);
  153. /*
  154. * pipe.c
  155. */
  156. extern const struct file_operations pipefifo_fops;
  157. /*
  158. * fs_pin.c
  159. */
  160. extern void group_pin_kill(struct hlist_head *p);
  161. extern void mnt_pin_kill(struct mount *m);
  162. /*
  163. * fs/nsfs.c
  164. */
  165. extern const struct dentry_operations ns_dentry_operations;
  166. /* direct-io.c: */
  167. int sb_init_dio_done_wq(struct super_block *sb);
  168. /*
  169. * fs/stat.c:
  170. */
  171. int getname_statx_lookup_flags(int flags);
  172. int do_statx(int dfd, struct filename *filename, unsigned int flags,
  173. unsigned int mask, struct statx __user *buffer);
  174. /*
  175. * fs/splice.c:
  176. */
  177. long splice_file_to_pipe(struct file *in,
  178. struct pipe_inode_info *opipe,
  179. loff_t *offset,
  180. size_t len, unsigned int flags);
  181. /*
  182. * fs/xattr.c:
  183. */
  184. struct xattr_name {
  185. char name[XATTR_NAME_MAX + 1];
  186. };
  187. struct xattr_ctx {
  188. /* Value of attribute */
  189. union {
  190. const void __user *cvalue;
  191. void __user *value;
  192. };
  193. void *kvalue;
  194. size_t size;
  195. /* Attribute name */
  196. struct xattr_name *kname;
  197. unsigned int flags;
  198. };
  199. ssize_t do_getxattr(struct user_namespace *mnt_userns,
  200. struct dentry *d,
  201. struct xattr_ctx *ctx);
  202. int setxattr_copy(const char __user *name, struct xattr_ctx *ctx);
  203. int do_setxattr(struct user_namespace *mnt_userns, struct dentry *dentry,
  204. struct xattr_ctx *ctx);
  205. ssize_t __kernel_write_iter(struct file *file, struct iov_iter *from, loff_t *pos);
  206. /*
  207. * fs/attr.c
  208. */