John Johansen | 63e2b42 | 2010-07-29 14:48:03 -0700 | [diff] [blame] | 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 | |
Kees Cook | 9acd494 | 2012-01-26 16:29:20 -0800 | [diff] [blame] | 18 | enum aa_fs_type { |
Kees Cook | e74abcf | 2012-01-26 16:29:21 -0800 | [diff] [blame] | 19 | AA_FS_TYPE_BOOLEAN, |
Kees Cook | a9bf8e9 | 2012-01-26 16:29:22 -0800 | [diff] [blame] | 20 | AA_FS_TYPE_STRING, |
Kees Cook | e74abcf | 2012-01-26 16:29:21 -0800 | [diff] [blame] | 21 | AA_FS_TYPE_U64, |
Kees Cook | 9acd494 | 2012-01-26 16:29:20 -0800 | [diff] [blame] | 22 | AA_FS_TYPE_FOPS, |
| 23 | AA_FS_TYPE_DIR, |
| 24 | }; |
| 25 | |
| 26 | struct aa_fs_entry; |
| 27 | |
| 28 | struct aa_fs_entry { |
| 29 | const char *name; |
| 30 | struct dentry *dentry; |
| 31 | umode_t mode; |
| 32 | enum aa_fs_type v_type; |
| 33 | union { |
Kees Cook | e74abcf | 2012-01-26 16:29:21 -0800 | [diff] [blame] | 34 | bool boolean; |
Kees Cook | a9bf8e9 | 2012-01-26 16:29:22 -0800 | [diff] [blame] | 35 | char *string; |
Kees Cook | e74abcf | 2012-01-26 16:29:21 -0800 | [diff] [blame] | 36 | unsigned long u64; |
Kees Cook | 9acd494 | 2012-01-26 16:29:20 -0800 | [diff] [blame] | 37 | struct aa_fs_entry *files; |
| 38 | } v; |
| 39 | const struct file_operations *file_ops; |
| 40 | }; |
| 41 | |
Kees Cook | e74abcf | 2012-01-26 16:29:21 -0800 | [diff] [blame] | 42 | extern const struct file_operations aa_fs_seq_file_ops; |
| 43 | |
| 44 | #define AA_FS_FILE_BOOLEAN(_name, _value) \ |
| 45 | { .name = (_name), .mode = 0444, \ |
| 46 | .v_type = AA_FS_TYPE_BOOLEAN, .v.boolean = (_value), \ |
| 47 | .file_ops = &aa_fs_seq_file_ops } |
Kees Cook | a9bf8e9 | 2012-01-26 16:29:22 -0800 | [diff] [blame] | 48 | #define AA_FS_FILE_STRING(_name, _value) \ |
| 49 | { .name = (_name), .mode = 0444, \ |
| 50 | .v_type = AA_FS_TYPE_STRING, .v.string = (_value), \ |
| 51 | .file_ops = &aa_fs_seq_file_ops } |
Kees Cook | e74abcf | 2012-01-26 16:29:21 -0800 | [diff] [blame] | 52 | #define AA_FS_FILE_U64(_name, _value) \ |
| 53 | { .name = (_name), .mode = 0444, \ |
| 54 | .v_type = AA_FS_TYPE_U64, .v.u64 = (_value), \ |
| 55 | .file_ops = &aa_fs_seq_file_ops } |
Kees Cook | 9acd494 | 2012-01-26 16:29:20 -0800 | [diff] [blame] | 56 | #define AA_FS_FILE_FOPS(_name, _mode, _fops) \ |
| 57 | { .name = (_name), .v_type = AA_FS_TYPE_FOPS, \ |
| 58 | .mode = (_mode), .file_ops = (_fops) } |
| 59 | #define AA_FS_DIR(_name, _value) \ |
| 60 | { .name = (_name), .v_type = AA_FS_TYPE_DIR, .v.files = (_value) } |
| 61 | |
John Johansen | 63e2b42 | 2010-07-29 14:48:03 -0700 | [diff] [blame] | 62 | extern void __init aa_destroy_aafs(void); |
| 63 | |
John Johansen | 0d259f0 | 2013-07-10 21:13:43 -0700 | [diff] [blame] | 64 | struct aa_profile; |
| 65 | struct aa_namespace; |
| 66 | |
| 67 | enum aafs_ns_type { |
| 68 | AAFS_NS_DIR, |
| 69 | AAFS_NS_PROFS, |
| 70 | AAFS_NS_NS, |
| 71 | AAFS_NS_COUNT, |
| 72 | AAFS_NS_MAX_COUNT, |
| 73 | AAFS_NS_SIZE, |
| 74 | AAFS_NS_MAX_SIZE, |
| 75 | AAFS_NS_OWNER, |
| 76 | AAFS_NS_SIZEOF, |
| 77 | }; |
| 78 | |
| 79 | enum aafs_prof_type { |
| 80 | AAFS_PROF_DIR, |
| 81 | AAFS_PROF_PROFS, |
| 82 | AAFS_PROF_NAME, |
| 83 | AAFS_PROF_MODE, |
John Johansen | 556d0be | 2013-07-10 21:17:43 -0700 | [diff] [blame] | 84 | AAFS_PROF_ATTACH, |
John Johansen | f8eb8a1 | 2013-08-14 11:27:36 -0700 | [diff] [blame] | 85 | AAFS_PROF_HASH, |
John Johansen | 0d259f0 | 2013-07-10 21:13:43 -0700 | [diff] [blame] | 86 | AAFS_PROF_SIZEOF, |
| 87 | }; |
| 88 | |
| 89 | #define ns_dir(X) ((X)->dents[AAFS_NS_DIR]) |
| 90 | #define ns_subns_dir(X) ((X)->dents[AAFS_NS_NS]) |
| 91 | #define ns_subprofs_dir(X) ((X)->dents[AAFS_NS_PROFS]) |
| 92 | |
| 93 | #define prof_dir(X) ((X)->dents[AAFS_PROF_DIR]) |
| 94 | #define prof_child_dir(X) ((X)->dents[AAFS_PROF_PROFS]) |
| 95 | |
| 96 | void __aa_fs_profile_rmdir(struct aa_profile *profile); |
| 97 | void __aa_fs_profile_migrate_dents(struct aa_profile *old, |
| 98 | struct aa_profile *new); |
| 99 | int __aa_fs_profile_mkdir(struct aa_profile *profile, struct dentry *parent); |
| 100 | void __aa_fs_namespace_rmdir(struct aa_namespace *ns); |
| 101 | int __aa_fs_namespace_mkdir(struct aa_namespace *ns, struct dentry *parent, |
| 102 | const char *name); |
| 103 | |
John Johansen | 63e2b42 | 2010-07-29 14:48:03 -0700 | [diff] [blame] | 104 | #endif /* __AA_APPARMORFS_H */ |