gen_lists.h

Go to the documentation of this file.
00001 /*************************************************** */
00002 /* Rule Set Based Access Control                     */
00003 /* Author and (c) 1999-2005: Amon Ott <ao@rsbac.org> */
00004 /* Generic lists - internal structures               */
00005 /* Last modified: 09/Feb/2005                        */
00006 /*************************************************** */
00007 
00008 #ifndef __RSBAC_GEN_LISTS_H
00009 #define __RSBAC_GEN_LISTS_H
00010 
00011 #include <linux/init.h>
00012 #include <rsbac/rkmem.h>
00013 #include <rsbac/lists.h>
00014 
00015 #define RSBAC_LIST_DISK_VERSION 10002
00016 #define RSBAC_LIST_DISK_OLD_VERSION 10001
00017 #define RSBAC_LIST_NONAME "(no name)"
00018 #define RSBAC_LIST_PROC_NAME "gen_lists"
00019 #define RSBAC_LIST_DEVICENAME "gen_list_device"
00020 #define RSBAC_LIST_FILENAME "genlst"
00021 
00022 #define RSBAC_GEN_LIST_DISK_VERSION 10001
00023 #define RSBAC_GEN_LIST_KEY 0x101face
00024 
00025 #define RSBAC_LIST_TA_KEY 0xface99
00026 
00027 /* Prototypes */
00028 
00029 /* Init */
00030 #ifdef CONFIG_RSBAC_INIT_DELAY
00031 int rsbac_list_init(void);
00032 #else
00033 int __init rsbac_list_init(void);
00034 #endif
00035 
00036 /* mount / umount */
00037 int rsbac_list_mount(kdev_t kdev);
00038 int rsbac_list_umount(kdev_t kdev);
00039 
00040 /* Status checking */
00041 int rsbac_check_lists(int correct);
00042 
00043 #if defined(CONFIG_RSBAC_AUTO_WRITE)
00044 int rsbac_write_lists(rsbac_boolean_t need_lock);
00045 #endif
00046 
00047 /* Data Structures */
00048 
00049 /* All items will be organized in double linked lists
00050  * However, we do not know the descriptor or item sizes, so we will access them
00051    with offsets later and only define the list links here.
00052  */
00053 
00054 struct rsbac_list_item_t
00055     {
00056       struct rsbac_list_item_t * prev;
00057       struct rsbac_list_item_t * next;
00058              rsbac_time_t        max_age;
00059     };
00060 
00061 /* lists of lists ds */
00062 struct rsbac_list_lol_item_t
00063     {
00064       struct rsbac_list_lol_item_t * prev;
00065       struct rsbac_list_lol_item_t * next;
00066       struct rsbac_list_item_t     * head;
00067       struct rsbac_list_item_t     * tail;
00068       struct rsbac_list_item_t     * curr;
00069              u_long                  count;
00070              rsbac_time_t            max_age;
00071     };
00072 
00073 /* Since all registrations will be organized in double linked lists, we must
00074  * have list items and a list head.
00075  * The pointer to this item will also be used as list handle. */
00076 
00077 typedef __u32 rsbac_list_count_t;
00078 
00079 struct rsbac_list_reg_item_t
00080     {
00081       struct rsbac_list_info_t             info;
00082              u_int                         flags;
00083              rsbac_list_compare_function_t * compare;
00084              rsbac_list_get_conv_t       * get_conv;
00085              void                        * def_data;
00086              char                          name[RSBAC_LIST_MAX_FILENAME+1];
00087              kdev_t                        device;
00088       struct rsbac_list_item_t           * head;
00089       struct rsbac_list_item_t           * tail;
00090       struct rsbac_list_item_t           * curr;
00091              rwlock_t                      lock;
00092              rsbac_list_count_t            count;
00093              rsbac_boolean_t               dirty;
00094              rsbac_boolean_t               no_write;
00095 #ifdef CONFIG_RSBAC_LIST_TRANS
00096              rsbac_ta_number_t             ta_copied;
00097       struct rsbac_list_item_t           * ta_head;
00098       struct rsbac_list_item_t           * ta_tail;
00099       struct rsbac_list_item_t           * ta_curr;
00100              rsbac_list_count_t            ta_count;
00101 #endif
00102 #if defined(CONFIG_RSBAC_PROC) && defined(CONFIG_PROC_FS)
00103       struct proc_dir_entry              * proc_entry_p;
00104 #endif
00105       struct rsbac_list_reg_item_t       * prev;
00106       struct rsbac_list_reg_item_t       * next;
00107       struct rsbac_list_reg_item_t       * self;
00108     };
00109 
00110 struct rsbac_list_lol_reg_item_t
00111     {
00112       struct rsbac_list_lol_info_t         info;
00113              u_int                         flags;
00114              rsbac_list_compare_function_t * compare;
00115              rsbac_list_compare_function_t * subcompare;
00116              rsbac_list_get_conv_t       * get_conv;
00117              rsbac_list_get_conv_t       * get_subconv;
00118              void                        * def_data;
00119              void                        * def_subdata;
00120              char                          name[RSBAC_LIST_MAX_FILENAME+1];
00121              kdev_t                        device;
00122       struct rsbac_list_lol_item_t       * head;
00123       struct rsbac_list_lol_item_t       * tail;
00124       struct rsbac_list_lol_item_t       * curr;
00125              rwlock_t                      lock;
00126              rsbac_list_count_t            count;
00127              rsbac_boolean_t               dirty;
00128              rsbac_boolean_t               no_write;
00129 #ifdef CONFIG_RSBAC_LIST_TRANS
00130              rsbac_ta_number_t             ta_copied;
00131       struct rsbac_list_lol_item_t       * ta_head;
00132       struct rsbac_list_lol_item_t       * ta_tail;
00133       struct rsbac_list_lol_item_t       * ta_curr;
00134              rsbac_list_count_t            ta_count;
00135 #endif
00136 #if defined(CONFIG_RSBAC_PROC) && defined(CONFIG_PROC_FS)
00137       struct proc_dir_entry              * proc_entry_p;
00138 #endif
00139       struct rsbac_list_lol_reg_item_t   * prev;
00140       struct rsbac_list_lol_reg_item_t   * next;
00141       struct rsbac_list_lol_reg_item_t   * self;
00142     };
00143 
00144 /* To provide consistency we use spinlocks for all list accesses. The
00145    'curr' entry is used to avoid repeated lookups for the same item. */
00146     
00147 struct rsbac_list_reg_head_t
00148     {
00149       struct rsbac_list_reg_item_t * head;
00150       struct rsbac_list_reg_item_t * tail;
00151       struct rsbac_list_reg_item_t * curr;
00152              rwlock_t                lock;
00153              u_int                   count;
00154     };
00155 
00156 struct rsbac_list_lol_reg_head_t
00157     {
00158       struct rsbac_list_lol_reg_item_t * head;
00159       struct rsbac_list_lol_reg_item_t * tail;
00160       struct rsbac_list_lol_reg_item_t * curr;
00161              rwlock_t                    lock;
00162              u_int                       count;
00163     };
00164 
00165 /* Internal helper list of filled write buffers */
00166 
00167 struct rsbac_list_write_item_t
00168     {
00169       struct rsbac_list_write_item_t * prev;
00170       struct rsbac_list_write_item_t * next;
00171       struct rsbac_list_reg_item_t   * list;
00172              u_long                    buflen;
00173              char                    * buf;
00174              rsbac_boolean_t           vmalloc_used;
00175              char                      name[RSBAC_LIST_MAX_FILENAME+1];
00176              kdev_t                    device;
00177     };
00178 
00179 struct rsbac_list_write_head_t
00180     {
00181       struct rsbac_list_write_item_t * head;
00182       struct rsbac_list_write_item_t * tail;
00183              u_long                    total;
00184              u_int                     count;
00185     };
00186 
00187 struct rsbac_list_lol_write_item_t
00188     {
00189       struct rsbac_list_lol_write_item_t * prev;
00190       struct rsbac_list_lol_write_item_t * next;
00191       struct rsbac_list_lol_reg_item_t   * list;
00192              u_long                        buflen;
00193              char                        * buf;
00194              rsbac_boolean_t               vmalloc_used;
00195              char                          name[RSBAC_LIST_MAX_FILENAME+1];
00196              kdev_t                        device;
00197     };
00198 
00199 struct rsbac_list_lol_write_head_t
00200     {
00201       struct rsbac_list_lol_write_item_t * head;
00202       struct rsbac_list_lol_write_item_t * tail;
00203              u_long                        total;
00204              u_int                         count;
00205     };
00206 
00207 
00208 /* Data structs for file timeout book keeping list filelist */
00209 struct rsbac_list_filelist_desc_t
00210   {
00211     char   filename[RSBAC_LIST_MAX_FILENAME+1];
00212   };
00213 
00214 struct rsbac_list_filelist_data_t
00215   {
00216     rsbac_time_t timestamp;
00217     rsbac_time_t max_age;
00218   };
00219 
00220 struct rsbac_list_ta_data_t
00221     {
00222       rsbac_time_t start;
00223       rsbac_time_t timeout;
00224       rsbac_uid_t  commit_uid;
00225       char         password[RSBAC_LIST_TA_MAX_PASSLEN];
00226     };
00227 
00228 #endif

Generated on Fri Jun 17 09:45:18 2005 for RSBAC by  doxygen 1.4.2