util.c (cbb44f0935974bba997f8db0458fac5739ae0009) util.c (f01d08899fd7fa808ff9b8d33ca4882ab44d42fa)
1// SPDX-License-Identifier: GPL-2.0-only
2/*
3 * Copyright (C) 2011 Novell Inc.
4 * Copyright (C) 2016 Red Hat, Inc.
5 */
6
7#include <linux/fs.h>
8#include <linux/mount.h>

--- 5 unchanged lines hidden (view full) ---

14#include <linux/fileattr.h>
15#include <linux/uuid.h>
16#include <linux/namei.h>
17#include <linux/ratelimit.h>
18#include "overlayfs.h"
19
20int ovl_want_write(struct dentry *dentry)
21{
1// SPDX-License-Identifier: GPL-2.0-only
2/*
3 * Copyright (C) 2011 Novell Inc.
4 * Copyright (C) 2016 Red Hat, Inc.
5 */
6
7#include <linux/fs.h>
8#include <linux/mount.h>

--- 5 unchanged lines hidden (view full) ---

14#include <linux/fileattr.h>
15#include <linux/uuid.h>
16#include <linux/namei.h>
17#include <linux/ratelimit.h>
18#include "overlayfs.h"
19
20int ovl_want_write(struct dentry *dentry)
21{
22 struct ovl_fs *ofs = dentry->d_sb->s_fs_info;
22 struct ovl_fs *ofs = OVL_FS(dentry->d_sb);
23 return mnt_want_write(ovl_upper_mnt(ofs));
24}
25
26void ovl_drop_write(struct dentry *dentry)
27{
23 return mnt_want_write(ovl_upper_mnt(ofs));
24}
25
26void ovl_drop_write(struct dentry *dentry)
27{
28 struct ovl_fs *ofs = dentry->d_sb->s_fs_info;
28 struct ovl_fs *ofs = OVL_FS(dentry->d_sb);
29 mnt_drop_write(ovl_upper_mnt(ofs));
30}
31
32struct dentry *ovl_workdir(struct dentry *dentry)
33{
29 mnt_drop_write(ovl_upper_mnt(ofs));
30}
31
32struct dentry *ovl_workdir(struct dentry *dentry)
33{
34 struct ovl_fs *ofs = dentry->d_sb->s_fs_info;
34 struct ovl_fs *ofs = OVL_FS(dentry->d_sb);
35 return ofs->workdir;
36}
37
38const struct cred *ovl_override_creds(struct super_block *sb)
39{
35 return ofs->workdir;
36}
37
38const struct cred *ovl_override_creds(struct super_block *sb)
39{
40 struct ovl_fs *ofs = sb->s_fs_info;
40 struct ovl_fs *ofs = OVL_FS(sb);
41
42 return override_creds(ofs->creator_cred);
43}
44
45/*
46 * Check if underlying fs supports file handles and try to determine encoding
47 * type, in order to deduce maximum inode number used by fs.
48 *

--- 9 unchanged lines hidden (view full) ---

58 if (!sb->s_export_op || !sb->s_export_op->fh_to_dentry)
59 return 0;
60
61 return sb->s_export_op->encode_fh ? -1 : FILEID_INO32_GEN;
62}
63
64struct dentry *ovl_indexdir(struct super_block *sb)
65{
41
42 return override_creds(ofs->creator_cred);
43}
44
45/*
46 * Check if underlying fs supports file handles and try to determine encoding
47 * type, in order to deduce maximum inode number used by fs.
48 *

--- 9 unchanged lines hidden (view full) ---

58 if (!sb->s_export_op || !sb->s_export_op->fh_to_dentry)
59 return 0;
60
61 return sb->s_export_op->encode_fh ? -1 : FILEID_INO32_GEN;
62}
63
64struct dentry *ovl_indexdir(struct super_block *sb)
65{
66 struct ovl_fs *ofs = sb->s_fs_info;
66 struct ovl_fs *ofs = OVL_FS(sb);
67
68 return ofs->indexdir;
69}
70
71/* Index all files on copy up. For now only enabled for NFS export */
72bool ovl_index_all(struct super_block *sb)
73{
67
68 return ofs->indexdir;
69}
70
71/* Index all files on copy up. For now only enabled for NFS export */
72bool ovl_index_all(struct super_block *sb)
73{
74 struct ovl_fs *ofs = sb->s_fs_info;
74 struct ovl_fs *ofs = OVL_FS(sb);
75
76 return ofs->config.nfs_export && ofs->config.index;
77}
78
79/* Verify lower origin on lookup. For now only enabled for NFS export */
80bool ovl_verify_lower(struct super_block *sb)
81{
75
76 return ofs->config.nfs_export && ofs->config.index;
77}
78
79/* Verify lower origin on lookup. For now only enabled for NFS export */
80bool ovl_verify_lower(struct super_block *sb)
81{
82 struct ovl_fs *ofs = sb->s_fs_info;
82 struct ovl_fs *ofs = OVL_FS(sb);
83
84 return ofs->config.nfs_export && ofs->config.index;
85}
86
87struct ovl_path *ovl_stack_alloc(unsigned int n)
88{
89 return kcalloc(n, sizeof(struct ovl_path), GFP_KERNEL);
90}

--- 108 unchanged lines hidden (view full) ---

199 if (ovl_numlower(oe) > 1)
200 type |= __OVL_PATH_MERGE;
201 }
202 return type;
203}
204
205void ovl_path_upper(struct dentry *dentry, struct path *path)
206{
83
84 return ofs->config.nfs_export && ofs->config.index;
85}
86
87struct ovl_path *ovl_stack_alloc(unsigned int n)
88{
89 return kcalloc(n, sizeof(struct ovl_path), GFP_KERNEL);
90}

--- 108 unchanged lines hidden (view full) ---

199 if (ovl_numlower(oe) > 1)
200 type |= __OVL_PATH_MERGE;
201 }
202 return type;
203}
204
205void ovl_path_upper(struct dentry *dentry, struct path *path)
206{
207 struct ovl_fs *ofs = dentry->d_sb->s_fs_info;
207 struct ovl_fs *ofs = OVL_FS(dentry->d_sb);
208
209 path->mnt = ovl_upper_mnt(ofs);
210 path->dentry = ovl_dentry_upper(dentry);
211}
212
213void ovl_path_lower(struct dentry *dentry, struct path *path)
214{
215 struct ovl_entry *oe = OVL_E(dentry);

--- 1201 unchanged lines hidden ---
208
209 path->mnt = ovl_upper_mnt(ofs);
210 path->dentry = ovl_dentry_upper(dentry);
211}
212
213void ovl_path_lower(struct dentry *dentry, struct path *path)
214{
215 struct ovl_entry *oe = OVL_E(dentry);

--- 1201 unchanged lines hidden ---