blob: 87e96b9024ce1db0ee8b6b53a45e0122d7a5eb71 [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 Viro2527b2842019-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 Howells7b0de42d2006-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 */
Matthew Wilcox (Oracle)d1bd0b42021-11-03 14:05:47 -040040int __block_write_begin_int(struct folio *folio, loff_t pos, unsigned len,
Christoph Hellwig6d49cc82021-08-10 18:33:05 -070041 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 Viro1e2d84642021-06-18 20:27:57 -040077extern int finish_automount(struct vfsmount *, const 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 Viro47cd813f2010-02-05 02:01:14 -050085
Al Viroa07b2002018-11-05 17:40:30 +000086extern void dissolve_on_fput(struct vfsmount *);
Al Viroa5f85d72022-03-01 00:05:29 -050087extern bool may_mount(void);
Christoph Hellwigc60166f2020-07-21 11:12:08 +020088
89int path_mount(const char *dev_name, struct path *path,
90 const char *type_page, unsigned long flags, void *data_page);
Christoph Hellwig09267de2020-07-23 08:23:08 +020091int path_umount(struct path *path, int flags);
Christoph Hellwigc60166f2020-07-21 11:12:08 +020092
Al Viro3e93cd62009-03-29 19:00:13 -040093/*
94 * fs_struct.c
95 */
Al Virodcf787f2013-03-01 23:51:07 -050096extern void chroot_fs_refs(const struct path *, const struct path *);
npiggin@suse.de864d7c42009-04-26 20:25:56 +100097
98/*
99 * file_table.c
100 */
Al Viroea73ea72018-07-11 15:00:04 -0400101extern struct file *alloc_empty_file(int, const struct cred *);
Miklos Szeredid3b10842018-07-18 15:44:40 +0200102extern struct file *alloc_empty_file_noaccount(int, const struct cred *);
Al Viro62c69432009-05-07 03:12:29 -0400103
104/*
105 * super.c
106 */
David Howells8d0347f2018-11-04 09:28:36 -0500107extern int reconfigure_super(struct fs_context *);
Konstantin Khlebnikoveb6ef3d2015-02-19 20:19:35 +0300108extern bool trylock_super(struct super_block *sb);
Christoph Hellwig4e7b5672020-11-23 13:38:40 +0100109struct super_block *user_get_super(dev_t, bool excl);
Christoph Hellwig60b49882020-11-16 15:21:18 +0100110void put_super(struct super_block *sb);
Al Viro20284ab2019-05-12 17:31:45 -0400111extern bool mount_capable(struct fs_context *);
Al Viro482928d2009-12-19 10:10:39 -0500112
113/*
114 * open.c
115 */
Al Viro47c805d2011-02-23 17:44:09 -0500116struct open_flags {
117 int open_flag;
Al Viroa218d0f2011-11-21 14:59:34 -0500118 umode_t mode;
Al Viro47c805d2011-02-23 17:44:09 -0500119 int acc_mode;
120 int intent;
Al Virof9652e12013-06-11 08:23:01 +0400121 int lookup_flags;
Al Viro47c805d2011-02-23 17:44:09 -0500122};
Jeff Layton669abf42012-10-10 16:43:10 -0400123extern struct file *do_filp_open(int dfd, struct filename *pathname,
Al Virof9652e12013-06-11 08:23:01 +0400124 const struct open_flags *op);
Al Viroffb37ca2021-04-01 19:00:57 -0400125extern struct file *do_file_open_root(const struct path *,
Al Virof9652e12013-06-11 08:23:01 +0400126 const char *, const struct open_flags *);
Jens Axboe35cb6d52019-12-13 11:10:11 -0700127extern struct open_how build_open_how(int flags, umode_t mode);
128extern int build_open_flags(const struct open_how *how, struct open_flags *op);
Al Viro6319194e2022-05-12 17:08:03 -0400129extern struct file *__close_fd_get_file(unsigned int fd);
Al Viroa8dade32010-10-24 11:13:10 -0400130
Dominik Brodowski411d9472018-03-11 11:34:54 +0100131long do_sys_ftruncate(unsigned int fd, loff_t length, int small);
Christoph Hellwig10977422020-07-22 11:41:02 +0200132int chmod_common(const struct path *path, umode_t mode);
Dominik Brodowski55731b32018-03-11 11:34:55 +0100133int do_fchownat(int dfd, const char __user *filename, uid_t user, gid_t group,
134 int flag);
Christoph Hellwigb8734982020-07-22 11:13:26 +0200135int chown_common(const struct path *path, uid_t user, gid_t group);
Al Viroae2bb292018-07-10 13:22:28 -0400136extern int vfs_open(const struct path *, struct file *);
Aneesh Kumar K.Vbecfd1f2011-01-29 18:43:26 +0530137
Al Viroa8dade32010-10-24 11:13:10 -0400138/*
139 * inode.c
140 */
Vladimir Davydov503c3582015-02-12 14:58:47 -0800141extern long prune_icache_sb(struct super_block *sb, struct shrink_control *sc);
Miklos Szeredif0fce872016-08-03 13:44:27 +0200142extern int dentry_needs_remove_privs(struct dentry *dentry);
Dave Chinner55fa6092011-03-22 22:23:40 +1100143
Dave Chinnera66979a2011-03-22 22:23:41 +1100144/*
145 * fs-writeback.c
146 */
Glauber Costa3942c072013-08-28 10:17:53 +1000147extern long get_nr_dirty_inodes(void);
NeilBrown93b270f2011-02-24 17:25:47 +1100148extern int invalidate_inodes(struct super_block *, bool);
Al Viroa4464db2011-07-07 15:03:58 -0400149
150/*
151 * dcache.c
152 */
Miklos Szeredieed81002013-09-05 14:39:11 +0200153extern int d_set_mounted(struct dentry *dentry);
Vladimir Davydov503c3582015-02-12 14:58:47 -0800154extern long prune_dcache_sb(struct super_block *sb, struct shrink_control *sc);
Al Viroba65dc52016-06-10 11:32:47 -0400155extern struct dentry *d_alloc_cursor(struct dentry *);
Al Viroab1152d2019-03-15 22:58:11 -0400156extern struct dentry * d_alloc_pseudo(struct super_block *, const struct qstr *);
Al Viro7e5f7bb2019-05-20 13:44:57 +0100157extern char *simple_dname(struct dentry *, char *, int);
Al Viro9bdebc22019-06-29 18:31:24 -0400158extern void dput_to_list(struct dentry *, struct list_head *);
159extern void shrink_dentry_list(struct list_head *);
Al Viro06ae43f32013-03-20 13:19:30 -0400160
161/*
Al Viro599a0ac2013-03-12 09:58:10 -0400162 * pipe.c
163 */
164extern const struct file_operations pipefifo_fops;
Al Viro8fa1f1c2014-05-21 18:22:52 -0400165
166/*
167 * fs_pin.c
168 */
Al Virofdab6842015-01-11 10:57:27 -0500169extern void group_pin_kill(struct hlist_head *p);
Al Viro8fa1f1c2014-05-21 18:22:52 -0400170extern void mnt_pin_kill(struct mount *m);
Al Viroe149ed22014-11-01 10:57:28 -0400171
172/*
173 * fs/nsfs.c
174 */
Rasmus Villemoesbe218aa2016-09-15 00:15:34 +0200175extern const struct dentry_operations ns_dentry_operations;
Al Viro66cf1912016-01-07 09:53:30 -0500176
Christoph Hellwigec1b8262016-11-30 14:33:53 +1100177/* direct-io.c: */
178int sb_init_dio_done_wq(struct super_block *sb);
Jens Axboe3934e362019-12-14 13:26:33 -0700179
180/*
181 * fs/stat.c:
182 */
Stefan Roesch1b6fe6e2022-02-25 10:53:26 -0800183
184int getname_statx_lookup_flags(int flags);
185int do_statx(int dfd, struct filename *filename, unsigned int flags,
Bijan Mottahedeh00187842020-05-22 21:31:17 -0700186 unsigned int mask, struct statx __user *buffer);
Al Virob964bf52021-01-25 22:24:28 -0500187
188/*
189 * fs/splice.c:
190 */
191long splice_file_to_pipe(struct file *in,
192 struct pipe_inode_info *opipe,
193 loff_t *offset,
194 size_t len, unsigned int flags);
Stefan Roesch1a917942022-04-24 18:10:46 -0600195
196/*
197 * fs/xattr.c:
198 */
199struct xattr_name {
200 char name[XATTR_NAME_MAX + 1];
201};
202
203struct xattr_ctx {
204 /* Value of attribute */
205 union {
206 const void __user *cvalue;
207 void __user *value;
208 };
209 void *kvalue;
210 size_t size;
211 /* Attribute name */
212 struct xattr_name *kname;
213 unsigned int flags;
214};
215
Stefan Roeschc975cad2022-04-24 18:13:50 -0600216
217ssize_t do_getxattr(struct user_namespace *mnt_userns,
218 struct dentry *d,
219 struct xattr_ctx *ctx);
220
Stefan Roesch1a917942022-04-24 18:10:46 -0600221int setxattr_copy(const char __user *name, struct xattr_ctx *ctx);
222int do_setxattr(struct user_namespace *mnt_userns, struct dentry *dentry,
223 struct xattr_ctx *ctx);