]> git.proxmox.com Git - mirror_ubuntu-focal-kernel.git/blob - fs/aufs/sysaufs.h
195fe279b820de3c3760fdf476dbd351d2f5764e
[mirror_ubuntu-focal-kernel.git] / fs / aufs / sysaufs.h
1 /* SPDX-License-Identifier: GPL-2.0 */
2 /*
3 * Copyright (C) 2005-2019 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 * sysfs interface and mount lifetime management
21 */
22
23 #ifndef __SYSAUFS_H__
24 #define __SYSAUFS_H__
25
26 #ifdef __KERNEL__
27
28 #include <linux/sysfs.h>
29 #include "module.h"
30
31 struct super_block;
32 struct au_sbinfo;
33
34 struct sysaufs_si_attr {
35 struct attribute attr;
36 int (*show)(struct seq_file *seq, struct super_block *sb);
37 };
38
39 /* ---------------------------------------------------------------------- */
40
41 /* sysaufs.c */
42 extern unsigned long sysaufs_si_mask;
43 extern struct kset *sysaufs_kset;
44 extern struct attribute *sysaufs_si_attrs[];
45 int sysaufs_si_init(struct au_sbinfo *sbinfo);
46 int __init sysaufs_init(void);
47 void sysaufs_fin(void);
48
49 /* ---------------------------------------------------------------------- */
50
51 /* some people doesn't like to show a pointer in kernel */
52 static inline unsigned long sysaufs_si_id(struct au_sbinfo *sbinfo)
53 {
54 return sysaufs_si_mask ^ (unsigned long)sbinfo;
55 }
56
57 #define SysaufsSiNamePrefix "si_"
58 #define SysaufsSiNameLen (sizeof(SysaufsSiNamePrefix) + 16)
59 static inline void sysaufs_name(struct au_sbinfo *sbinfo, char *name)
60 {
61 snprintf(name, SysaufsSiNameLen, SysaufsSiNamePrefix "%lx",
62 sysaufs_si_id(sbinfo));
63 }
64
65 struct au_branch;
66 #ifdef CONFIG_SYSFS
67 /* sysfs.c */
68 extern struct attribute_group *sysaufs_attr_group;
69
70 int sysaufs_si_xi_path(struct seq_file *seq, struct super_block *sb);
71 ssize_t sysaufs_si_show(struct kobject *kobj, struct attribute *attr,
72 char *buf);
73 long au_brinfo_ioctl(struct file *file, unsigned long arg);
74 #ifdef CONFIG_COMPAT
75 long au_brinfo_compat_ioctl(struct file *file, unsigned long arg);
76 #endif
77
78 void sysaufs_br_init(struct au_branch *br);
79 void sysaufs_brs_add(struct super_block *sb, aufs_bindex_t bindex);
80 void sysaufs_brs_del(struct super_block *sb, aufs_bindex_t bindex);
81
82 #define sysaufs_brs_init() do {} while (0)
83
84 #else
85 #define sysaufs_attr_group NULL
86
87 AuStubInt0(sysaufs_si_xi_path, struct seq_file *seq, struct super_block *sb)
88 AuStub(ssize_t, sysaufs_si_show, return 0, struct kobject *kobj,
89 struct attribute *attr, char *buf)
90 AuStubVoid(sysaufs_br_init, struct au_branch *br)
91 AuStubVoid(sysaufs_brs_add, struct super_block *sb, aufs_bindex_t bindex)
92 AuStubVoid(sysaufs_brs_del, struct super_block *sb, aufs_bindex_t bindex)
93
94 static inline void sysaufs_brs_init(void)
95 {
96 sysaufs_brs = 0;
97 }
98
99 #endif /* CONFIG_SYSFS */
100
101 #endif /* __KERNEL__ */
102 #endif /* __SYSAUFS_H__ */