blob: 2f9750aefbd624d290ea966d1e3d5cf2f16a4839 [file] [log] [blame]
Thomas Gleixner2874c5f2019-05-27 08:55:01 +02001/* SPDX-License-Identifier: GPL-2.0-or-later */
David Howells07f3f052006-09-30 20:52:18 +02002/* fs/ internal definitions
3 *
4 * Copyright (C) 2006 Red Hat, Inc. All Rights Reserved.
5 * Written by David Howells (dhowells@redhat.com)
David Howells07f3f052006-09-30 20:52:18 +02006 */
7
Andrew Morton5e6d12b2006-08-31 12:55:23 +02008struct super_block;
Al Viro9d412a42011-03-17 22:08:28 -04009struct file_system_type;
Christoph Hellwigae259a92016-06-21 09:23:11 +100010struct iomap;
Christoph Hellwigbefb5032016-09-19 11:24:49 +100011struct iomap_ops;
David Howellsa6f76f22008-11-14 10:39:24 +110012struct linux_binprm;
Al Viro3e93cd62009-03-29 19:00:13 -040013struct path;
Al Viroc7105362011-11-24 18:22:03 -050014struct mount;
Vladimir Davydov503c3582015-02-12 14:58:47 -080015struct shrink_control;
David Howells9bc61ab2018-11-04 03:19:03 -050016struct fs_context;
Al Viro2527b282019-05-12 17:09:01 -040017struct user_namespace;
Al Virob964bf52021-01-25 22:24:28 -050018struct pipe_inode_info;
Andrew Morton5e6d12b2006-08-31 12:55:23 +020019
David Howells07f3f052006-09-30 20:52:18 +020020/*
21 * block_dev.c
22 */
David Howells93614012006-09-30 20:45:40 +020023#ifdef CONFIG_BLOCK
David Howells07f3f052006-09-30 20:52:18 +020024extern void __init bdev_cache_init(void);
25
Jan Kara5cee5812009-04-27 16:43:51 +020026extern int __sync_blockdev(struct block_device *bdev, int wait);
Christoph Hellwig3f1266f2020-06-20 09:16:41 +020027void iterate_bdevs(void (*)(struct block_device *, void *), void *);
28void emergency_thaw_bdev(struct super_block *sb);
Andrew Morton5e6d12b2006-08-31 12:55:23 +020029#else
30static inline void bdev_cache_init(void)
31{
32}
33
Jan Kara5cee5812009-04-27 16:43:51 +020034static inline int __sync_blockdev(struct block_device *bdev, int wait)
35{
36 return 0;
37}
Christoph Hellwig3f1266f2020-06-20 09:16:41 +020038static inline void iterate_bdevs(void (*f)(struct block_device *, void *),
39 void *arg)
40{
41}
42static inline int emergency_thaw_bdev(struct super_block *sb)
43{
44 return 0;
45}
Christoph Hellwig3f1266f2020-06-20 09:16:41 +020046#endif /* CONFIG_BLOCK */
David Howells7b0de422006-08-29 19:06:07 +010047
David Howells07f3f052006-09-30 20:52:18 +020048/*
Akinobu Mita4db96b72014-10-09 15:26:55 -070049 * buffer.c
50 */
Christoph Hellwigae259a92016-06-21 09:23:11 +100051extern int __block_write_begin_int(struct page *page, loff_t pos, unsigned len,
52 get_block_t *get_block, struct iomap *iomap);
Akinobu Mita4db96b72014-10-09 15:26:55 -070053
54/*
David Howells07f3f052006-09-30 20:52:18 +020055 * char_dev.c
56 */
57extern void __init chrdev_init(void);
58
59/*
David Howells9bc61ab2018-11-04 03:19:03 -050060 * fs_context.c
61 */
David Howellsecdab1502018-11-01 23:36:09 +000062extern const struct fs_context_operations legacy_fs_context_ops;
David Howells9bc61ab2018-11-04 03:19:03 -050063extern int parse_monolithic_mount_data(struct fs_context *, void *);
David Howellsecdab1502018-11-01 23:36:09 +000064extern void vfs_clean_context(struct fs_context *fc);
65extern int finish_clean_context(struct fs_context *fc);
David Howells9bc61ab2018-11-04 03:19:03 -050066
67/*
David Howells0bdaea92012-06-25 12:55:46 +010068 * namei.c
69 */
David Howells31d921c2018-11-01 23:07:24 +000070extern int filename_lookup(int dfd, struct filename *name, unsigned flags,
71 struct path *path, struct path *root);
Al Viro197df042013-09-08 14:03:27 -040072extern int vfs_path_lookup(struct dentry *, struct vfsmount *,
73 const char *, unsigned int, struct path *);
Dmitry Kadashev45f30da2021-07-08 13:34:44 +070074int do_rmdir(int dfd, struct filename *name);
75int do_unlinkat(int dfd, struct filename *name);
Christian Braunerba73d982021-01-21 14:19:31 +010076int may_linkat(struct user_namespace *mnt_userns, struct path *link);
Jens Axboee8866632020-09-26 17:20:17 -060077int do_renameat2(int olddfd, struct filename *oldname, int newdfd,
78 struct filename *newname, unsigned int flags);
Dmitry Kadashev45f30da2021-07-08 13:34:44 +070079int do_mkdirat(int dfd, struct filename *name, umode_t mode);
Dmitry Kadashev7a8721f2021-07-08 13:34:46 +070080int do_symlinkat(struct filename *from, int newdfd, struct filename *to);
David Howells0bdaea92012-06-25 12:55:46 +010081
82/*
David Howells07f3f052006-09-30 20:52:18 +020083 * namespace.c
84 */
Al Viroca71cf72016-11-20 19:45:28 -050085extern struct vfsmount *lookup_mnt(const struct path *);
Al Viro19a167a2011-01-17 01:35:23 -050086extern int finish_automount(struct vfsmount *, struct path *);
Al Viro6d59e7f2008-03-22 15:48:17 -040087
Miklos Szeredi4ed5e82f2011-11-21 12:11:31 +010088extern int sb_prepare_remount_readonly(struct super_block *);
Al Virof03c6592011-01-14 22:30:21 -050089
Al Viro6d59e7f2008-03-22 15:48:17 -040090extern void __init mnt_init(void);
Al Viro3e93cd62009-03-29 19:00:13 -040091
Jan Karaeb04c282012-06-12 16:20:35 +020092extern int __mnt_want_write_file(struct file *);
Jan Karaeb04c282012-06-12 16:20:35 +020093extern void __mnt_drop_write_file(struct file *);
Al Viro47cd8132010-02-05 02:01:14 -050094
Al Viroa07b2002018-11-05 17:40:30 +000095extern void dissolve_on_fput(struct vfsmount *);
Christoph Hellwigc60166f2020-07-21 11:12:08 +020096
97int path_mount(const char *dev_name, struct path *path,
98 const char *type_page, unsigned long flags, void *data_page);
Christoph Hellwig09267de2020-07-23 08:23:08 +020099int path_umount(struct path *path, int flags);
Christoph Hellwigc60166f2020-07-21 11:12:08 +0200100
Al Viro3e93cd62009-03-29 19:00:13 -0400101/*
102 * fs_struct.c
103 */
Al Virodcf787f2013-03-01 23:51:07 -0500104extern void chroot_fs_refs(const struct path *, const struct path *);
npiggin@suse.de864d7c42009-04-26 20:25:56 +1000105
106/*
107 * file_table.c
108 */
Al Viroea73ea72018-07-11 15:00:04 -0400109extern struct file *alloc_empty_file(int, const struct cred *);
Miklos Szeredid3b10842018-07-18 15:44:40 +0200110extern struct file *alloc_empty_file_noaccount(int, const struct cred *);
Al Viro62c69432009-05-07 03:12:29 -0400111
112/*
113 * super.c
114 */
David Howells8d0347f2018-11-04 09:28:36 -0500115extern int reconfigure_super(struct fs_context *);
Konstantin Khlebnikoveb6ef3d2015-02-19 20:19:35 +0300116extern bool trylock_super(struct super_block *sb);
Christoph Hellwig4e7b5672020-11-23 13:38:40 +0100117struct super_block *user_get_super(dev_t, bool excl);
Christoph Hellwig60b49882020-11-16 15:21:18 +0100118void put_super(struct super_block *sb);
Al Viro20284ab2019-05-12 17:31:45 -0400119extern bool mount_capable(struct fs_context *);
Al Viro482928d2009-12-19 10:10:39 -0500120
121/*
122 * open.c
123 */
Al Viro47c805d2011-02-23 17:44:09 -0500124struct open_flags {
125 int open_flag;
Al Viroa218d0f2011-11-21 14:59:34 -0500126 umode_t mode;
Al Viro47c805d2011-02-23 17:44:09 -0500127 int acc_mode;
128 int intent;
Al Virof9652e12013-06-11 08:23:01 +0400129 int lookup_flags;
Al Viro47c805d2011-02-23 17:44:09 -0500130};
Jeff Layton669abf42012-10-10 16:43:10 -0400131extern struct file *do_filp_open(int dfd, struct filename *pathname,
Al Virof9652e12013-06-11 08:23:01 +0400132 const struct open_flags *op);
Al Viroffb37ca2021-04-01 19:00:57 -0400133extern struct file *do_file_open_root(const struct path *,
Al Virof9652e12013-06-11 08:23:01 +0400134 const char *, const struct open_flags *);
Jens Axboe35cb6d52019-12-13 11:10:11 -0700135extern struct open_how build_open_how(int flags, umode_t mode);
136extern int build_open_flags(const struct open_how *how, struct open_flags *op);
Jens Axboe53dec2e2021-01-19 15:41:52 -0700137extern int __close_fd_get_file(unsigned int fd, struct file **res);
Al Viroa8dade32010-10-24 11:13:10 -0400138
Dominik Brodowski411d9472018-03-11 11:34:54 +0100139long do_sys_ftruncate(unsigned int fd, loff_t length, int small);
Christoph Hellwig10977422020-07-22 11:41:02 +0200140int chmod_common(const struct path *path, umode_t mode);
Dominik Brodowski55731b32018-03-11 11:34:55 +0100141int do_fchownat(int dfd, const char __user *filename, uid_t user, gid_t group,
142 int flag);
Christoph Hellwigb8734982020-07-22 11:13:26 +0200143int chown_common(const struct path *path, uid_t user, gid_t group);
Al Viroae2bb292018-07-10 13:22:28 -0400144extern int vfs_open(const struct path *, struct file *);
Aneesh Kumar K.Vbecfd1f2011-01-29 18:43:26 +0530145
Al Viroa8dade32010-10-24 11:13:10 -0400146/*
147 * inode.c
148 */
Vladimir Davydov503c3582015-02-12 14:58:47 -0800149extern long prune_icache_sb(struct super_block *sb, struct shrink_control *sc);
Jan Kara4eff96d2012-11-26 16:29:51 -0800150extern void inode_add_lru(struct inode *inode);
Miklos Szeredif0fce872016-08-03 13:44:27 +0200151extern int dentry_needs_remove_privs(struct dentry *dentry);
Dave Chinner55fa6092011-03-22 22:23:40 +1100152
Dave Chinnera66979a2011-03-22 22:23:41 +1100153/*
154 * fs-writeback.c
155 */
Glauber Costa3942c072013-08-28 10:17:53 +1000156extern long get_nr_dirty_inodes(void);
NeilBrown93b270f2011-02-24 17:25:47 +1100157extern int invalidate_inodes(struct super_block *, bool);
Al Viroa4464db2011-07-07 15:03:58 -0400158
159/*
160 * dcache.c
161 */
Miklos Szeredieed81002013-09-05 14:39:11 +0200162extern int d_set_mounted(struct dentry *dentry);
Vladimir Davydov503c3582015-02-12 14:58:47 -0800163extern long prune_dcache_sb(struct super_block *sb, struct shrink_control *sc);
Al Viroba65dc52016-06-10 11:32:47 -0400164extern struct dentry *d_alloc_cursor(struct dentry *);
Al Viroab1152d2019-03-15 22:58:11 -0400165extern struct dentry * d_alloc_pseudo(struct super_block *, const struct qstr *);
Al Viro7e5f7bb2019-05-20 13:44:57 +0100166extern char *simple_dname(struct dentry *, char *, int);
Al Viro9bdebc22019-06-29 18:31:24 -0400167extern void dput_to_list(struct dentry *, struct list_head *);
168extern void shrink_dentry_list(struct list_head *);
Al Viro06ae43f2013-03-20 13:19:30 -0400169
170/*
171 * read_write.c
172 */
Al Viro68d70d02013-06-19 15:26:04 +0400173extern int rw_verify_area(int, struct file *, const loff_t *, size_t);
Al Viro599a0ac2013-03-12 09:58:10 -0400174
175/*
176 * pipe.c
177 */
178extern const struct file_operations pipefifo_fops;
Al Viro8fa1f1c2014-05-21 18:22:52 -0400179
180/*
181 * fs_pin.c
182 */
Al Virofdab6842015-01-11 10:57:27 -0500183extern void group_pin_kill(struct hlist_head *p);
Al Viro8fa1f1c2014-05-21 18:22:52 -0400184extern void mnt_pin_kill(struct mount *m);
Al Viroe149ed22014-11-01 10:57:28 -0400185
186/*
187 * fs/nsfs.c
188 */
Rasmus Villemoesbe218aa2016-09-15 00:15:34 +0200189extern const struct dentry_operations ns_dentry_operations;
Al Viro66cf1912016-01-07 09:53:30 -0500190
Christoph Hellwigec1b8262016-11-30 14:33:53 +1100191/* direct-io.c: */
192int sb_init_dio_done_wq(struct super_block *sb);
Jens Axboe3934e362019-12-14 13:26:33 -0700193
194/*
195 * fs/stat.c:
196 */
Bijan Mottahedeh00187842020-05-22 21:31:17 -0700197int do_statx(int dfd, const char __user *filename, unsigned flags,
198 unsigned int mask, struct statx __user *buffer);
Al Virob964bf52021-01-25 22:24:28 -0500199
200/*
201 * fs/splice.c:
202 */
203long splice_file_to_pipe(struct file *in,
204 struct pipe_inode_info *opipe,
205 loff_t *offset,
206 size_t len, unsigned int flags);