TOMOYO: Use array of "struct list_head".
[pandora-kernel.git] / security / tomoyo / common.h
index f4da7a8..451dc3c 100644 (file)
@@ -46,6 +46,30 @@ enum tomoyo_mode_index {
        TOMOYO_CONFIG_USE_DEFAULT = 255
 };
 
+enum tomoyo_policy_id {
+       TOMOYO_ID_GROUP,
+       TOMOYO_ID_PATH_GROUP,
+       TOMOYO_ID_NUMBER_GROUP,
+       TOMOYO_ID_DOMAIN_INITIALIZER,
+       TOMOYO_ID_DOMAIN_KEEPER,
+       TOMOYO_ID_AGGREGATOR,
+       TOMOYO_ID_ALIAS,
+       TOMOYO_ID_GLOBALLY_READABLE,
+       TOMOYO_ID_PATTERN,
+       TOMOYO_ID_NO_REWRITE,
+       TOMOYO_ID_MANAGER,
+       TOMOYO_ID_NAME,
+       TOMOYO_ID_ACL,
+       TOMOYO_ID_DOMAIN,
+       TOMOYO_MAX_POLICY
+};
+
+enum tomoyo_group_id {
+       TOMOYO_PATH_GROUP,
+       TOMOYO_NUMBER_GROUP,
+       TOMOYO_MAX_GROUP
+};
+
 /* Keywords for ACLs. */
 #define TOMOYO_KEYWORD_AGGREGATOR                "aggregator "
 #define TOMOYO_KEYWORD_ALIAS                     "alias "
@@ -291,28 +315,20 @@ struct tomoyo_name_entry {
 
 struct tomoyo_name_union {
        const struct tomoyo_path_info *filename;
-       struct tomoyo_path_group *group;
+       struct tomoyo_group *group;
        u8 is_group;
 };
 
 struct tomoyo_number_union {
        unsigned long values[2];
-       struct tomoyo_number_group *group;
+       struct tomoyo_group *group;
        u8 min_type;
        u8 max_type;
        u8 is_group;
 };
 
-/* Structure for "path_group" directive. */
-struct tomoyo_path_group {
-       struct list_head list;
-       const struct tomoyo_path_info *group_name;
-       struct list_head member_list;
-       atomic_t users;
-};
-
-/* Structure for "number_group" directive. */
-struct tomoyo_number_group {
+/* Structure for "path_group"/"number_group" directive. */
+struct tomoyo_group {
        struct list_head list;
        const struct tomoyo_path_info *group_name;
        struct list_head member_list;
@@ -320,13 +336,13 @@ struct tomoyo_number_group {
 };
 
 /* Structure for "path_group" directive. */
-struct tomoyo_path_group_member {
+struct tomoyo_path_group {
        struct tomoyo_acl_head head;
        const struct tomoyo_path_info *member_name;
 };
 
 /* Structure for "number_group" directive. */
-struct tomoyo_number_group_member {
+struct tomoyo_number_group {
        struct tomoyo_acl_head head;
        struct tomoyo_number_union number;
 };
@@ -526,7 +542,7 @@ struct tomoyo_mount_acl {
  * is appended.
  */
 struct tomoyo_io_buffer {
-       int (*read) (struct tomoyo_io_buffer *);
+       void (*read) (struct tomoyo_io_buffer *);
        int (*write) (struct tomoyo_io_buffer *);
        int (*poll) (struct file *file, poll_table *wait);
        /* Exclusive lock for this structure.   */
@@ -578,7 +594,7 @@ struct tomoyo_globally_readable_file_entry {
 
 /*
  * tomoyo_pattern_entry is a structure which is used for holding
- * "tomoyo_pattern_list" entries.
+ * "file_pattern" entries.
  * It has following fields.
  *
  *  (1) "head" is "struct tomoyo_acl_head".
@@ -766,11 +782,11 @@ bool tomoyo_parse_name_union(const char *filename,
                             struct tomoyo_name_union *ptr);
 /* Check whether the given filename matches the given path_group. */
 bool tomoyo_path_matches_group(const struct tomoyo_path_info *pathname,
-                              const struct tomoyo_path_group *group);
+                              const struct tomoyo_group *group);
 /* Check whether the given value matches the given number_group. */
 bool tomoyo_number_matches_group(const unsigned long min,
                                 const unsigned long max,
-                                const struct tomoyo_number_group *group);
+                                const struct tomoyo_group *group);
 /* Check whether the given filename matches the given pattern. */
 bool tomoyo_path_matches_pattern(const struct tomoyo_path_info *filename,
                                 const struct tomoyo_path_info *pattern);
@@ -858,8 +874,8 @@ struct tomoyo_domain_info *tomoyo_find_or_assign_new_domain(const char *
                                                            const u8 profile);
 struct tomoyo_profile *tomoyo_profile(const u8 profile);
 /* Allocate memory for "struct tomoyo_path_group". */
-struct tomoyo_path_group *tomoyo_get_path_group(const char *group_name);
-struct tomoyo_number_group *tomoyo_get_number_group(const char *group_name);
+struct tomoyo_group *tomoyo_get_path_group(const char *group_name);
+struct tomoyo_group *tomoyo_get_number_group(const char *group_name);
 
 /* Check mode for specified functionality. */
 unsigned int tomoyo_check_flags(const struct tomoyo_domain_info *domain,
@@ -900,7 +916,7 @@ void *tomoyo_commit_ok(void *data, const unsigned int size);
 const struct tomoyo_path_info *tomoyo_get_name(const char *name);
 
 /* Check for memory usage. */
-int tomoyo_read_memory_counter(struct tomoyo_io_buffer *head);
+void tomoyo_read_memory_counter(struct tomoyo_io_buffer *head);
 
 /* Set memory quota. */
 int tomoyo_write_memory_quota(struct tomoyo_io_buffer *head);
@@ -958,16 +974,8 @@ extern struct srcu_struct tomoyo_ss;
 /* The list for "struct tomoyo_domain_info". */
 extern struct list_head tomoyo_domain_list;
 
-extern struct list_head tomoyo_path_group_list;
-extern struct list_head tomoyo_number_group_list;
-extern struct list_head tomoyo_domain_initializer_list;
-extern struct list_head tomoyo_domain_keeper_list;
-extern struct list_head tomoyo_aggregator_list;
-extern struct list_head tomoyo_alias_list;
-extern struct list_head tomoyo_globally_readable_list;
-extern struct list_head tomoyo_pattern_list;
-extern struct list_head tomoyo_no_rewrite_list;
-extern struct list_head tomoyo_policy_manager_list;
+extern struct list_head tomoyo_policy_list[TOMOYO_MAX_POLICY];
+extern struct list_head tomoyo_group_list[TOMOYO_MAX_GROUP];
 extern struct list_head tomoyo_name_list[TOMOYO_MAX_HASH];
 
 /* Lock for protecting policy. */
@@ -1039,13 +1047,7 @@ static inline void tomoyo_put_name(const struct tomoyo_path_info *name)
        }
 }
 
-static inline void tomoyo_put_path_group(struct tomoyo_path_group *group)
-{
-       if (group)
-               atomic_dec(&group->users);
-}
-
-static inline void tomoyo_put_number_group(struct tomoyo_number_group *group)
+static inline void tomoyo_put_group(struct tomoyo_group *group)
 {
        if (group)
                atomic_dec(&group->users);