2874c5fd28426 (Thomas Gleixner 2019-05-27 08:55:01 +0200 1) /* SPDX-License-Identifier: GPL-2.0-or-later */
07f3f05c1e305 (David Howells 2006-09-30 20:52:18 +0200 2) /* fs/ internal definitions
07f3f05c1e305 (David Howells 2006-09-30 20:52:18 +0200 3) *
07f3f05c1e305 (David Howells 2006-09-30 20:52:18 +0200 4) * Copyright (C) 2006 Red Hat, Inc. All Rights Reserved.
07f3f05c1e305 (David Howells 2006-09-30 20:52:18 +0200 5) * Written by David Howells (dhowells@redhat.com)
07f3f05c1e305 (David Howells 2006-09-30 20:52:18 +0200 6) */
07f3f05c1e305 (David Howells 2006-09-30 20:52:18 +0200 7)
5e6d12b2c8be2 (Andrew Morton 2006-08-31 12:55:23 +0200 8) struct super_block;
9d412a43c3b26 (Al Viro 2011-03-17 22:08:28 -0400 9) struct file_system_type;
ae259a9c8593f (Christoph Hellwig 2016-06-21 09:23:11 +1000 10) struct iomap;
befb503ca6e64 (Christoph Hellwig 2016-09-19 11:24:49 +1000 11) struct iomap_ops;
a6f76f23d297f (David Howells 2008-11-14 10:39:24 +1100 12) struct linux_binprm;
3e93cd671813e (Al Viro 2009-03-29 19:00:13 -0400 13) struct path;
c71053659e3bb (Al Viro 2011-11-24 18:22:03 -0500 14) struct mount;
503c358cf1925 (Vladimir Davydov 2015-02-12 14:58:47 -0800 15) struct shrink_control;
9bc61ab18b1d4 (David Howells 2018-11-04 03:19:03 -0500 16) struct fs_context;
2527b284defae (Al Viro 2019-05-12 17:09:01 -0400 17) struct user_namespace;
b964bf53e5402 (Al Viro 2021-01-25 22:24:28 -0500 18) struct pipe_inode_info;
5e6d12b2c8be2 (Andrew Morton 2006-08-31 12:55:23 +0200 19)
07f3f05c1e305 (David Howells 2006-09-30 20:52:18 +0200 20) /*
07f3f05c1e305 (David Howells 2006-09-30 20:52:18 +0200 21) * block_dev.c
07f3f05c1e305 (David Howells 2006-09-30 20:52:18 +0200 22) */
9361401eb7619 (David Howells 2006-09-30 20:45:40 +0200 23) #ifdef CONFIG_BLOCK
07f3f05c1e305 (David Howells 2006-09-30 20:52:18 +0200 24) extern void __init bdev_cache_init(void);
07f3f05c1e305 (David Howells 2006-09-30 20:52:18 +0200 25)
5cee5815d1564 (Jan Kara 2009-04-27 16:43:51 +0200 26) extern int __sync_blockdev(struct block_device *bdev, int wait);
3f1266f1f82d7 (Christoph Hellwig 2020-06-20 09:16:41 +0200 27) void iterate_bdevs(void (*)(struct block_device *, void *), void *);
3f1266f1f82d7 (Christoph Hellwig 2020-06-20 09:16:41 +0200 28) void emergency_thaw_bdev(struct super_block *sb);
9361401eb7619 (David Howells 2006-09-30 20:45:40 +0200 29) #else
5e6d12b2c8be2 (Andrew Morton 2006-08-31 12:55:23 +0200 30) static inline void bdev_cache_init(void)
5e6d12b2c8be2 (Andrew Morton 2006-08-31 12:55:23 +0200 31) {
5e6d12b2c8be2 (Andrew Morton 2006-08-31 12:55:23 +0200 32) }
9361401eb7619 (David Howells 2006-09-30 20:45:40 +0200 33)
5cee5815d1564 (Jan Kara 2009-04-27 16:43:51 +0200 34) static inline int __sync_blockdev(struct block_device *bdev, int wait)
5cee5815d1564 (Jan Kara 2009-04-27 16:43:51 +0200 35) {
5cee5815d1564 (Jan Kara 2009-04-27 16:43:51 +0200 36) return 0;
5cee5815d1564 (Jan Kara 2009-04-27 16:43:51 +0200 37) }
3f1266f1f82d7 (Christoph Hellwig 2020-06-20 09:16:41 +0200 38) static inline void iterate_bdevs(void (*f)(struct block_device *, void *),
3f1266f1f82d7 (Christoph Hellwig 2020-06-20 09:16:41 +0200 39) void *arg)
3f1266f1f82d7 (Christoph Hellwig 2020-06-20 09:16:41 +0200 40) {
3f1266f1f82d7 (Christoph Hellwig 2020-06-20 09:16:41 +0200 41) }
3f1266f1f82d7 (Christoph Hellwig 2020-06-20 09:16:41 +0200 42) static inline int emergency_thaw_bdev(struct super_block *sb)
3f1266f1f82d7 (Christoph Hellwig 2020-06-20 09:16:41 +0200 43) {
3f1266f1f82d7 (Christoph Hellwig 2020-06-20 09:16:41 +0200 44) return 0;
3f1266f1f82d7 (Christoph Hellwig 2020-06-20 09:16:41 +0200 45) }
3f1266f1f82d7 (Christoph Hellwig 2020-06-20 09:16:41 +0200 46) #endif /* CONFIG_BLOCK */
7b0de42d7c5a4 (David Howells 2006-08-29 19:06:07 +0100 47)
4db96b71e3cae (Akinobu Mita 2014-10-09 15:26:55 -0700 48) /*
4db96b71e3cae (Akinobu Mita 2014-10-09 15:26:55 -0700 49) * buffer.c
4db96b71e3cae (Akinobu Mita 2014-10-09 15:26:55 -0700 50) */
ae259a9c8593f (Christoph Hellwig 2016-06-21 09:23:11 +1000 51) extern int __block_write_begin_int(struct page *page, loff_t pos, unsigned len,
ae259a9c8593f (Christoph Hellwig 2016-06-21 09:23:11 +1000 52) get_block_t *get_block, struct iomap *iomap);
4db96b71e3cae (Akinobu Mita 2014-10-09 15:26:55 -0700 53)
07f3f05c1e305 (David Howells 2006-09-30 20:52:18 +0200 54) /*
07f3f05c1e305 (David Howells 2006-09-30 20:52:18 +0200 55) * char_dev.c
07f3f05c1e305 (David Howells 2006-09-30 20:52:18 +0200 56) */
07f3f05c1e305 (David Howells 2006-09-30 20:52:18 +0200 57) extern void __init chrdev_init(void);
07f3f05c1e305 (David Howells 2006-09-30 20:52:18 +0200 58)
9bc61ab18b1d4 (David Howells 2018-11-04 03:19:03 -0500 59) /*
9bc61ab18b1d4 (David Howells 2018-11-04 03:19:03 -0500 60) * fs_context.c
9bc61ab18b1d4 (David Howells 2018-11-04 03:19:03 -0500 61) */
ecdab150fddb4 (David Howells 2018-11-01 23:36:09 +0000 62) extern const struct fs_context_operations legacy_fs_context_ops;
9bc61ab18b1d4 (David Howells 2018-11-04 03:19:03 -0500 63) extern int parse_monolithic_mount_data(struct fs_context *, void *);
ecdab150fddb4 (David Howells 2018-11-01 23:36:09 +0000 64) extern void vfs_clean_context(struct fs_context *fc);
ecdab150fddb4 (David Howells 2018-11-01 23:36:09 +0000 65) extern int finish_clean_context(struct fs_context *fc);
9bc61ab18b1d4 (David Howells 2018-11-04 03:19:03 -0500 66)
0bdaea9017b9d (David Howells 2012-06-25 12:55:46 +0100 67) /*
0bdaea9017b9d (David Howells 2012-06-25 12:55:46 +0100 68) * namei.c
0bdaea9017b9d (David Howells 2012-06-25 12:55:46 +0100 69) */
31d921c7fb969 (David Howells 2018-11-01 23:07:24 +0000 70) extern int filename_lookup(int dfd, struct filename *name, unsigned flags,
31d921c7fb969 (David Howells 2018-11-01 23:07:24 +0000 71) struct path *path, struct path *root);
197df04c749a0 (Al Viro 2013-09-08 14:03:27 -0400 72) extern int vfs_path_lookup(struct dentry *, struct vfsmount *,
197df04c749a0 (Al Viro 2013-09-08 14:03:27 -0400 73) const char *, unsigned int, struct path *);
e24ab0ef689de (Christoph Hellwig 2020-07-21 10:48:15 +0200 74) long do_rmdir(int dfd, struct filename *name);
da2f1362c8bdf (Christoph Hellwig 2017-11-04 13:44:45 +0300 75) long do_unlinkat(int dfd, struct filename *name);
ba73d98745be1 (Christian Brauner 2021-01-21 14:19:31 +0100 76) int may_linkat(struct user_namespace *mnt_userns, struct path *link);
e886663cfd029 (Jens Axboe 2020-09-26 17:20:17 -0600 77) int do_renameat2(int olddfd, struct filename *oldname, int newdfd,
e886663cfd029 (Jens Axboe 2020-09-26 17:20:17 -0600 78) struct filename *newname, unsigned int flags);
0bdaea9017b9d (David Howells 2012-06-25 12:55:46 +0100 79)
07f3f05c1e305 (David Howells 2006-09-30 20:52:18 +0200 80) /*
07f3f05c1e305 (David Howells 2006-09-30 20:52:18 +0200 81) * namespace.c
07f3f05c1e305 (David Howells 2006-09-30 20:52:18 +0200 82) */
ca71cf71eeda0 (Al Viro 2016-11-20 19:45:28 -0500 83) extern struct vfsmount *lookup_mnt(const struct path *);
19a167af7c972 (Al Viro 2011-01-17 01:35:23 -0500 84) extern int finish_automount(struct vfsmount *, struct path *);
6d59e7f582ef1 (Al Viro 2008-03-22 15:48:17 -0400 85)
4ed5e82fe77f4 (Miklos Szeredi 2011-11-21 12:11:31 +0100 86) extern int sb_prepare_remount_readonly(struct super_block *);
f03c65993b98e (Al Viro 2011-01-14 22:30:21 -0500 87)
6d59e7f582ef1 (Al Viro 2008-03-22 15:48:17 -0400 88) extern void __init mnt_init(void);
3e93cd671813e (Al Viro 2009-03-29 19:00:13 -0400 89)
eb04c28288bb0 (Jan Kara 2012-06-12 16:20:35 +0200 90) extern int __mnt_want_write_file(struct file *);
eb04c28288bb0 (Jan Kara 2012-06-12 16:20:35 +0200 91) extern void __mnt_drop_write_file(struct file *);
47cd813f29845 (Al Viro 2010-02-05 02:01:14 -0500 92)
a07b20004793d (Al Viro 2018-11-05 17:40:30 +0000 93) extern void dissolve_on_fput(struct vfsmount *);
c60166f04283f (Christoph Hellwig 2020-07-21 11:12:08 +0200 94)
c60166f04283f (Christoph Hellwig 2020-07-21 11:12:08 +0200 95) int path_mount(const char *dev_name, struct path *path,
c60166f04283f (Christoph Hellwig 2020-07-21 11:12:08 +0200 96) const char *type_page, unsigned long flags, void *data_page);
09267defa36aa (Christoph Hellwig 2020-07-23 08:23:08 +0200 97) int path_umount(struct path *path, int flags);
c60166f04283f (Christoph Hellwig 2020-07-21 11:12:08 +0200 98)
3e93cd671813e (Al Viro 2009-03-29 19:00:13 -0400 99) /*
3e93cd671813e (Al Viro 2009-03-29 19:00:13 -0400 100) * fs_struct.c
3e93cd671813e (Al Viro 2009-03-29 19:00:13 -0400 101) */
dcf787f39162c (Al Viro 2013-03-01 23:51:07 -0500 102) extern void chroot_fs_refs(const struct path *, const struct path *);
864d7c4c068f2 (Nicholas Piggin 2009-04-26 20:25:56 +1000 103)
864d7c4c068f2 (Nicholas Piggin 2009-04-26 20:25:56 +1000 104) /*
864d7c4c068f2 (Nicholas Piggin 2009-04-26 20:25:56 +1000 105) * file_table.c
864d7c4c068f2 (Nicholas Piggin 2009-04-26 20:25:56 +1000 106) */
ea73ea7279884 (Al Viro 2018-07-11 15:00:04 -0400 107) extern struct file *alloc_empty_file(int, const struct cred *);
d3b1084dfd629 (Miklos Szeredi 2018-07-18 15:44:40 +0200 108) extern struct file *alloc_empty_file_noaccount(int, const struct cred *);
62c6943b4b1e8 (Al Viro 2009-05-07 03:12:29 -0400 109)
62c6943b4b1e8 (Al Viro 2009-05-07 03:12:29 -0400 110) /*
62c6943b4b1e8 (Al Viro 2009-05-07 03:12:29 -0400 111) * super.c
62c6943b4b1e8 (Al Viro 2009-05-07 03:12:29 -0400 112) */
8d0347f6c3a9d (David Howells 2018-11-04 09:28:36 -0500 113) extern int reconfigure_super(struct fs_context *);
eb6ef3df4faa5 (Konstantin Khlebnikov 2015-02-19 20:19:35 +0300 114) extern bool trylock_super(struct super_block *sb);
4e7b5671c6a88 (Christoph Hellwig 2020-11-23 13:38:40 +0100 115) struct super_block *user_get_super(dev_t, bool excl);
60b498852bf21 (Christoph Hellwig 2020-11-16 15:21:18 +0100 116) void put_super(struct super_block *sb);
20284ab7427ff (Al Viro 2019-05-12 17:31:45 -0400 117) extern bool mount_capable(struct fs_context *);
482928d59db66 (Al Viro 2009-12-19 10:10:39 -0500 118)
482928d59db66 (Al Viro 2009-12-19 10:10:39 -0500 119) /*
482928d59db66 (Al Viro 2009-12-19 10:10:39 -0500 120) * open.c
482928d59db66 (Al Viro 2009-12-19 10:10:39 -0500 121) */
47c805dc2d2df (Al Viro 2011-02-23 17:44:09 -0500 122) struct open_flags {
47c805dc2d2df (Al Viro 2011-02-23 17:44:09 -0500 123) int open_flag;
a218d0fdc5f90 (Al Viro 2011-11-21 14:59:34 -0500 124) umode_t mode;
47c805dc2d2df (Al Viro 2011-02-23 17:44:09 -0500 125) int acc_mode;
47c805dc2d2df (Al Viro 2011-02-23 17:44:09 -0500 126) int intent;
f9652e10c12b4 (Al Viro 2013-06-11 08:23:01 +0400 127) int lookup_flags;
47c805dc2d2df (Al Viro 2011-02-23 17:44:09 -0500 128) };
669abf4e5539c (Jeff Layton 2012-10-10 16:43:10 -0400 129) extern struct file *do_filp_open(int dfd, struct filename *pathname,
f9652e10c12b4 (Al Viro 2013-06-11 08:23:01 +0400 130) const struct open_flags *op);
73d049a40fc62 (Al Viro 2011-03-11 12:08:24 -0500 131) extern struct file *do_file_open_root(struct dentry *, struct vfsmount *,
f9652e10c12b4 (Al Viro 2013-06-11 08:23:01 +0400 132) const char *, const struct open_flags *);
35cb6d54c1d5d (Jens Axboe 2019-12-13 11:10:11 -0700 133) extern struct open_how build_open_how(int flags, umode_t mode);
35cb6d54c1d5d (Jens Axboe 2019-12-13 11:10:11 -0700 134) extern int build_open_flags(const struct open_how *how, struct open_flags *op);
53dec2ea74f2e (Jens Axboe 2021-01-19 15:41:52 -0700 135) extern int __close_fd_get_file(unsigned int fd, struct file **res);
a8dade34e3df5 (Al Viro 2010-10-24 11:13:10 -0400 136)
411d9475cf901 (Dominik Brodowski 2018-03-11 11:34:54 +0100 137) long do_sys_ftruncate(unsigned int fd, loff_t length, int small);
1097742efc643 (Christoph Hellwig 2020-07-22 11:41:02 +0200 138) int chmod_common(const struct path *path, umode_t mode);
55731b3cda3a8 (Dominik Brodowski 2018-03-11 11:34:55 +0100 139) int do_fchownat(int dfd, const char __user *filename, uid_t user, gid_t group,
55731b3cda3a8 (Dominik Brodowski 2018-03-11 11:34:55 +0100 140) int flag);
b873498f99c77 (Christoph Hellwig 2020-07-22 11:13:26 +0200 141) int chown_common(const struct path *path, uid_t user, gid_t group);
ae2bb293a3e8a (Al Viro 2018-07-10 13:22:28 -0400 142) extern int vfs_open(const struct path *, struct file *);
becfd1f375447 (Aneesh Kumar K.V 2011-01-29 18:43:26 +0530 143)
a8dade34e3df5 (Al Viro 2010-10-24 11:13:10 -0400 144) /*
a8dade34e3df5 (Al Viro 2010-10-24 11:13:10 -0400 145) * inode.c
a8dade34e3df5 (Al Viro 2010-10-24 11:13:10 -0400 146) */
503c358cf1925 (Vladimir Davydov 2015-02-12 14:58:47 -0800 147) extern long prune_icache_sb(struct super_block *sb, struct shrink_control *sc);
4eff96dd5283a (Jan Kara 2012-11-26 16:29:51 -0800 148) extern void inode_add_lru(struct inode *inode);
f0fce87c36aec (Miklos Szeredi 2016-08-03 13:44:27 +0200 149) extern int dentry_needs_remove_privs(struct dentry *dentry);
55fa6091d8316 (Dave Chinner 2011-03-22 22:23:40 +1100 150)
a66979abad090 (Dave Chinner 2011-03-22 22:23:41 +1100 151) /*
a66979abad090 (Dave Chinner 2011-03-22 22:23:41 +1100 152) * fs-writeback.c
a66979abad090 (Dave Chinner 2011-03-22 22:23:41 +1100 153) */
3942c07ccf98e (Glauber Costa 2013-08-28 10:17:53 +1000 154) extern long get_nr_dirty_inodes(void);
93b270f76e7ef (NeilBrown 2011-02-24 17:25:47 +1100 155) extern int invalidate_inodes(struct super_block *, bool);
a4464dbc0ca6a (Al Viro 2011-07-07 15:03:58 -0400 156)
a4464dbc0ca6a (Al Viro 2011-07-07 15:03:58 -0400 157) /*
a4464dbc0ca6a (Al Viro 2011-07-07 15:03:58 -0400 158) * dcache.c
a4464dbc0ca6a (Al Viro 2011-07-07 15:03:58 -0400 159) */
eed810076685c (Miklos Szeredi 2013-09-05 14:39:11 +0200 160) extern int d_set_mounted(struct dentry *dentry);
503c358cf1925 (Vladimir Davydov 2015-02-12 14:58:47 -0800 161) extern long prune_dcache_sb(struct super_block *sb, struct shrink_control *sc);
ba65dc5ef16f8 (Al Viro 2016-06-10 11:32:47 -0400 162) extern struct dentry *d_alloc_cursor(struct dentry *);
ab1152dd5650d (Al Viro 2019-03-15 22:58:11 -0400 163) extern struct dentry * d_alloc_pseudo(struct super_block *, const struct qstr *);
7e5f7bb08b8ce (Al Viro 2019-05-20 13:44:57 +0100 164) extern char *simple_dname(struct dentry *, char *, int);
9bdebc2bd1c4a (Al Viro 2019-06-29 18:31:24 -0400 165) extern void dput_to_list(struct dentry *, struct list_head *);
9bdebc2bd1c4a (Al Viro 2019-06-29 18:31:24 -0400 166) extern void shrink_dentry_list(struct list_head *);
06ae43f34bcc0 (Al Viro 2013-03-20 13:19:30 -0400 167)
06ae43f34bcc0 (Al Viro 2013-03-20 13:19:30 -0400 168) /*
06ae43f34bcc0 (Al Viro 2013-03-20 13:19:30 -0400 169) * read_write.c
06ae43f34bcc0 (Al Viro 2013-03-20 13:19:30 -0400 170) */
68d70d03f8f5b (Al Viro 2013-06-19 15:26:04 +0400 171) extern int rw_verify_area(int, struct file *, const loff_t *, size_t);
599a0ac14e065 (Al Viro 2013-03-12 09:58:10 -0400 172)
599a0ac14e065 (Al Viro 2013-03-12 09:58:10 -0400 173) /*
599a0ac14e065 (Al Viro 2013-03-12 09:58:10 -0400 174) * pipe.c
599a0ac14e065 (Al Viro 2013-03-12 09:58:10 -0400 175) */
599a0ac14e065 (Al Viro 2013-03-12 09:58:10 -0400 176) extern const struct file_operations pipefifo_fops;
8fa1f1c2bd860 (Al Viro 2014-05-21 18:22:52 -0400 177)
8fa1f1c2bd860 (Al Viro 2014-05-21 18:22:52 -0400 178) /*
8fa1f1c2bd860 (Al Viro 2014-05-21 18:22:52 -0400 179) * fs_pin.c
8fa1f1c2bd860 (Al Viro 2014-05-21 18:22:52 -0400 180) */
fdab684d72027 (Al Viro 2015-01-11 10:57:27 -0500 181) extern void group_pin_kill(struct hlist_head *p);
8fa1f1c2bd860 (Al Viro 2014-05-21 18:22:52 -0400 182) extern void mnt_pin_kill(struct mount *m);
e149ed2b805fe (Al Viro 2014-11-01 10:57:28 -0400 183)
e149ed2b805fe (Al Viro 2014-11-01 10:57:28 -0400 184) /*
e149ed2b805fe (Al Viro 2014-11-01 10:57:28 -0400 185) * fs/nsfs.c
e149ed2b805fe (Al Viro 2014-11-01 10:57:28 -0400 186) */
be218aa2e3f7a (Rasmus Villemoes 2016-09-15 00:15:34 +0200 187) extern const struct dentry_operations ns_dentry_operations;
66cf191f3eae4 (Al Viro 2016-01-07 09:53:30 -0500 188)
ec1b826097f30 (Christoph Hellwig 2016-11-30 14:33:53 +1100 189) /* direct-io.c: */
ec1b826097f30 (Christoph Hellwig 2016-11-30 14:33:53 +1100 190) int sb_init_dio_done_wq(struct super_block *sb);
3934e36f6099e (Jens Axboe 2019-12-14 13:26:33 -0700 191)
3934e36f6099e (Jens Axboe 2019-12-14 13:26:33 -0700 192) /*
3934e36f6099e (Jens Axboe 2019-12-14 13:26:33 -0700 193) * fs/stat.c:
3934e36f6099e (Jens Axboe 2019-12-14 13:26:33 -0700 194) */
0018784fc84f6 (Bijan Mottahedeh 2020-05-22 21:31:17 -0700 195) int do_statx(int dfd, const char __user *filename, unsigned flags,
0018784fc84f6 (Bijan Mottahedeh 2020-05-22 21:31:17 -0700 196) unsigned int mask, struct statx __user *buffer);
b964bf53e5402 (Al Viro 2021-01-25 22:24:28 -0500 197)
b964bf53e5402 (Al Viro 2021-01-25 22:24:28 -0500 198) /*
b964bf53e5402 (Al Viro 2021-01-25 22:24:28 -0500 199) * fs/splice.c:
b964bf53e5402 (Al Viro 2021-01-25 22:24:28 -0500 200) */
b964bf53e5402 (Al Viro 2021-01-25 22:24:28 -0500 201) long splice_file_to_pipe(struct file *in,
b964bf53e5402 (Al Viro 2021-01-25 22:24:28 -0500 202) struct pipe_inode_info *opipe,
b964bf53e5402 (Al Viro 2021-01-25 22:24:28 -0500 203) loff_t *offset,
b964bf53e5402 (Al Viro 2021-01-25 22:24:28 -0500 204) size_t len, unsigned int flags);