]> git.proxmox.com Git - mirror_ubuntu-hirsute-kernel.git/blob - fs/aufs/dirren.h
UBUNTU: SAUCE: Import aufs driver
[mirror_ubuntu-hirsute-kernel.git] / fs / aufs / dirren.h
1 /* SPDX-License-Identifier: GPL-2.0 */
2 /*
3 * Copyright (C) 2017-2020 Junjiro R. Okajima
4 *
5 * This program, aufs is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18
19 /*
20 * renamed dir info
21 */
22
23 #ifndef __AUFS_DIRREN_H__
24 #define __AUFS_DIRREN_H__
25
26 #ifdef __KERNEL__
27
28 #include <linux/dcache.h>
29 #include <linux/statfs.h>
30 #include <linux/uuid.h>
31 #include "hbl.h"
32
33 #define AuDirren_NHASH 100
34
35 #ifdef CONFIG_AUFS_DIRREN
36 enum au_brid_type {
37 AuBrid_Unset,
38 AuBrid_UUID,
39 AuBrid_FSID,
40 AuBrid_DEV
41 };
42
43 struct au_dr_brid {
44 enum au_brid_type type;
45 union {
46 uuid_t uuid; /* unimplemented yet */
47 fsid_t fsid;
48 dev_t dev;
49 };
50 };
51
52 /* 20 is the max digits length of ulong 64 */
53 /* brid-type "_" uuid "_" inum */
54 #define AUFS_DIRREN_FNAME_SZ (1 + 1 + UUID_STRING_LEN + 20)
55 #define AUFS_DIRREN_ENV_VAL_SZ (AUFS_DIRREN_FNAME_SZ + 1 + 20)
56
57 struct au_dr_hino {
58 struct hlist_bl_node dr_hnode;
59 ino_t dr_h_ino;
60 };
61
62 struct au_dr_br {
63 struct hlist_bl_head dr_h_ino[AuDirren_NHASH];
64 struct au_dr_brid dr_brid;
65 };
66
67 struct au_dr_lookup {
68 /* dr_name is pointed by struct au_do_lookup_args.name */
69 struct qstr dr_name; /* subset of dr_info */
70 aufs_bindex_t ninfo;
71 struct au_drinfo **drinfo;
72 };
73 #else
74 struct au_dr_hino;
75 /* empty */
76 struct au_dr_br { };
77 struct au_dr_lookup { };
78 #endif
79
80 /* ---------------------------------------------------------------------- */
81
82 struct au_branch;
83 struct au_do_lookup_args;
84 struct au_hinode;
85 #ifdef CONFIG_AUFS_DIRREN
86 int au_dr_hino_test_add(struct au_dr_br *dr, ino_t h_ino,
87 struct au_dr_hino *add_ent);
88 void au_dr_hino_free(struct au_dr_br *dr);
89 int au_dr_br_init(struct super_block *sb, struct au_branch *br,
90 const struct path *path);
91 int au_dr_br_fin(struct super_block *sb, struct au_branch *br);
92 int au_dr_rename(struct dentry *src, aufs_bindex_t bindex,
93 struct qstr *dst_name, void *_rev);
94 void au_dr_rename_fin(struct dentry *src, aufs_bindex_t btgt, void *rev);
95 void au_dr_rename_rev(struct dentry *src, aufs_bindex_t bindex, void *rev);
96 int au_dr_lkup(struct au_do_lookup_args *lkup, struct dentry *dentry,
97 aufs_bindex_t bindex);
98 int au_dr_lkup_name(struct au_do_lookup_args *lkup, aufs_bindex_t btgt);
99 int au_dr_lkup_h_ino(struct au_do_lookup_args *lkup, aufs_bindex_t bindex,
100 ino_t h_ino);
101 void au_dr_lkup_fin(struct au_do_lookup_args *lkup);
102 int au_dr_opt_set(struct super_block *sb);
103 int au_dr_opt_flush(struct super_block *sb);
104 int au_dr_opt_clr(struct super_block *sb, int no_flush);
105 #else
106 AuStubInt0(au_dr_hino_test_add, struct au_dr_br *dr, ino_t h_ino,
107 struct au_dr_hino *add_ent);
108 AuStubVoid(au_dr_hino_free, struct au_dr_br *dr);
109 AuStubInt0(au_dr_br_init, struct super_block *sb, struct au_branch *br,
110 const struct path *path);
111 AuStubInt0(au_dr_br_fin, struct super_block *sb, struct au_branch *br);
112 AuStubInt0(au_dr_rename, struct dentry *src, aufs_bindex_t bindex,
113 struct qstr *dst_name, void *_rev);
114 AuStubVoid(au_dr_rename_fin, struct dentry *src, aufs_bindex_t btgt, void *rev);
115 AuStubVoid(au_dr_rename_rev, struct dentry *src, aufs_bindex_t bindex,
116 void *rev);
117 AuStubInt0(au_dr_lkup, struct au_do_lookup_args *lkup, struct dentry *dentry,
118 aufs_bindex_t bindex);
119 AuStubInt0(au_dr_lkup_name, struct au_do_lookup_args *lkup, aufs_bindex_t btgt);
120 AuStubInt0(au_dr_lkup_h_ino, struct au_do_lookup_args *lkup,
121 aufs_bindex_t bindex, ino_t h_ino);
122 AuStubVoid(au_dr_lkup_fin, struct au_do_lookup_args *lkup);
123 AuStubInt0(au_dr_opt_set, struct super_block *sb);
124 AuStubInt0(au_dr_opt_flush, struct super_block *sb);
125 AuStubInt0(au_dr_opt_clr, struct super_block *sb, int no_flush);
126 #endif
127
128 /* ---------------------------------------------------------------------- */
129
130 #ifdef CONFIG_AUFS_DIRREN
131 static inline int au_dr_ihash(ino_t h_ino)
132 {
133 return h_ino % AuDirren_NHASH;
134 }
135 #else
136 AuStubInt0(au_dr_ihash, ino_t h_ino);
137 #endif
138
139 #endif /* __KERNEL__ */
140 #endif /* __AUFS_DIRREN_H__ */