#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 5427 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(). 05428 { 05429 struct rsbac_list_reg_item_t * list; 05430 struct rsbac_list_lol_reg_item_t * lol_list; 05431 struct rsbac_list_item_t * item_p; 05432 struct rsbac_list_item_t * next_item_p; 05433 struct rsbac_list_lol_item_t * lol_item_p; 05434 struct rsbac_list_lol_item_t * next_lol_item_p; 05435 struct rsbac_list_item_t * lol_subitem_p; 05436 struct rsbac_list_item_t * next_lol_subitem_p; 05437 u_long lock_flags, rlock_flags; 05438 u_long tmp_count; 05439 u_long tmp_subcount; 05440 u_long subitem_count; 05441 u_long dirty = 0; 05442 05443 #ifdef CONFIG_RSBAC_DEBUG 05444 if(rsbac_debug_lists) 05445 { 05446 rsbac_printk(KERN_DEBUG "rsbac_check_lists() called.\n"); 05447 } 05448 #endif 05449 if(!list_initialized) 05450 return -RSBAC_ENOTINITIALIZED; 05451 rsbac_read_lock(®_head.lock, &rlock_flags); 05452 list = reg_head.head; 05453 while(list) 05454 { 05455 /* check list */ 05456 rsbac_write_lock(&list->lock, &lock_flags); 05457 tmp_count = 0; 05458 item_p = list->head; 05459 while(item_p) 05460 { 05461 if( ( item_p->max_age 05462 && (item_p->max_age <= RSBAC_CURRENT_TIME) 05463 ) 05464 || ( list->def_data 05465 && !memcmp(((char *) item_p) + sizeof(*item_p) + list->info.desc_size, 05466 list->def_data, 05467 list->info.data_size) 05468 ) 05469 ) 05470 { 05471 next_item_p = item_p->next; 05472 do_remove_item(list, item_p); 05473 item_p = next_item_p; 05474 } 05475 else 05476 { 05477 tmp_count++; 05478 item_p = item_p->next; 05479 } 05480 } 05481 if(tmp_count != list->count) 05482 { 05483 if(correct) 05484 { 05485 rsbac_printk(KERN_WARNING 05486 "rsbac_check_lists(): correcting count mismatch for list %s on device %02u:%02u - was %u, counted %lu!\n", 05487 list->name, RSBAC_MAJOR(list->device), RSBAC_MINOR(list->device), list->count, tmp_count); 05488 list->count = tmp_count; 05489 } 05490 else 05491 { 05492 rsbac_printk(KERN_WARNING 05493 "rsbac_check_lists(): count mismatch for list %s on device %02u:%02u - is %u, counted %lu!\n", 05494 list->name, RSBAC_MAJOR(list->device), RSBAC_MINOR(list->device), list->count, tmp_count); 05495 } 05496 } 05497 rsbac_write_unlock(&list->lock, &lock_flags); 05498 if(list->dirty && (list->flags & RSBAC_LIST_PERSIST)) 05499 { 05500 dirty++; 05501 #ifdef CONFIG_RSBAC_DEBUG 05502 if(rsbac_debug_lists) 05503 { 05504 rsbac_printk(KERN_DEBUG 05505 "rsbac_check_lists(): %s on %02u:%02u has %u items (list is dirty)\n", 05506 list->name, RSBAC_MAJOR(list->device), RSBAC_MINOR(list->device), list->count); 05507 } 05508 #endif 05509 } 05510 #ifdef CONFIG_RSBAC_DEBUG 05511 else 05512 { 05513 if(rsbac_debug_lists) 05514 { 05515 rsbac_printk(KERN_DEBUG 05516 "rsbac_check_lists(): %s on %02u:%02u has %u items\n", 05517 list->name, RSBAC_MAJOR(list->device), RSBAC_MINOR(list->device), list->count); 05518 } 05519 } 05520 #endif 05521 list = list->next; 05522 } 05523 rsbac_read_unlock(®_head.lock, &rlock_flags); 05524 05525 rsbac_read_lock(&lol_reg_head.lock, &rlock_flags); 05526 lol_list = lol_reg_head.head; 05527 while(lol_list) 05528 { 05529 /* check list */ 05530 rsbac_write_lock(&lol_list->lock, &lock_flags); 05531 tmp_count = 0; 05532 subitem_count = 0; 05533 lol_item_p = lol_list->head; 05534 while(lol_item_p) 05535 { 05536 if( ( lol_item_p->max_age 05537 && (lol_item_p->max_age <= RSBAC_CURRENT_TIME) 05538 ) 05539 || ( lol_list->def_data 05540 && !lol_item_p->count 05541 && !memcmp(((char *) lol_item_p) + sizeof(*lol_item_p) + lol_list->info.desc_size, 05542 lol_list->def_data, 05543 lol_list->info.data_size) 05544 ) 05545 || ( !lol_list->info.data_size 05546 && (lol_list->flags & RSBAC_LIST_DEF_DATA) 05547 && !lol_item_p->count 05548 ) 05549 ) 05550 { 05551 next_lol_item_p = lol_item_p->next; 05552 do_remove_lol_item(lol_list, lol_item_p); 05553 lol_item_p = next_lol_item_p; 05554 } 05555 else 05556 { 05557 tmp_count++; 05558 tmp_subcount = 0; 05559 lol_subitem_p = lol_item_p->head; 05560 while(lol_subitem_p) 05561 { 05562 if( ( lol_subitem_p->max_age 05563 && (lol_subitem_p->max_age <= RSBAC_CURRENT_TIME) 05564 ) 05565 || ( lol_list->def_subdata 05566 && !memcmp(((char *) lol_subitem_p) + sizeof(*lol_subitem_p) + lol_list->info.subdesc_size, 05567 lol_list->def_subdata, 05568 lol_list->info.subdata_size) 05569 ) 05570 ) 05571 { 05572 next_lol_subitem_p = lol_subitem_p->next; 05573 do_remove_lol_subitem(lol_item_p, lol_subitem_p); 05574 lol_subitem_p = next_lol_subitem_p; 05575 } 05576 else 05577 { 05578 tmp_subcount++; 05579 lol_subitem_p = lol_subitem_p->next; 05580 } 05581 } 05582 if(tmp_subcount != lol_item_p->count) 05583 { 05584 if(correct) 05585 { 05586 rsbac_printk(KERN_WARNING 05587 "rsbac_check_lists(): correcting count mismatch for list of lists %s sublist on %02u:%02u - was %lu, counted %lu!\n", 05588 lol_list->name, RSBAC_MAJOR(lol_list->device), RSBAC_MINOR(lol_list->device), lol_item_p->count, tmp_subcount); 05589 lol_item_p->count = tmp_subcount; 05590 } 05591 else 05592 { 05593 rsbac_printk(KERN_WARNING 05594 "rsbac_check_lists(): count mismatch for list of lists %s sublist on %02u:%02u - is %lu, counted %lu!\n", 05595 lol_list->name, RSBAC_MAJOR(lol_list->device), RSBAC_MINOR(lol_list->device), lol_item_p->count, tmp_subcount); 05596 } 05597 } 05598 subitem_count += lol_item_p->count; 05599 lol_item_p = lol_item_p->next; 05600 } 05601 } 05602 if(tmp_count != lol_list->count) 05603 { 05604 if(correct) 05605 { 05606 rsbac_printk(KERN_WARNING 05607 "rsbac_check_lists(): correcting count mismatch for list of lists %s on %02u:%02u - was %u, counted %lu!\n", 05608 lol_list->name, RSBAC_MAJOR(lol_list->device), RSBAC_MINOR(lol_list->device), lol_list->count, tmp_count); 05609 lol_list->count = tmp_count; 05610 } 05611 else 05612 { 05613 rsbac_printk(KERN_WARNING 05614 "rsbac_check_lists(): count mismatch for list of lists %s on %02u:%02u - is %u, counted %lu!\n", 05615 lol_list->name, RSBAC_MAJOR(lol_list->device), RSBAC_MINOR(lol_list->device), lol_list->count, tmp_count); 05616 } 05617 } 05618 rsbac_write_unlock(&lol_list->lock, &lock_flags); 05619 if(lol_list->dirty && (lol_list->flags & RSBAC_LIST_PERSIST)) 05620 { 05621 dirty++; 05622 #ifdef CONFIG_RSBAC_DEBUG 05623 if(rsbac_debug_lists) 05624 { 05625 rsbac_printk(KERN_DEBUG 05626 "rsbac_check_lists(): %s on %02u:%02u has %u items and %lu subitems (list is dirty)\n", 05627 lol_list->name, RSBAC_MAJOR(lol_list->device), RSBAC_MINOR(lol_list->device), lol_list->count, subitem_count); 05628 } 05629 #endif 05630 } 05631 #ifdef CONFIG_RSBAC_DEBUG 05632 else 05633 { 05634 if(rsbac_debug_lists) 05635 { 05636 rsbac_printk(KERN_DEBUG 05637 "rsbac_check_lists(): %s on %02u:%02u has %u items and %lu subitems\n", 05638 lol_list->name, RSBAC_MAJOR(lol_list->device), RSBAC_MINOR(lol_list->device), lol_list->count, subitem_count); 05639 } 05640 } 05641 #endif 05642 lol_list = lol_list->next; 05643 } 05644 rsbac_read_unlock(&lol_reg_head.lock, &rlock_flags); 05645 return 0; 05646 }
|
|
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 }
|