xref: /linux-6.15/include/linux/backing-file.h (revision a6293b3e)
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 /*
3  * Common helpers for stackable filesystems and backing files.
4  *
5  * Copyright (C) 2023 CTERA Networks.
6  */
7 
8 #ifndef _LINUX_BACKING_FILE_H
9 #define _LINUX_BACKING_FILE_H
10 
11 #include <linux/file.h>
12 #include <linux/uio.h>
13 #include <linux/fs.h>
14 
15 struct backing_file_ctx {
16 	const struct cred *cred;
17 	struct file *user_file;
18 	void (*accessed)(struct file *);
19 	void (*end_write)(struct file *);
20 };
21 
22 struct file *backing_file_open(const struct path *user_path, int flags,
23 			       const struct path *real_path,
24 			       const struct cred *cred);
25 ssize_t backing_file_read_iter(struct file *file, struct iov_iter *iter,
26 			       struct kiocb *iocb, int flags,
27 			       struct backing_file_ctx *ctx);
28 ssize_t backing_file_write_iter(struct file *file, struct iov_iter *iter,
29 				struct kiocb *iocb, int flags,
30 				struct backing_file_ctx *ctx);
31 
32 #endif /* _LINUX_BACKING_FILE_H */
33