diff options
| author | Christian Brauner <[email protected]> | 2024-02-08 18:10:45 +0000 |
|---|---|---|
| committer | Christian Brauner <[email protected]> | 2024-02-25 11:05:08 +0000 |
| commit | bac0a9e56e1fd14b227ab57142eca6f7bc6e6115 (patch) | |
| tree | 685eb551d85a634533ec89b3eb99f505b718717e /fs/file_table.c | |
| parent | file: prepare for new helper (diff) | |
| download | kernel-bac0a9e56e1fd14b227ab57142eca6f7bc6e6115.tar.gz kernel-bac0a9e56e1fd14b227ab57142eca6f7bc6e6115.zip | |
file: add alloc_file_pseudo_noaccount()
When we open block devices as files we want to make sure to not charge
them against the open file limit of the caller as that can cause
spurious failures.
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Christian Brauner <[email protected]>
Diffstat (limited to 'fs/file_table.c')
| -rw-r--r-- | fs/file_table.c | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/fs/file_table.c b/fs/file_table.c index a94adac3d907..6925522faa0a 100644 --- a/fs/file_table.c +++ b/fs/file_table.c @@ -357,6 +357,30 @@ struct file *alloc_file_pseudo(struct inode *inode, struct vfsmount *mnt, } EXPORT_SYMBOL(alloc_file_pseudo); +struct file *alloc_file_pseudo_noaccount(struct inode *inode, + struct vfsmount *mnt, const char *name, + int flags, + const struct file_operations *fops) +{ + int ret; + struct path path; + struct file *file; + + ret = alloc_path_pseudo(name, inode, mnt, &path); + if (ret) + return ERR_PTR(ret); + + file = alloc_empty_file_noaccount(flags, current_cred()); + if (IS_ERR(file)) { + ihold(inode); + path_put(&path); + return file; + } + file_init_path(file, &path, fops); + return file; +} +EXPORT_SYMBOL_GPL(alloc_file_pseudo_noaccount); + struct file *alloc_file_clone(struct file *base, int flags, const struct file_operations *fops) { |
