#include <linux/init.h>#include <rsbac/rkmem.h>#include <rsbac/lists.h>#include <rsbac/repl_lists.h>Go to the source code of this file.
Defines | |
| #define | RSBAC_LIST_DISK_VERSION 10003 |
| #define | RSBAC_LIST_DISK_OLD_VERSION 10002 |
| #define | RSBAC_LIST_NONAME "(no name)" |
| #define | RSBAC_LIST_PROC_NAME "gen_lists" |
| #define | RSBAC_LIST_TA_KEY 0xface99 |
Typedefs | |
| typedef __u32 | rsbac_list_count_t |
Functions | |
| int __init | rsbac_list_init (void) |
| int | rsbac_list_mount (kdev_t kdev) |
| int | rsbac_list_umount (kdev_t kdev) |
| int | rsbac_check_lists (int correct) |
|
|
Definition at line 17 of file gen_lists.h. Referenced by read_list(), and read_lol_list(). |
|
|
Definition at line 16 of file gen_lists.h. Referenced by fill_buffer(), fill_lol_buffer(), read_list(), and read_lol_list(). |
|
|
Definition at line 18 of file gen_lists.h. Referenced by create_lol_reg(), and create_reg(). |
|
|
Definition at line 19 of file gen_lists.h. Referenced by rsbac_list_init(). |
|
|
Definition at line 21 of file gen_lists.h. Referenced by rsbac_list_init(). |
|
|
Definition at line 73 of file gen_lists.h. |
|
|
Definition at line 5429 of file gen_lists.c. References rsbac_list_lol_reg_item_t::count, rsbac_list_lol_item_t::count, rsbac_list_reg_item_t::count, rsbac_list_lol_info_t::data_size, rsbac_list_info_t::data_size, rsbac_list_lol_reg_item_t::def_data, rsbac_list_reg_item_t::def_data, rsbac_list_lol_reg_item_t::def_subdata, rsbac_list_lol_info_t::desc_size, rsbac_list_info_t::desc_size, rsbac_list_lol_reg_item_t::device, rsbac_list_reg_item_t::device, rsbac_list_lol_reg_item_t::dirty, rsbac_list_reg_item_t::dirty, do_remove_item(), do_remove_lol_item(), do_remove_lol_subitem(), rsbac_list_lol_reg_item_t::flags, rsbac_list_reg_item_t::flags, rsbac_list_lol_reg_item_t::head, rsbac_list_lol_reg_head_t::head, rsbac_list_reg_item_t::head, rsbac_list_reg_head_t::head, rsbac_list_lol_reg_item_t::info, rsbac_list_reg_item_t::info, list_initialized, rsbac_list_lol_reg_item_t::lock, rsbac_list_lol_reg_head_t::lock, rsbac_list_reg_item_t::lock, rsbac_list_reg_head_t::lock, rsbac_list_lol_item_t::max_age, rsbac_list_item_t::max_age, rsbac_list_lol_reg_item_t::name, rsbac_list_reg_item_t::name, rsbac_list_lol_reg_item_t::next, rsbac_list_lol_item_t::next, rsbac_list_reg_item_t::next, rsbac_list_item_t::next, RSBAC_ENOTINITIALIZED, RSBAC_LIST_DEF_DATA, RSBAC_LIST_PERSIST, rsbac_printk(), rsbac_list_lol_info_t::subdata_size, and rsbac_list_lol_info_t::subdesc_size. Referenced by rsbac_do_init(), and sys_rsbac_check(). 05430 {
05431 struct rsbac_list_reg_item_t * list;
05432 struct rsbac_list_lol_reg_item_t * lol_list;
05433 struct rsbac_list_item_t * item_p;
05434 struct rsbac_list_item_t * next_item_p;
05435 struct rsbac_list_lol_item_t * lol_item_p;
05436 struct rsbac_list_lol_item_t * next_lol_item_p;
05437 struct rsbac_list_item_t * lol_subitem_p;
05438 struct rsbac_list_item_t * next_lol_subitem_p;
05439 u_long lock_flags, rlock_flags;
05440 u_long tmp_count;
05441 u_long tmp_subcount;
05442 u_long subitem_count;
05443 u_long dirty = 0;
05444
05445 #ifdef CONFIG_RSBAC_DEBUG
05446 if(rsbac_debug_lists)
05447 {
05448 rsbac_printk(KERN_DEBUG "rsbac_check_lists() called.\n");
05449 }
05450 #endif
05451 if(!list_initialized)
05452 return -RSBAC_ENOTINITIALIZED;
05453 rsbac_read_lock(®_head.lock, &rlock_flags);
05454 list = reg_head.head;
05455 while(list)
05456 {
05457 /* check list */
05458 rsbac_write_lock(&list->lock, &lock_flags);
05459 tmp_count = 0;
05460 item_p = list->head;
05461 while(item_p)
05462 {
05463 if( ( item_p->max_age
05464 && (item_p->max_age <= RSBAC_CURRENT_TIME)
05465 )
05466 || ( list->def_data
05467 && !memcmp(((char *) item_p) + sizeof(*item_p) + list->info.desc_size,
05468 list->def_data,
05469 list->info.data_size)
05470 )
05471 )
05472 {
05473 next_item_p = item_p->next;
05474 do_remove_item(list, item_p);
05475 item_p = next_item_p;
05476 }
05477 else
05478 {
05479 tmp_count++;
05480 item_p = item_p->next;
05481 }
05482 }
05483 if(tmp_count != list->count)
05484 {
05485 if(correct)
05486 {
05487 rsbac_printk(KERN_WARNING
05488 "rsbac_check_lists(): correcting count mismatch for list %s on device %02u:%02u - was %u, counted %lu!\n",
05489 list->name, RSBAC_MAJOR(list->device), RSBAC_MINOR(list->device), list->count, tmp_count);
05490 list->count = tmp_count;
05491 }
05492 else
05493 {
05494 rsbac_printk(KERN_WARNING
05495 "rsbac_check_lists(): count mismatch for list %s on device %02u:%02u - is %u, counted %lu!\n",
05496 list->name, RSBAC_MAJOR(list->device), RSBAC_MINOR(list->device), list->count, tmp_count);
05497 }
05498 }
05499 rsbac_write_unlock(&list->lock, &lock_flags);
05500 if(list->dirty && (list->flags & RSBAC_LIST_PERSIST))
05501 {
05502 dirty++;
05503 #ifdef CONFIG_RSBAC_DEBUG
05504 if(rsbac_debug_lists)
05505 {
05506 rsbac_printk(KERN_DEBUG
05507 "rsbac_check_lists(): %s on %02u:%02u has %u items (list is dirty)\n",
05508 list->name, RSBAC_MAJOR(list->device), RSBAC_MINOR(list->device), list->count);
05509 }
05510 #endif
05511 }
05512 #ifdef CONFIG_RSBAC_DEBUG
05513 else
05514 {
05515 if(rsbac_debug_lists)
05516 {
05517 rsbac_printk(KERN_DEBUG
05518 "rsbac_check_lists(): %s on %02u:%02u has %u items\n",
05519 list->name, RSBAC_MAJOR(list->device), RSBAC_MINOR(list->device), list->count);
05520 }
05521 }
05522 #endif
05523 list = list->next;
05524 }
05525 rsbac_read_unlock(®_head.lock, &rlock_flags);
05526
05527 rsbac_read_lock(&lol_reg_head.lock, &rlock_flags);
05528 lol_list = lol_reg_head.head;
05529 while(lol_list)
05530 {
05531 /* check list */
05532 rsbac_write_lock(&lol_list->lock, &lock_flags);
05533 tmp_count = 0;
05534 subitem_count = 0;
05535 lol_item_p = lol_list->head;
05536 while(lol_item_p)
05537 {
05538 if( ( lol_item_p->max_age
05539 && (lol_item_p->max_age <= RSBAC_CURRENT_TIME)
05540 )
05541 || ( lol_list->def_data
05542 && !lol_item_p->count
05543 && !memcmp(((char *) lol_item_p) + sizeof(*lol_item_p) + lol_list->info.desc_size,
05544 lol_list->def_data,
05545 lol_list->info.data_size)
05546 )
05547 || ( !lol_list->info.data_size
05548 && (lol_list->flags & RSBAC_LIST_DEF_DATA)
05549 && !lol_item_p->count
05550 )
05551 )
05552 {
05553 next_lol_item_p = lol_item_p->next;
05554 do_remove_lol_item(lol_list, lol_item_p);
05555 lol_item_p = next_lol_item_p;
05556 }
05557 else
05558 {
05559 tmp_count++;
05560 tmp_subcount = 0;
05561 lol_subitem_p = lol_item_p->head;
05562 while(lol_subitem_p)
05563 {
05564 if( ( lol_subitem_p->max_age
05565 && (lol_subitem_p->max_age <= RSBAC_CURRENT_TIME)
05566 )
05567 || ( lol_list->def_subdata
05568 && !memcmp(((char *) lol_subitem_p) + sizeof(*lol_subitem_p) + lol_list->info.subdesc_size,
05569 lol_list->def_subdata,
05570 lol_list->info.subdata_size)
05571 )
05572 )
05573 {
05574 next_lol_subitem_p = lol_subitem_p->next;
05575 do_remove_lol_subitem(lol_item_p, lol_subitem_p);
05576 lol_subitem_p = next_lol_subitem_p;
05577 }
05578 else
05579 {
05580 tmp_subcount++;
05581 lol_subitem_p = lol_subitem_p->next;
05582 }
05583 }
05584 if(tmp_subcount != lol_item_p->count)
05585 {
05586 if(correct)
05587 {
05588 rsbac_printk(KERN_WARNING
05589 "rsbac_check_lists(): correcting count mismatch for list of lists %s sublist on %02u:%02u - was %lu, counted %lu!\n",
05590 lol_list->name, RSBAC_MAJOR(lol_list->device), RSBAC_MINOR(lol_list->device), lol_item_p->count, tmp_subcount);
05591 lol_item_p->count = tmp_subcount;
05592 }
05593 else
05594 {
05595 rsbac_printk(KERN_WARNING
05596 "rsbac_check_lists(): count mismatch for list of lists %s sublist on %02u:%02u - is %lu, counted %lu!\n",
05597 lol_list->name, RSBAC_MAJOR(lol_list->device), RSBAC_MINOR(lol_list->device), lol_item_p->count, tmp_subcount);
05598 }
05599 }
05600 subitem_count += lol_item_p->count;
05601 lol_item_p = lol_item_p->next;
05602 }
05603 }
05604 if(tmp_count != lol_list->count)
05605 {
05606 if(correct)
05607 {
05608 rsbac_printk(KERN_WARNING
05609 "rsbac_check_lists(): correcting count mismatch for list of lists %s on %02u:%02u - was %u, counted %lu!\n",
05610 lol_list->name, RSBAC_MAJOR(lol_list->device), RSBAC_MINOR(lol_list->device), lol_list->count, tmp_count);
05611 lol_list->count = tmp_count;
05612 }
05613 else
05614 {
05615 rsbac_printk(KERN_WARNING
05616 "rsbac_check_lists(): count mismatch for list of lists %s on %02u:%02u - is %u, counted %lu!\n",
05617 lol_list->name, RSBAC_MAJOR(lol_list->device), RSBAC_MINOR(lol_list->device), lol_list->count, tmp_count);
05618 }
05619 }
05620 rsbac_write_unlock(&lol_list->lock, &lock_flags);
05621 if(lol_list->dirty && (lol_list->flags & RSBAC_LIST_PERSIST))
05622 {
05623 dirty++;
05624 #ifdef CONFIG_RSBAC_DEBUG
05625 if(rsbac_debug_lists)
05626 {
05627 rsbac_printk(KERN_DEBUG
05628 "rsbac_check_lists(): %s on %02u:%02u has %u items and %lu subitems (list is dirty)\n",
05629 lol_list->name, RSBAC_MAJOR(lol_list->device), RSBAC_MINOR(lol_list->device), lol_list->count, subitem_count);
05630 }
05631 #endif
05632 }
05633 #ifdef CONFIG_RSBAC_DEBUG
05634 else
05635 {
05636 if(rsbac_debug_lists)
05637 {
05638 rsbac_printk(KERN_DEBUG
05639 "rsbac_check_lists(): %s on %02u:%02u has %u items and %lu subitems\n",
05640 lol_list->name, RSBAC_MAJOR(lol_list->device), RSBAC_MINOR(lol_list->device), lol_list->count, subitem_count);
05641 }
05642 }
05643 #endif
05644 lol_list = lol_list->next;
05645 }
05646 rsbac_read_unlock(&lol_reg_head.lock, &rlock_flags);
05647 return 0;
05648 }
|
|
|
Definition at line 5065 of file gen_lists.c. References rsbac_list_lol_reg_head_t::count, rsbac_list_reg_head_t::count, rsbac_list_lol_reg_head_t::curr, rsbac_list_reg_head_t::curr, get_error_name(), rsbac_list_lol_reg_head_t::head, rsbac_list_reg_head_t::head, list_initialized, rsbac_list_lol_reg_head_t::lock, rsbac_list_reg_head_t::lock, rsbac_nanotime_t::nsec, NULL, proc_rsbac_root_p, rsbac_list_compare_u32(), RSBAC_LIST_PERSIST, RSBAC_LIST_PROC_NAME, rsbac_list_register(), RSBAC_LIST_REPL_PARTNER_FILENAME, RSBAC_LIST_REPL_PARTNER_KEY, RSBAC_LIST_REPL_PARTNER_VERSION, RSBAC_LIST_REPL_PROC_NAME, RSBAC_LIST_TA_KEY, RSBAC_LIST_VERSION, RSBAC_MAXNAMELEN, rsbac_printk(), rsbac_nanotime_t::sec, rsbac_list_lol_reg_head_t::tail, rsbac_list_reg_head_t::tail, and TRUE. Referenced by rsbac_do_init(). 05067 {
05068 #ifdef CONFIG_RSBAC_LIST_TRANS
05069 int err;
05070 struct rsbac_list_info_t * list_info_p;
05071 #endif
05072
05073 reg_head.head = NULL;
05074 reg_head.tail = NULL;
05075 reg_head.curr = NULL;
05076 reg_head.lock = RW_LOCK_UNLOCKED;
05077 reg_head.count = 0;
05078
05079 lol_reg_head.head = NULL;
05080 lol_reg_head.tail = NULL;
05081 lol_reg_head.curr = NULL;
05082 lol_reg_head.lock = RW_LOCK_UNLOCKED;
05083 lol_reg_head.count = 0;
05084
05085 list_initialized = TRUE;
05086
05087 #ifdef CONFIG_RSBAC_LIST_REPL
05088 repl_last.sec = 0;
05089 repl_last.nsec = 0;
05090 #endif
05091
05092 /* init proc entry */
05093 #if defined(CONFIG_RSBAC_PROC) && defined(CONFIG_PROC_FS)
05094 {
05095 struct proc_dir_entry * tmp_entry_p;
05096
05097 tmp_entry_p = create_proc_entry(RSBAC_LIST_PROC_NAME,
05098 S_IFREG | S_IRUGO,
05099 proc_rsbac_root_p);
05100 if(tmp_entry_p)
05101 {
05102 tmp_entry_p->get_info = lists_proc_info;
05103 }
05104 #if defined(CONFIG_RSBAC_LIST_REPL)
05105 tmp_entry_p = create_proc_entry(RSBAC_LIST_REPL_PROC_NAME,
05106 S_IFREG | S_IRUGO,
05107 proc_rsbac_root_p);
05108 if(tmp_entry_p)
05109 {
05110 tmp_entry_p->get_info = repl_lists_proc_info;
05111 }
05112 #endif
05113 }
05114 #endif
05115
05116 #ifdef CONFIG_RSBAC_LIST_TRANS
05117 rsbac_printk(KERN_INFO
05118 "rsbac_list_init(): Registering transaction list.\n");
05119 list_info_p = kmalloc(sizeof(*list_info_p), GFP_KERNEL);
05120 if(!list_info_p)
05121 {
05122 return -ENOMEM;
05123 }
05124 list_info_p->version = 1;
05125 list_info_p->key = RSBAC_LIST_TA_KEY;
05126 list_info_p->desc_size = sizeof(rsbac_list_ta_number_t);
05127 list_info_p->data_size = sizeof(struct rsbac_list_ta_data_t);
05128 list_info_p->max_age = 0;
05129 err = rsbac_list_register(RSBAC_LIST_VERSION,
05130 (void **) &ta_handle,
05131 list_info_p,
05132 0,
05133 rsbac_list_compare_u32,
05134 NULL,
05135 NULL,
05136 "transactions",
05137 RSBAC_AUTO_DEV);
05138 if(err)
05139 {
05140 char * tmp = kmalloc(RSBAC_MAXNAMELEN, GFP_KERNEL);
05141
05142 if(tmp)
05143 {
05144 rsbac_printk(KERN_WARNING
05145 "rsbac_list_init(): Registering transaction list failed with error %s\n",
05146 get_error_name(tmp, err));
05147 kfree(tmp);
05148 }
05149 }
05150 kfree(list_info_p);
05151 #endif
05152
05153 #ifdef CONFIG_RSBAC_LIST_REPL
05154 rsbac_printk(KERN_INFO
05155 "rsbac_list_init(): Registering replication partner list.\n");
05156 list_info_p = kmalloc(sizeof(*list_info_p), GFP_KERNEL);
05157 if(!list_info_p)
05158 {
05159 return -ENOMEM;
05160 }
05161 list_info_p->version = RSBAC_LIST_REPL_PARTNER_VERSION;
05162 list_info_p->key = RSBAC_LIST_REPL_PARTNER_KEY;
05163 list_info_p->desc_size = sizeof(rsbac_list_repl_partner_number_t);
05164 list_info_p->data_size = sizeof(struct rsbac_list_repl_partner_entry_t);
05165 list_info_p->max_age = 0;
05166 err = rsbac_list_register(RSBAC_LIST_VERSION,
05167 (void **) &repl_partner_handle,
05168 list_info_p,
05169 RSBAC_LIST_PERSIST,
05170 NULL,
05171 NULL,
05172 NULL,
05173 RSBAC_LIST_REPL_PARTNER_FILENAME,
05174 RSBAC_AUTO_DEV);
05175 if(err)
05176 {
05177 char * tmp = kmalloc(RSBAC_MAXNAMELEN, GFP_KERNEL);
05178
05179 if(tmp)
05180 {
05181 rsbac_printk(KERN_WARNING
05182 "rsbac_list_init(): Registering replication partner list failed with error %s\n",
05183 get_error_name(tmp, err));
05184 kfree(tmp);
05185 }
05186 }
05187 kfree(list_info_p);
05188 #endif
05189
05190 return 0;
05191 }
|
|
|
Definition at line 5193 of file gen_lists.c. Referenced by rsbac_mount(). 05194 {
05195 return 0;
05196 }
|
|
|
Definition at line 5198 of file gen_lists.c. Referenced by rsbac_umount(). 05199 {
05200 return 0;
05201 }
|
1.4.2