Commit | Line | Data |
---|---|---|
63e2b423 JJ |
1 | /* |
2 | * AppArmor security module | |
3 | * | |
4 | * This file contains AppArmor filesystem definitions. | |
5 | * | |
6 | * Copyright (C) 1998-2008 Novell/SUSE | |
7 | * Copyright 2009-2010 Canonical Ltd. | |
8 | * | |
9 | * This program is free software; you can redistribute it and/or | |
10 | * modify it under the terms of the GNU General Public License as | |
11 | * published by the Free Software Foundation, version 2 of the | |
12 | * License. | |
13 | */ | |
14 | ||
15 | #ifndef __AA_APPARMORFS_H | |
16 | #define __AA_APPARMORFS_H | |
17 | ||
a71ada30 JJ |
18 | extern struct path aa_null; |
19 | ||
c97204ba JJ |
20 | enum aa_sfs_type { |
21 | AA_SFS_TYPE_BOOLEAN, | |
22 | AA_SFS_TYPE_STRING, | |
23 | AA_SFS_TYPE_U64, | |
24 | AA_SFS_TYPE_FOPS, | |
25 | AA_SFS_TYPE_DIR, | |
9acd494b KC |
26 | }; |
27 | ||
c97204ba | 28 | struct aa_sfs_entry; |
9acd494b | 29 | |
c97204ba | 30 | struct aa_sfs_entry { |
9acd494b KC |
31 | const char *name; |
32 | struct dentry *dentry; | |
33 | umode_t mode; | |
c97204ba | 34 | enum aa_sfs_type v_type; |
9acd494b | 35 | union { |
e74abcf3 | 36 | bool boolean; |
a9bf8e9f | 37 | char *string; |
e74abcf3 | 38 | unsigned long u64; |
c97204ba | 39 | struct aa_sfs_entry *files; |
9acd494b KC |
40 | } v; |
41 | const struct file_operations *file_ops; | |
42 | }; | |
43 | ||
c97204ba | 44 | extern const struct file_operations aa_sfs_seq_file_ops; |
e74abcf3 | 45 | |
c97204ba | 46 | #define AA_SFS_FILE_BOOLEAN(_name, _value) \ |
e74abcf3 | 47 | { .name = (_name), .mode = 0444, \ |
c97204ba JJ |
48 | .v_type = AA_SFS_TYPE_BOOLEAN, .v.boolean = (_value), \ |
49 | .file_ops = &aa_sfs_seq_file_ops } | |
50 | #define AA_SFS_FILE_STRING(_name, _value) \ | |
a9bf8e9f | 51 | { .name = (_name), .mode = 0444, \ |
c97204ba JJ |
52 | .v_type = AA_SFS_TYPE_STRING, .v.string = (_value), \ |
53 | .file_ops = &aa_sfs_seq_file_ops } | |
54 | #define AA_SFS_FILE_U64(_name, _value) \ | |
e74abcf3 | 55 | { .name = (_name), .mode = 0444, \ |
c97204ba JJ |
56 | .v_type = AA_SFS_TYPE_U64, .v.u64 = (_value), \ |
57 | .file_ops = &aa_sfs_seq_file_ops } | |
58 | #define AA_SFS_FILE_FOPS(_name, _mode, _fops) \ | |
59 | { .name = (_name), .v_type = AA_SFS_TYPE_FOPS, \ | |
9acd494b | 60 | .mode = (_mode), .file_ops = (_fops) } |
c97204ba JJ |
61 | #define AA_SFS_DIR(_name, _value) \ |
62 | { .name = (_name), .v_type = AA_SFS_TYPE_DIR, .v.files = (_value) } | |
9acd494b | 63 | |
63e2b423 JJ |
64 | extern void __init aa_destroy_aafs(void); |
65 | ||
0d259f04 | 66 | struct aa_profile; |
98849dff | 67 | struct aa_ns; |
0d259f04 JJ |
68 | |
69 | enum aafs_ns_type { | |
70 | AAFS_NS_DIR, | |
71 | AAFS_NS_PROFS, | |
72 | AAFS_NS_NS, | |
5ac8c355 | 73 | AAFS_NS_RAW_DATA, |
b7fd2c03 JJ |
74 | AAFS_NS_LOAD, |
75 | AAFS_NS_REPLACE, | |
76 | AAFS_NS_REMOVE, | |
d9bf2c26 | 77 | AAFS_NS_REVISION, |
0d259f04 JJ |
78 | AAFS_NS_COUNT, |
79 | AAFS_NS_MAX_COUNT, | |
80 | AAFS_NS_SIZE, | |
81 | AAFS_NS_MAX_SIZE, | |
82 | AAFS_NS_OWNER, | |
83 | AAFS_NS_SIZEOF, | |
84 | }; | |
85 | ||
86 | enum aafs_prof_type { | |
87 | AAFS_PROF_DIR, | |
88 | AAFS_PROF_PROFS, | |
89 | AAFS_PROF_NAME, | |
90 | AAFS_PROF_MODE, | |
556d0be7 | 91 | AAFS_PROF_ATTACH, |
f8eb8a13 | 92 | AAFS_PROF_HASH, |
5ac8c355 JJ |
93 | AAFS_PROF_RAW_DATA, |
94 | AAFS_PROF_RAW_HASH, | |
95 | AAFS_PROF_RAW_ABI, | |
0d259f04 JJ |
96 | AAFS_PROF_SIZEOF, |
97 | }; | |
98 | ||
99 | #define ns_dir(X) ((X)->dents[AAFS_NS_DIR]) | |
100 | #define ns_subns_dir(X) ((X)->dents[AAFS_NS_NS]) | |
101 | #define ns_subprofs_dir(X) ((X)->dents[AAFS_NS_PROFS]) | |
5ac8c355 | 102 | #define ns_subdata_dir(X) ((X)->dents[AAFS_NS_RAW_DATA]) |
b7fd2c03 JJ |
103 | #define ns_subload(X) ((X)->dents[AAFS_NS_LOAD]) |
104 | #define ns_subreplace(X) ((X)->dents[AAFS_NS_REPLACE]) | |
105 | #define ns_subremove(X) ((X)->dents[AAFS_NS_REMOVE]) | |
d9bf2c26 | 106 | #define ns_subrevision(X) ((X)->dents[AAFS_NS_REVISION]) |
0d259f04 JJ |
107 | |
108 | #define prof_dir(X) ((X)->dents[AAFS_PROF_DIR]) | |
109 | #define prof_child_dir(X) ((X)->dents[AAFS_PROF_PROFS]) | |
110 | ||
5d5182ca | 111 | void __aa_bump_ns_revision(struct aa_ns *ns); |
c97204ba JJ |
112 | void __aafs_profile_rmdir(struct aa_profile *profile); |
113 | void __aafs_profile_migrate_dents(struct aa_profile *old, | |
0d259f04 | 114 | struct aa_profile *new); |
c97204ba JJ |
115 | int __aafs_profile_mkdir(struct aa_profile *profile, struct dentry *parent); |
116 | void __aafs_ns_rmdir(struct aa_ns *ns); | |
98407f0a JJ |
117 | int __aafs_ns_mkdir(struct aa_ns *ns, struct dentry *parent, const char *name, |
118 | struct dentry *dent); | |
0d259f04 | 119 | |
5d5182ca JJ |
120 | struct aa_loaddata; |
121 | void __aa_fs_remove_rawdata(struct aa_loaddata *rawdata); | |
122 | int __aa_fs_create_rawdata(struct aa_ns *ns, struct aa_loaddata *rawdata); | |
123 | ||
63e2b423 | 124 | #endif /* __AA_APPARMORFS_H */ |