blob: 2bb444600852ec541c8706d17231a7f1d8952479 [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);
Dmitry Kadashevcf30da92021-07-08 13:34:47 +070081int do_linkat(int olddfd, struct filename *old, int newdfd,
82 struct filename *new, int flags);
David Howells0bdaea92012-06-25 12:55:46 +010083
84/*
David Howells07f3f052006-09-30 20:52:18 +020085 * namespace.c
86 */
Al Viroca71cf72016-11-20 19:45:28 -050087extern struct vfsmount *lookup_mnt(const struct path *);
Al Viro19a167a2011-01-17 01:35:23 -050088extern int finish_automount(struct vfsmount *, struct path *);
Al Viro6d59e7f2008-03-22 15:48:17 -040089
Miklos Szeredi4ed5e82f2011-11-21 12:11:31 +010090extern int sb_prepare_remount_readonly(struct super_block *);
Al Virof03c6592011-01-14 22:30:21 -050091
Al Viro6d59e7f2008-03-22 15:48:17 -040092extern void __init mnt_init(void);
Al Viro3e93cd62009-03-29 19:00:13 -040093
Jan Karaeb04c282012-06-12 16:20:35 +020094extern int __mnt_want_write_file(struct file *);
Jan Karaeb04c282012-06-12 16:20:35 +020095extern void __mnt_drop_write_file(struct file *);
Al Viro47cd8132010-02-05 02:01:14 -050096
Al Viroa07b2002018-11-05 17:40:30 +000097extern void dissolve_on_fput(struct vfsmount *);
Christoph Hellwigc60166f2020-07-21 11:12:08 +020098
99int path_mount(const char *dev_name, struct path *path,
100 const char *type_page, unsigned long flags, void *data_page);
Christoph Hellwig09267de2020-07-23 08:23:08 +0200101int path_umount(struct path *path, int flags);
Christoph Hellwigc60166f2020-07-21 11:12:08 +0200102
Al Viro3e93cd62009-03-29 19:00:13 -0400103/*
104 * fs_struct.c
105 */
Al Virodcf787f2013-03-01 23:51:07 -0500106extern void chroot_fs_refs(const struct path *, const struct path *);
npiggin@suse.de864d7c42009-04-26 20:25:56 +1000107
108/*
109 * file_table.c
110 */
Al Viroea73ea72018-07-11 15:00:04 -0400111extern struct file *alloc_empty_file(int, const struct cred *);
Miklos Szeredid3b10842018-07-18 15:44:40 +0200112extern struct file *alloc_empty_file_noaccount(int, const struct cred *);
Al Viro62c69432009-05-07 03:12:29 -0400113
114/*
115 * super.c
116 */
David Howells8d0347f2018-11-04 09:28:36 -0500117extern int reconfigure_super(struct fs_context *);
Konstantin Khlebnikoveb6ef3d2015-02-19 20:19:35 +0300118extern bool trylock_super(struct super_block *sb);
Christoph Hellwig4e7b5672020-11-23 13:38:40 +0100119struct super_block *user_get_super(dev_t, bool excl);
Christoph Hellwig60b49882020-11-16 15:21:18 +0100120void put_super(struct super_block *sb);
Al Viro20284ab2019-05-12 17:31:45 -0400121extern bool mount_capable(struct fs_context *);
Al Viro482928d2009-12-19 10:10:39 -0500122
123/*
124 * open.c
125 */
Al Viro47c805d2011-02-23 17:44:09 -0500126struct open_flags {
127 int open_flag;
Al Viroa218d0f2011-11-21 14:59:34 -0500128 umode_t mode;
Al Viro47c805d2011-02-23 17:44:09 -0500129 int acc_mode;
130 int intent;
Al Virof9652e12013-06-11 08:23:01 +0400131 int lookup_flags;
Al Viro47c805d2011-02-23 17:44:09 -0500132};
Jeff Layton669abf42012-10-10 16:43:10 -0400133extern struct file *do_filp_open(int dfd, struct filename *pathname,
Al Virof9652e12013-06-11 08:23:01 +0400134 const struct open_flags *op);
Al Viroffb37ca2021-04-01 19:00:57 -0400135extern struct file *do_file_open_root(const struct path *,
Al Virof9652e12013-06-11 08:23:01 +0400136 const char *, const struct open_flags *);
Jens Axboe35cb6d52019-12-13 11:10:11 -0700137extern struct open_how build_open_how(int flags, umode_t mode);
138extern int build_open_flags(const struct open_how *how, struct open_flags *op);
Jens Axboe53dec2e2021-01-19 15:41:52 -0700139extern int __close_fd_get_file(unsigned int fd, struct file **res);
Al Viroa8dade32010-10-24 11:13:10 -0400140
Dominik Brodowski411d9472018-03-11 11:34:54 +0100141long do_sys_ftruncate(unsigned int fd, loff_t length, int small);
Christoph Hellwig10977422020-07-22 11:41:02 +0200142int chmod_common(const struct path *path, umode_t mode);
Dominik Brodowski55731b32018-03-11 11:34:55 +0100143int do_fchownat(int dfd, const char __user *filename, uid_t user, gid_t group,
144 int flag);
Christoph Hellwigb8734982020-07-22 11:13:26 +0200145int chown_common(const struct path *path, uid_t user, gid_t group);
Al Viroae2bb292018-07-10 13:22:28 -0400146extern int vfs_open(const struct path *, struct file *);
Aneesh Kumar K.Vbecfd1f2011-01-29 18:43:26 +0530147
Al Viroa8dade32010-10-24 11:13:10 -0400148/*
149 * inode.c
150 */
Vladimir Davydov503c3582015-02-12 14:58:47 -0800151extern long prune_icache_sb(struct super_block *sb, struct shrink_control *sc);
Jan Kara4eff96d2012-11-26 16:29:51 -0800152extern void inode_add_lru(struct inode *inode);
Miklos Szeredif0fce872016-08-03 13:44:27 +0200153extern int dentry_needs_remove_privs(struct dentry *dentry);
Dave Chinner55fa6092011-03-22 22:23:40 +1100154
Dave Chinnera66979a2011-03-22 22:23:41 +1100155/*
156 * fs-writeback.c
157 */
Glauber Costa3942c072013-08-28 10:17:53 +1000158extern long get_nr_dirty_inodes(void);
NeilBrown93b270f2011-02-24 17:25:47 +1100159extern int invalidate_inodes(struct super_block *, bool);
Al Viroa4464db2011-07-07 15:03:58 -0400160
161/*
162 * dcache.c
163 */
Miklos Szeredieed81002013-09-05 14:39:11 +0200164extern int d_set_mounted(struct dentry *dentry);
Vladimir Davydov503c3582015-02-12 14:58:47 -0800165extern long prune_dcache_sb(struct super_block *sb, struct shrink_control *sc);
Al Viroba65dc52016-06-10 11:32:47 -0400166extern struct dentry *d_alloc_cursor(struct dentry *);
Al Viroab1152d2019-03-15 22:58:11 -0400167extern struct dentry * d_alloc_pseudo(struct super_block *, const struct qstr *);
Al Viro7e5f7bb2019-05-20 13:44:57 +0100168extern char *simple_dname(struct dentry *, char *, int);
Al Viro9bdebc22019-06-29 18:31:24 -0400169extern void dput_to_list(struct dentry *, struct list_head *);
170extern void shrink_dentry_list(struct list_head *);
Al Viro06ae43f2013-03-20 13:19:30 -0400171
172/*
173 * read_write.c
174 */
Al Viro68d70d02013-06-19 15:26:04 +0400175extern int rw_verify_area(int, struct file *, const loff_t *, size_t);
Al Viro599a0ac2013-03-12 09:58:10 -0400176
177/*
178 * pipe.c
179 */
180extern const struct file_operations pipefifo_fops;
Al Viro8fa1f1c2014-05-21 18:22:52 -0400181
182/*
183 * fs_pin.c
184 */
Al Virofdab6842015-01-11 10:57:27 -0500185extern void group_pin_kill(struct hlist_head *p);
Al Viro8fa1f1c2014-05-21 18:22:52 -0400186extern void mnt_pin_kill(struct mount *m);
Al Viroe149ed22014-11-01 10:57:28 -0400187
188/*
189 * fs/nsfs.c
190 */
Rasmus Villemoesbe218aa2016-09-15 00:15:34 +0200191extern const struct dentry_operations ns_dentry_operations;
Al Viro66cf1912016-01-07 09:53:30 -0500192
Christoph Hellwigec1b8262016-11-30 14:33:53 +1100193/* direct-io.c: */
194int sb_init_dio_done_wq(struct super_block *sb);
Jens Axboe3934e362019-12-14 13:26:33 -0700195
196/*
197 * fs/stat.c:
198 */
Bijan Mottahedeh00187842020-05-22 21:31:17 -0700199int do_statx(int dfd, const char __user *filename, unsigned flags,
200 unsigned int mask, struct statx __user *buffer);
Al Virob964bf52021-01-25 22:24:28 -0500201
202/*
203 * fs/splice.c:
204 */
205long splice_file_to_pipe(struct file *in,
206 struct pipe_inode_info *opipe,
207 loff_t *offset,
208 size_t len, unsigned int flags);