]> bbs.cooldavid.org Git - net-next-2.6.git/blobdiff - security/tomoyo/realpath.h
TOMOYO: Add refcounter on string data.
[net-next-2.6.git] / security / tomoyo / realpath.h
index da4f06ff6f8da8f8171b8bed855d71de75214fe0..b94cb512adb57c988d82ff670fe2965eb552d96a 100644 (file)
@@ -43,7 +43,7 @@ bool tomoyo_memory_ok(void *ptr);
  * Keep the given name on the RAM.
  * The RAM is shared, so NEVER try to modify or kfree() the returned name.
  */
-const struct tomoyo_path_info *tomoyo_save_name(const char *name);
+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);
@@ -54,4 +54,23 @@ int tomoyo_write_memory_quota(struct tomoyo_io_buffer *head);
 /* Initialize realpath related code. */
 void __init tomoyo_realpath_init(void);
 
+/*
+ * tomoyo_name_entry is a structure which is used for linking
+ * "struct tomoyo_path_info" into tomoyo_name_list .
+ */
+struct tomoyo_name_entry {
+       struct list_head list;
+       atomic_t users;
+       struct tomoyo_path_info entry;
+};
+
+static inline void tomoyo_put_name(const struct tomoyo_path_info *name)
+{
+       if (name) {
+               struct tomoyo_name_entry *ptr =
+                       container_of(name, struct tomoyo_name_entry, entry);
+               atomic_dec(&ptr->users);
+       }
+}
+
 #endif /* !defined(_SECURITY_TOMOYO_REALPATH_H) */