blob: 7979ff8d168cc205d318b4681549cb49f2307cbe [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/*
Christoph Hellwig0dca4462021-09-07 16:13:03 +020021 * block/bdev.c
David Howells07f3f052006-09-30 20:52:18 +020022 */
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
Christoph Hellwig3f1266f2020-06-20 09:16:41 +020026void emergency_thaw_bdev(struct super_block *sb);
Andrew Morton5e6d12b2006-08-31 12:55:23 +020027#else
28static inline void bdev_cache_init(void)
29{
30}
Christoph Hellwig3f1266f2020-06-20 09:16:41 +020031static inline int emergency_thaw_bdev(struct super_block *sb)
32{
33 return 0;
34}
Christoph Hellwig3f1266f2020-06-20 09:16:41 +020035#endif /* CONFIG_BLOCK */
David Howells7b0de422006-08-29 19:06:07 +010036
David Howells07f3f052006-09-30 20:52:18 +020037/*
Akinobu Mita4db96b72014-10-09 15:26:55 -070038 * buffer.c
39 */
Christoph Hellwig6d49cc82021-08-10 18:33:05 -070040int __block_write_begin_int(struct page *page, loff_t pos, unsigned len,
41 get_block_t *get_block, const struct iomap *iomap);
Akinobu Mita4db96b72014-10-09 15:26:55 -070042
43/*
David Howells07f3f052006-09-30 20:52:18 +020044 * char_dev.c
45 */
46extern void __init chrdev_init(void);
47
48/*
David Howells9bc61ab2018-11-04 03:19:03 -050049 * fs_context.c
50 */
David Howellsecdab1502018-11-01 23:36:09 +000051extern const struct fs_context_operations legacy_fs_context_ops;
David Howells9bc61ab2018-11-04 03:19:03 -050052extern int parse_monolithic_mount_data(struct fs_context *, void *);
David Howellsecdab1502018-11-01 23:36:09 +000053extern void vfs_clean_context(struct fs_context *fc);
54extern int finish_clean_context(struct fs_context *fc);
David Howells9bc61ab2018-11-04 03:19:03 -050055
56/*
David Howells0bdaea92012-06-25 12:55:46 +010057 * namei.c
58 */
David Howells31d921c2018-11-01 23:07:24 +000059extern int filename_lookup(int dfd, struct filename *name, unsigned flags,
60 struct path *path, struct path *root);
Al Viro197df042013-09-08 14:03:27 -040061extern int vfs_path_lookup(struct dentry *, struct vfsmount *,
62 const char *, unsigned int, struct path *);
Dmitry Kadashev45f30da2021-07-08 13:34:44 +070063int do_rmdir(int dfd, struct filename *name);
64int do_unlinkat(int dfd, struct filename *name);
Christian Braunerba73d982021-01-21 14:19:31 +010065int may_linkat(struct user_namespace *mnt_userns, struct path *link);
Jens Axboee8866632020-09-26 17:20:17 -060066int do_renameat2(int olddfd, struct filename *oldname, int newdfd,
67 struct filename *newname, unsigned int flags);
Dmitry Kadashev45f30da2021-07-08 13:34:44 +070068int do_mkdirat(int dfd, struct filename *name, umode_t mode);
Dmitry Kadashev7a8721f2021-07-08 13:34:46 +070069int do_symlinkat(struct filename *from, int newdfd, struct filename *to);
Dmitry Kadashevcf30da92021-07-08 13:34:47 +070070int do_linkat(int olddfd, struct filename *old, int newdfd,
71 struct filename *new, int flags);
David Howells0bdaea92012-06-25 12:55:46 +010072
73/*
David Howells07f3f052006-09-30 20:52:18 +020074 * namespace.c
75 */
Al Viroca71cf72016-11-20 19:45:28 -050076extern struct vfsmount *lookup_mnt(const struct path *);
Al Viro19a167a2011-01-17 01:35:23 -050077extern int finish_automount(struct vfsmount *, struct path *);
Al Viro6d59e7f2008-03-22 15:48:17 -040078
Miklos Szeredi4ed5e82f2011-11-21 12:11:31 +010079extern int sb_prepare_remount_readonly(struct super_block *);
Al Virof03c6592011-01-14 22:30:21 -050080
Al Viro6d59e7f2008-03-22 15:48:17 -040081extern void __init mnt_init(void);
Al Viro3e93cd62009-03-29 19:00:13 -040082
Jan Karaeb04c282012-06-12 16:20:35 +020083extern int __mnt_want_write_file(struct file *);
Jan Karaeb04c282012-06-12 16:20:35 +020084extern void __mnt_drop_write_file(struct file *);
Al Viro47cd8132010-02-05 02:01:14 -050085
Al Viroa07b2002018-11-05 17:40:30 +000086extern void dissolve_on_fput(struct vfsmount *);
Christoph Hellwigc60166f2020-07-21 11:12:08 +020087
88int path_mount(const char *dev_name, struct path *path,
89 const char *type_page, unsigned long flags, void *data_page);
Christoph Hellwig09267de2020-07-23 08:23:08 +020090int path_umount(struct path *path, int flags);
Christoph Hellwigc60166f2020-07-21 11:12:08 +020091
Al Viro3e93cd62009-03-29 19:00:13 -040092/*
93 * fs_struct.c
94 */
Al Virodcf787f2013-03-01 23:51:07 -050095extern void chroot_fs_refs(const struct path *, const struct path *);
npiggin@suse.de864d7c42009-04-26 20:25:56 +100096
97/*
98 * file_table.c
99 */
Al Viroea73ea72018-07-11 15:00:04 -0400100extern struct file *alloc_empty_file(int, const struct cred *);
Miklos Szeredid3b10842018-07-18 15:44:40 +0200101extern struct file *alloc_empty_file_noaccount(int, const struct cred *);
Al Viro62c69432009-05-07 03:12:29 -0400102
103/*
104 * super.c
105 */
David Howells8d0347f2018-11-04 09:28:36 -0500106extern int reconfigure_super(struct fs_context *);
Konstantin Khlebnikoveb6ef3d2015-02-19 20:19:35 +0300107extern bool trylock_super(struct super_block *sb);
Christoph Hellwig4e7b5672020-11-23 13:38:40 +0100108struct super_block *user_get_super(dev_t, bool excl);
Christoph Hellwig60b49882020-11-16 15:21:18 +0100109void put_super(struct super_block *sb);
Al Viro20284ab2019-05-12 17:31:45 -0400110extern bool mount_capable(struct fs_context *);
Al Viro482928d2009-12-19 10:10:39 -0500111
112/*
113 * open.c
114 */
Al Viro47c805d2011-02-23 17:44:09 -0500115struct open_flags {
116 int open_flag;
Al Viroa218d0f2011-11-21 14:59:34 -0500117 umode_t mode;
Al Viro47c805d2011-02-23 17:44:09 -0500118 int acc_mode;
119 int intent;
Al Virof9652e12013-06-11 08:23:01 +0400120 int lookup_flags;
Al Viro47c805d2011-02-23 17:44:09 -0500121};
Jeff Layton669abf42012-10-10 16:43:10 -0400122extern struct file *do_filp_open(int dfd, struct filename *pathname,
Al Virof9652e12013-06-11 08:23:01 +0400123 const struct open_flags *op);
Al Viroffb37ca2021-04-01 19:00:57 -0400124extern struct file *do_file_open_root(const struct path *,
Al Virof9652e12013-06-11 08:23:01 +0400125 const char *, const struct open_flags *);
Jens Axboe35cb6d52019-12-13 11:10:11 -0700126extern struct open_how build_open_how(int flags, umode_t mode);
127extern int build_open_flags(const struct open_how *how, struct open_flags *op);
Jens Axboe53dec2e2021-01-19 15:41:52 -0700128extern int __close_fd_get_file(unsigned int fd, struct file **res);
Al Viroa8dade32010-10-24 11:13:10 -0400129
Dominik Brodowski411d9472018-03-11 11:34:54 +0100130long do_sys_ftruncate(unsigned int fd, loff_t length, int small);
Christoph Hellwig10977422020-07-22 11:41:02 +0200131int chmod_common(const struct path *path, umode_t mode);
Dominik Brodowski55731b32018-03-11 11:34:55 +0100132int do_fchownat(int dfd, const char __user *filename, uid_t user, gid_t group,
133 int flag);
Christoph Hellwigb8734982020-07-22 11:13:26 +0200134int chown_common(const struct path *path, uid_t user, gid_t group);
Al Viroae2bb292018-07-10 13:22:28 -0400135extern int vfs_open(const struct path *, struct file *);
Aneesh Kumar K.Vbecfd1f2011-01-29 18:43:26 +0530136
Al Viroa8dade32010-10-24 11:13:10 -0400137/*
138 * inode.c
139 */
Vladimir Davydov503c3582015-02-12 14:58:47 -0800140extern long prune_icache_sb(struct super_block *sb, struct shrink_control *sc);
Miklos Szeredif0fce872016-08-03 13:44:27 +0200141extern int dentry_needs_remove_privs(struct dentry *dentry);
Dave Chinner55fa6092011-03-22 22:23:40 +1100142
Dave Chinnera66979a2011-03-22 22:23:41 +1100143/*
144 * fs-writeback.c
145 */
Glauber Costa3942c072013-08-28 10:17:53 +1000146extern long get_nr_dirty_inodes(void);
NeilBrown93b270f2011-02-24 17:25:47 +1100147extern int invalidate_inodes(struct super_block *, bool);
Al Viroa4464db2011-07-07 15:03:58 -0400148
149/*
150 * dcache.c
151 */
Miklos Szeredieed81002013-09-05 14:39:11 +0200152extern int d_set_mounted(struct dentry *dentry);
Vladimir Davydov503c3582015-02-12 14:58:47 -0800153extern long prune_dcache_sb(struct super_block *sb, struct shrink_control *sc);
Al Viroba65dc52016-06-10 11:32:47 -0400154extern struct dentry *d_alloc_cursor(struct dentry *);
Al Viroab1152d2019-03-15 22:58:11 -0400155extern struct dentry * d_alloc_pseudo(struct super_block *, const struct qstr *);
Al Viro7e5f7bb2019-05-20 13:44:57 +0100156extern char *simple_dname(struct dentry *, char *, int);
Al Viro9bdebc22019-06-29 18:31:24 -0400157extern void dput_to_list(struct dentry *, struct list_head *);
158extern void shrink_dentry_list(struct list_head *);
Al Viro06ae43f2013-03-20 13:19:30 -0400159
160/*
161 * read_write.c
162 */
Al Viro68d70d02013-06-19 15:26:04 +0400163extern int rw_verify_area(int, struct file *, const loff_t *, size_t);
Al Viro599a0ac2013-03-12 09:58:10 -0400164
165/*
166 * pipe.c
167 */
168extern const struct file_operations pipefifo_fops;
Al Viro8fa1f1c2014-05-21 18:22:52 -0400169
170/*
171 * fs_pin.c
172 */
Al Virofdab6842015-01-11 10:57:27 -0500173extern void group_pin_kill(struct hlist_head *p);
Al Viro8fa1f1c2014-05-21 18:22:52 -0400174extern void mnt_pin_kill(struct mount *m);
Al Viroe149ed22014-11-01 10:57:28 -0400175
176/*
177 * fs/nsfs.c
178 */
Rasmus Villemoesbe218aa2016-09-15 00:15:34 +0200179extern const struct dentry_operations ns_dentry_operations;
Al Viro66cf1912016-01-07 09:53:30 -0500180
Christoph Hellwigec1b8262016-11-30 14:33:53 +1100181/* direct-io.c: */
182int sb_init_dio_done_wq(struct super_block *sb);
Jens Axboe3934e362019-12-14 13:26:33 -0700183
184/*
185 * fs/stat.c:
186 */
Bijan Mottahedeh00187842020-05-22 21:31:17 -0700187int do_statx(int dfd, const char __user *filename, unsigned flags,
188 unsigned int mask, struct statx __user *buffer);
Al Virob964bf52021-01-25 22:24:28 -0500189
190/*
191 * fs/splice.c:
192 */
193long splice_file_to_pipe(struct file *in,
194 struct pipe_inode_info *opipe,
195 loff_t *offset,
196 size_t len, unsigned int flags);