apparmorfs.h 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  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. #ifndef __AA_APPARMORFS_H
  15. #define __AA_APPARMORFS_H
  16. enum aa_fs_type {
  17. AA_FS_TYPE_BOOLEAN,
  18. AA_FS_TYPE_STRING,
  19. AA_FS_TYPE_U64,
  20. AA_FS_TYPE_FOPS,
  21. AA_FS_TYPE_DIR,
  22. };
  23. struct aa_fs_entry;
  24. struct aa_fs_entry {
  25. const char *name;
  26. struct dentry *dentry;
  27. umode_t mode;
  28. enum aa_fs_type v_type;
  29. union {
  30. bool boolean;
  31. char *string;
  32. unsigned long u64;
  33. struct aa_fs_entry *files;
  34. } v;
  35. const struct file_operations *file_ops;
  36. };
  37. extern const struct file_operations aa_fs_seq_file_ops;
  38. #define AA_FS_FILE_BOOLEAN(_name, _value) \
  39. { .name = (_name), .mode = 0444, \
  40. .v_type = AA_FS_TYPE_BOOLEAN, .v.boolean = (_value), \
  41. .file_ops = &aa_fs_seq_file_ops }
  42. #define AA_FS_FILE_STRING(_name, _value) \
  43. { .name = (_name), .mode = 0444, \
  44. .v_type = AA_FS_TYPE_STRING, .v.string = (_value), \
  45. .file_ops = &aa_fs_seq_file_ops }
  46. #define AA_FS_FILE_U64(_name, _value) \
  47. { .name = (_name), .mode = 0444, \
  48. .v_type = AA_FS_TYPE_U64, .v.u64 = (_value), \
  49. .file_ops = &aa_fs_seq_file_ops }
  50. #define AA_FS_FILE_FOPS(_name, _mode, _fops) \
  51. { .name = (_name), .v_type = AA_FS_TYPE_FOPS, \
  52. .mode = (_mode), .file_ops = (_fops) }
  53. #define AA_FS_DIR(_name, _value) \
  54. { .name = (_name), .v_type = AA_FS_TYPE_DIR, .v.files = (_value) }
  55. extern void __init aa_destroy_aafs(void);
  56. struct aa_profile;
  57. struct aa_namespace;
  58. enum aafs_ns_type {
  59. AAFS_NS_DIR,
  60. AAFS_NS_PROFS,
  61. AAFS_NS_NS,
  62. AAFS_NS_COUNT,
  63. AAFS_NS_MAX_COUNT,
  64. AAFS_NS_SIZE,
  65. AAFS_NS_MAX_SIZE,
  66. AAFS_NS_OWNER,
  67. AAFS_NS_SIZEOF,
  68. };
  69. enum aafs_prof_type {
  70. AAFS_PROF_DIR,
  71. AAFS_PROF_PROFS,
  72. AAFS_PROF_NAME,
  73. AAFS_PROF_MODE,
  74. AAFS_PROF_ATTACH,
  75. AAFS_PROF_HASH,
  76. AAFS_PROF_SIZEOF,
  77. };
  78. #define ns_dir(X) ((X)->dents[AAFS_NS_DIR])
  79. #define ns_subns_dir(X) ((X)->dents[AAFS_NS_NS])
  80. #define ns_subprofs_dir(X) ((X)->dents[AAFS_NS_PROFS])
  81. #define prof_dir(X) ((X)->dents[AAFS_PROF_DIR])
  82. #define prof_child_dir(X) ((X)->dents[AAFS_PROF_PROFS])
  83. void __aa_fs_profile_rmdir(struct aa_profile *profile);
  84. void __aa_fs_profile_migrate_dents(struct aa_profile *old,
  85. struct aa_profile *new);
  86. int __aa_fs_profile_mkdir(struct aa_profile *profile, struct dentry *parent);
  87. void __aa_fs_namespace_rmdir(struct aa_namespace *ns);
  88. int __aa_fs_namespace_mkdir(struct aa_namespace *ns, struct dentry *parent,
  89. const char *name);
  90. #endif /* __AA_APPARMORFS_H */