]>
git.ipfire.org Git - thirdparty/kernel/linux.git/blob - fs/backing-file.c
1 // SPDX-License-Identifier: GPL-2.0-only
3 * Common helpers for stackable filesystems and backing files.
5 * Copyright (C) 2023 CTERA Networks.
9 #include <linux/backing-file.h>
14 * backing_file_open - open a backing file for kernel internal use
15 * @user_path: path that the user reuqested to open
17 * @real_path: path of the backing file
18 * @cred: credentials for open
20 * Open a backing file for a stackable filesystem (e.g., overlayfs).
21 * @user_path may be on the stackable filesystem and @real_path on the
22 * underlying filesystem. In this case, we want to be able to return the
23 * @user_path of the stackable filesystem. This is done by embedding the
24 * returned file into a container structure that also stores the stacked
25 * file's path, which can be retrieved using backing_file_user_path().
27 struct file
*backing_file_open(const struct path
*user_path
, int flags
,
28 const struct path
*real_path
,
29 const struct cred
*cred
)
34 f
= alloc_empty_backing_file(flags
, cred
);
39 *backing_file_user_path(f
) = *user_path
;
40 error
= vfs_open(real_path
, f
);
48 EXPORT_SYMBOL_GPL(backing_file_open
);