reg_main.c File Reference

#include <linux/types.h>
#include <linux/string.h>
#include <linux/init.h>
#include <linux/kernel.h>
#include <linux/config.h>
#include <linux/module.h>
#include <asm/uaccess.h>
#include <linux/smp_lock.h>
#include <rsbac/types.h>
#include <rsbac/reg.h>
#include <rsbac/reg_main.h>
#include <rsbac/aci.h>
#include <rsbac/aci_data_structures.h>
#include <rsbac/adf.h>
#include <rsbac/adf_main.h>
#include <rsbac/error.h>
#include <rsbac/helpers.h>
#include <rsbac/getname.h>
#include <rsbac/proc_fs.h>
#include <rsbac/rkmem.h>

Go to the source code of this file.

Functions

static void reg_read_lock (void)
static void reg_read_unlock (void)
static void reg_write_lock (void)
static void reg_write_unlock (void)
static void reg_sc_read_lock (void)
static void reg_sc_read_unlock (void)
static void reg_sc_write_lock (void)
static void reg_sc_write_unlock (void)
static struct rsbac_reg_list_item_t * lookup_item (rsbac_reg_handle_t handle)
static struct rsbac_reg_sc_list_item_t * lookup_sc_item_reg (rsbac_reg_handle_t handle)
static struct rsbac_reg_sc_list_item_t * lookup_sc_item_dis (rsbac_reg_handle_t handle)
static struct rsbac_reg_list_item_t * add_item (struct rsbac_reg_entry_t entry)
static struct rsbac_reg_sc_list_item_t * add_sc_item (struct rsbac_reg_syscall_entry_t entry)
static void remove_item (rsbac_reg_handle_t handle)
static void remove_sc_item (rsbac_reg_handle_t handle)
void __init rsbac_reg_init (void)
enum rsbac_adf_req_ret_t rsbac_adf_request_reg (enum rsbac_adf_request_t request, rsbac_pid_t caller_pid, enum rsbac_target_t target, union rsbac_target_id_t tid, enum rsbac_attribute_t attr, union rsbac_attribute_value_t attr_val, rsbac_uid_t owner)
int rsbac_adf_set_attr_reg (enum rsbac_adf_request_t request, rsbac_pid_t caller_pid, enum rsbac_target_t target, union rsbac_target_id_t tid, enum rsbac_target_t new_target, union rsbac_target_id_t new_tid, enum rsbac_attribute_t attr, union rsbac_attribute_value_t attr_val, rsbac_uid_t owner)
int rsbac_mount_reg (kdev_t kdev)
int rsbac_umount_reg (kdev_t kdev)
int rsbac_check_reg (int correct, int check_inode)
 EXPORT_SYMBOL (rsbac_reg_register)
rsbac_reg_handle_t rsbac_reg_register (rsbac_version_t version, struct rsbac_reg_entry_t entry)
 EXPORT_SYMBOL (rsbac_reg_switch)
int rsbac_reg_switch (rsbac_reg_handle_t handle, rsbac_boolean_t value)
 EXPORT_SYMBOL (rsbac_reg_unregister)
int rsbac_reg_unregister (rsbac_reg_handle_t handle)
rsbac_reg_handle_t rsbac_reg_register_syscall (rsbac_version_t version, struct rsbac_reg_syscall_entry_t entry)
int rsbac_reg_unregister_syscall (rsbac_reg_handle_t handle)
int rsbac_reg_syscall (rsbac_reg_handle_t handle, void *arg)

Variables

static struct rsbac_reg_list_head_t list_head
static struct rsbac_reg_sc_list_head_t sc_list_head


Function Documentation

static struct rsbac_reg_list_item_t* add_item struct rsbac_reg_entry_t  entry  )  [static]
 

Definition at line 172 of file reg_main.c.

References list_head, NULL, rsbac_kmalloc(), and RSBAC_REG_NAME_LEN.

Referenced by read_list(), rsbac_reg_register(), and rsbac_ta_list_add_ttl().

00173     {
00174       struct rsbac_reg_list_item_t * new_item_p = NULL;
00175 
00176       if ( !(new_item_p = (struct rsbac_reg_list_item_t *)
00177                  rsbac_kmalloc(sizeof(*new_item_p))) )
00178         return(NULL);
00179       new_item_p->entry.handle = entry.handle;
00180       strncpy(new_item_p->entry.name, entry.name, RSBAC_REG_NAME_LEN);
00181       new_item_p->entry.name[RSBAC_REG_NAME_LEN] = 0;
00182       new_item_p->entry.request_func = entry.request_func;
00183       new_item_p->entry.set_attr_func = entry.set_attr_func;
00184       new_item_p->entry.need_overwrite_func = entry.need_overwrite_func;
00185       new_item_p->entry.write_func = entry.write_func;
00186       new_item_p->entry.mount_func = entry.mount_func;
00187       new_item_p->entry.umount_func = entry.umount_func;
00188       new_item_p->entry.check_func = entry.check_func;
00189       new_item_p->entry.switch_on = entry.switch_on;
00190       
00191       if (!list_head.head)
00192         {
00193           list_head.head=new_item_p;
00194           list_head.tail=new_item_p;
00195           list_head.curr=new_item_p;
00196           list_head.count = 1;
00197           new_item_p->prev=NULL;
00198           new_item_p->next=NULL;          
00199         }  
00200       else
00201         {
00202           new_item_p->prev=list_head.tail;
00203           new_item_p->next=NULL;
00204           list_head.tail->next=new_item_p;
00205           list_head.tail=new_item_p;
00206           list_head.curr=new_item_p;
00207           list_head.count++;
00208         };
00209       return(new_item_p);
00210     };

static struct rsbac_reg_sc_list_item_t* add_sc_item struct rsbac_reg_syscall_entry_t  entry  )  [static]
 

Definition at line 213 of file reg_main.c.

References rsbac_reg_syscall_entry_t::dispatcher_handle, rsbac_reg_syscall_entry_t::name, NULL, rsbac_reg_syscall_entry_t::registration_handle, rsbac_kmalloc(), RSBAC_REG_NAME_LEN, sc_list_head, and rsbac_reg_syscall_entry_t::syscall_func.

Referenced by rsbac_reg_register_syscall().

00214     {
00215       struct rsbac_reg_sc_list_item_t * new_item_p = NULL;
00216 
00217       if ( !(new_item_p = (struct rsbac_reg_sc_list_item_t *)
00218                  rsbac_kmalloc(sizeof(*new_item_p))) )
00219         return(NULL);
00220       new_item_p->entry.registration_handle = entry.registration_handle;
00221       new_item_p->entry.dispatcher_handle = entry.dispatcher_handle;
00222       strncpy(new_item_p->entry.name, entry.name, RSBAC_REG_NAME_LEN);
00223       new_item_p->entry.name[RSBAC_REG_NAME_LEN] = 0;
00224       new_item_p->entry.syscall_func = entry.syscall_func;
00225       
00226       if (!sc_list_head.head)
00227         {
00228           sc_list_head.head=new_item_p;
00229           sc_list_head.tail=new_item_p;
00230           sc_list_head.curr=new_item_p;
00231           sc_list_head.count = 1;
00232           new_item_p->prev=NULL;
00233           new_item_p->next=NULL;          
00234         }  
00235       else
00236         {
00237           new_item_p->prev=sc_list_head.tail;
00238           new_item_p->next=NULL;
00239           sc_list_head.tail->next=new_item_p;
00240           sc_list_head.tail=new_item_p;
00241           sc_list_head.curr=new_item_p;
00242           sc_list_head.count++;
00243         };
00244       return(new_item_p);
00245     };

EXPORT_SYMBOL rsbac_reg_unregister   ) 
 

EXPORT_SYMBOL rsbac_reg_switch   ) 
 

EXPORT_SYMBOL rsbac_reg_register   ) 
 

static struct rsbac_reg_list_item_t* lookup_item rsbac_reg_handle_t  handle  )  [static]
 

Definition at line 121 of file reg_main.c.

References list_head.

Referenced by remove_item(), rsbac_reg_register(), rsbac_reg_switch(), rsbac_reg_unregister(), rsbac_ta_list_add_ttl(), rsbac_ta_list_exist(), rsbac_ta_list_get_data_ttl(), rsbac_ta_list_get_next_desc(), and rsbac_ta_list_remove().

00122   {
00123     struct rsbac_reg_list_item_t  * curr = list_head.curr;
00124 
00125     /* is the current item the one we look for? yes -> return, else search */
00126     if (curr && (curr->entry.handle == handle))
00127       return (curr);
00128 
00129     curr = list_head.head;
00130     while (curr && (curr->entry.handle != handle))
00131       curr = curr->next;
00132     if (curr)
00133       list_head.curr=curr;
00134     return (curr);
00135   };

static struct rsbac_reg_sc_list_item_t* lookup_sc_item_dis rsbac_reg_handle_t  handle  )  [static]
 

Definition at line 155 of file reg_main.c.

References sc_list_head.

Referenced by rsbac_reg_register_syscall(), and rsbac_reg_syscall().

00156   {
00157     struct rsbac_reg_sc_list_item_t  * curr = sc_list_head.curr;
00158 
00159     /* is the current item the one we look for? yes -> return, else search */
00160     if (curr && (curr->entry.dispatcher_handle == handle))
00161       return (curr);
00162 
00163     curr = sc_list_head.head;
00164     while (curr && (curr->entry.dispatcher_handle != handle))
00165       curr = curr->next;
00166     if (curr)
00167       sc_list_head.curr=curr;
00168     return (curr);
00169   };

static struct rsbac_reg_sc_list_item_t* lookup_sc_item_reg rsbac_reg_handle_t  handle  )  [static]
 

Definition at line 138 of file reg_main.c.

References sc_list_head.

Referenced by remove_sc_item(), rsbac_reg_register_syscall(), and rsbac_reg_unregister_syscall().

00139   {
00140     struct rsbac_reg_sc_list_item_t  * curr = sc_list_head.curr;
00141 
00142     /* is the current item the one we look for? yes -> return, else search */
00143     if (curr && (curr->entry.registration_handle == handle))
00144       return (curr);
00145 
00146     curr = sc_list_head.head;
00147     while (curr && (curr->entry.registration_handle != handle))
00148       curr = curr->next;
00149     if (curr)
00150       sc_list_head.curr=curr;
00151     return (curr);
00152   };

static void reg_read_lock void   )  [static]
 

Definition at line 44 of file reg_main.c.

References list_head.

Referenced by rsbac_adf_request_reg(), rsbac_adf_set_attr_reg(), rsbac_check_reg(), rsbac_mount_reg(), rsbac_reg_switch(), and rsbac_umount_reg().

00045   {
00046     spin_lock(&list_head.lock);
00047     while(list_head.readers < 0)
00048       {
00049         spin_unlock(&list_head.lock);
00050         spin_lock(&list_head.lock);
00051       }
00052     list_head.readers++;
00053     spin_unlock(&list_head.lock);
00054   }

static void reg_read_unlock void   )  [static]
 

Definition at line 56 of file reg_main.c.

References list_head.

Referenced by rsbac_adf_request_reg(), rsbac_adf_set_attr_reg(), rsbac_check_reg(), rsbac_mount_reg(), rsbac_reg_switch(), and rsbac_umount_reg().

00057   {
00058     spin_lock(&list_head.lock);
00059     list_head.readers--;
00060     spin_unlock(&list_head.lock);
00061   }

static void reg_sc_read_lock void   )  [static]
 

Definition at line 82 of file reg_main.c.

References sc_list_head.

Referenced by rsbac_reg_syscall().

00083   {
00084     spin_lock(&sc_list_head.lock);
00085     while(sc_list_head.readers < 0)
00086       {
00087         spin_unlock(&sc_list_head.lock);
00088         spin_lock(&sc_list_head.lock);
00089       }
00090     sc_list_head.readers++;
00091     spin_unlock(&sc_list_head.lock);
00092   }

static void reg_sc_read_unlock void   )  [static]
 

Definition at line 94 of file reg_main.c.

References sc_list_head.

Referenced by rsbac_reg_syscall().

00095   {
00096     spin_lock(&sc_list_head.lock);
00097     sc_list_head.readers--;
00098     spin_unlock(&sc_list_head.lock);
00099   }

static void reg_sc_write_lock void   )  [static]
 

Definition at line 101 of file reg_main.c.

References sc_list_head.

Referenced by rsbac_reg_register_syscall(), and rsbac_reg_unregister_syscall().

00102   {
00103     spin_lock(&sc_list_head.lock);
00104     while(sc_list_head.readers != 0)
00105       {
00106         spin_unlock(&sc_list_head.lock);
00107         spin_lock(&sc_list_head.lock);
00108       }
00109     sc_list_head.readers = -1;
00110     spin_unlock(&sc_list_head.lock);
00111   }

static void reg_sc_write_unlock void   )  [static]
 

Definition at line 113 of file reg_main.c.

References sc_list_head.

Referenced by rsbac_reg_register_syscall(), and rsbac_reg_unregister_syscall().

00114   {
00115     spin_lock(&sc_list_head.lock);
00116     sc_list_head.readers = 0;
00117     spin_unlock(&sc_list_head.lock);
00118   }

static void reg_write_lock void   )  [static]
 

Definition at line 63 of file reg_main.c.

References list_head.

Referenced by rsbac_reg_register(), and rsbac_reg_unregister().

00064   {
00065     spin_lock(&list_head.lock);
00066     while(list_head.readers != 0)
00067       {
00068         spin_unlock(&list_head.lock);
00069         spin_lock(&list_head.lock);
00070       }
00071     list_head.readers = -1;
00072     spin_unlock(&list_head.lock);
00073   }

static void reg_write_unlock void   )  [static]
 

Definition at line 75 of file reg_main.c.

References list_head.

Referenced by rsbac_reg_register(), and rsbac_reg_unregister().

00076   {
00077     spin_lock(&list_head.lock);
00078     list_head.readers = 0;
00079     spin_unlock(&list_head.lock);
00080   }

static void remove_item rsbac_reg_handle_t  handle  )  [static]
 

Definition at line 247 of file reg_main.c.

References list_head, lookup_item(), NULL, and rsbac_kfree().

Referenced by rsbac_reg_unregister(), and rsbac_ta_list_remove().

00248     {
00249       struct rsbac_reg_list_item_t * item_p;
00250     
00251       /* first we must locate the item. */
00252       if ( (item_p = lookup_item(handle)) )
00253         { /* ok, item was found */
00254           if ( (list_head.head == item_p) )
00255              { /* item is head */
00256                if ( (list_head.tail == item_p) )
00257                  { /* item is head and tail = only item -> list will be empty*/
00258                    list_head.head = NULL;
00259                    list_head.tail = NULL;
00260                  }
00261                else
00262                  { /* item is head, but not tail -> next item becomes head */
00263                    item_p->next->prev = NULL;
00264                    list_head.head = item_p->next;
00265                  };
00266              }
00267           else
00268              { /* item is not head */
00269                if ( (list_head.tail == item_p) )
00270                  { /*item is not head, but tail -> previous item becomes tail*/
00271                    item_p->prev->next = NULL;
00272                    list_head.tail = item_p->prev;
00273                  }
00274                else
00275                  { /* item is neither head nor tail -> item is cut out */
00276                    item_p->prev->next = item_p->next;
00277                    item_p->next->prev = item_p->prev;
00278                  };
00279              };
00280              
00281           /* curr is no longer valid -> reset */
00282           list_head.curr=NULL;
00283           /* adjust counter */
00284           list_head.count--;
00285           /* now we can remove the item from memory */
00286           rsbac_kfree(item_p);    
00287         };  /* end of if: item was found */
00288     }; /* end of remove_item() */

static void remove_sc_item rsbac_reg_handle_t  handle  )  [static]
 

Definition at line 290 of file reg_main.c.

References lookup_sc_item_reg(), NULL, rsbac_kfree(), and sc_list_head.

Referenced by rsbac_reg_unregister_syscall().

00291     {
00292       struct rsbac_reg_sc_list_item_t * item_p;
00293     
00294       /* first we must locate the item. */
00295       if ( (item_p = lookup_sc_item_reg(handle)) )
00296         { /* ok, item was found */
00297           if ( (sc_list_head.head == item_p) )
00298              { /* item is head */
00299                if ( (sc_list_head.tail == item_p) )
00300                  { /* item is head and tail = only item -> sc_list will be empty*/
00301                    sc_list_head.head = NULL;
00302                    sc_list_head.tail = NULL;
00303                  }
00304                else
00305                  { /* item is head, but not tail -> next item becomes head */
00306                    item_p->next->prev = NULL;
00307                    sc_list_head.head = item_p->next;
00308                  };
00309              }
00310           else
00311              { /* item is not head */
00312                if ( (sc_list_head.tail == item_p) )
00313                  { /*item is not head, but tail -> previous item becomes tail*/
00314                    item_p->prev->next = NULL;
00315                    sc_list_head.tail = item_p->prev;
00316                  }
00317                else
00318                  { /* item is neither head nor tail -> item is cut out */
00319                    item_p->prev->next = item_p->next;
00320                    item_p->next->prev = item_p->prev;
00321                  };
00322              };
00323              
00324           /* curr is no longer valid -> reset */
00325           sc_list_head.curr=NULL;
00326           /* adjust counter */
00327           sc_list_head.count--;
00328           /* now we can remove the item from memory */
00329           rsbac_kfree(item_p);    
00330         };  /* end of if: item was found */
00331     }; /* end of remove_item() */

enum rsbac_adf_req_ret_t rsbac_adf_request_reg enum rsbac_adf_request_t  request,
rsbac_pid_t  caller_pid,
enum rsbac_target_t  target,
union rsbac_target_id_t  tid,
enum rsbac_attribute_t  attr,
union rsbac_attribute_value_t  attr_val,
rsbac_uid_t  owner
 

Definition at line 523 of file reg_main.c.

References adf_and_plus(), DO_NOT_CARE, list_head, reg_read_lock(), and reg_read_unlock().

Referenced by rsbac_adf_request_int().

00530   {
00531     enum   rsbac_adf_req_ret_t        result = DO_NOT_CARE;
00532     struct rsbac_reg_list_item_t    * item_p;
00533 
00534     reg_read_lock();
00535     item_p=list_head.head;
00536     while(item_p)
00537       {
00538         if(   item_p->entry.request_func
00539         #ifdef CONFIG_RSBAC_SWITCH_REG
00540            && item_p->entry.switch_on
00541         #endif
00542           )
00543           result = adf_and_plus(result,
00544                                 item_p->entry.request_func (request,
00545                                                             caller_pid,
00546                                                             target,
00547                                                             tid,
00548                                                             attr,
00549                                                             attr_val,
00550                                                             owner) );
00551         item_p=item_p->next;
00552       }
00553     reg_read_unlock();
00554     return result;
00555   }

int rsbac_adf_set_attr_reg enum rsbac_adf_request_t  request,
rsbac_pid_t  caller_pid,
enum rsbac_target_t  target,
union rsbac_target_id_t  tid,
enum rsbac_target_t  new_target,
union rsbac_target_id_t  new_tid,
enum rsbac_attribute_t  attr,
union rsbac_attribute_value_t  attr_val,
rsbac_uid_t  owner
 

Definition at line 557 of file reg_main.c.

References list_head, reg_read_lock(), and reg_read_unlock().

Referenced by rsbac_adf_set_attr().

00567   {
00568     int error = 0;
00569     int suberror;
00570     struct rsbac_reg_list_item_t    * item_p;
00571 
00572     reg_read_lock();
00573     item_p=list_head.head;
00574     while(item_p)
00575       {
00576         if(   item_p->entry.set_attr_func
00577         #ifdef CONFIG_RSBAC_SWITCH_REG
00578            && item_p->entry.switch_on
00579         #endif
00580           )
00581           {
00582             suberror = item_p->entry.set_attr_func (request,
00583                                                     caller_pid,
00584                                                     target,
00585                                                     tid,
00586                                                     new_target,
00587                                                     new_tid,
00588                                                     attr,
00589                                                     attr_val,
00590                                                     owner);
00591             if(suberror)
00592               error = suberror;
00593           }
00594         item_p = item_p->next;
00595       }
00596     reg_read_unlock();
00597     return error;
00598   }

int rsbac_check_reg int  correct,
int  check_inode
 

Definition at line 716 of file reg_main.c.

References list_head, reg_read_lock(), and reg_read_unlock().

Referenced by sys_rsbac_check().

00717   {
00718     int error = 0;
00719     int suberror;
00720     struct rsbac_reg_list_item_t    * item_p;
00721 
00722     reg_read_lock();
00723     item_p=list_head.head;
00724     while(item_p)
00725       {
00726         if(   item_p->entry.check_func
00727           )
00728           {
00729             suberror = item_p->entry.check_func(correct, check_inode);
00730             if(suberror < 0)
00731               error = suberror;
00732           }
00733         item_p=item_p->next;
00734       }
00735     reg_read_unlock();
00736     return error;
00737   }

int rsbac_mount_reg kdev_t  kdev  ) 
 

Definition at line 626 of file reg_main.c.

References list_head, reg_read_lock(), and reg_read_unlock().

Referenced by rsbac_mount().

00627   {
00628     int error = 0;
00629     int suberror;
00630     struct rsbac_reg_list_item_t    * item_p;
00631 
00632     reg_read_lock();
00633     item_p=list_head.head;
00634     while(item_p)
00635       {
00636         if(   item_p->entry.mount_func
00637           )
00638           {
00639             suberror = item_p->entry.mount_func(kdev);
00640             if(suberror < 0)
00641               error = suberror;
00642           }
00643         item_p=item_p->next;
00644       }
00645     reg_read_unlock();
00646     return error;
00647   }

void __init rsbac_reg_init void   ) 
 

Definition at line 481 of file reg_main.c.

References list_head, NULL, proc_rsbac_root_p, rsbac_is_initialized(), rsbac_printk(), RSBAC_REG_PROC_NAME, and sc_list_head.

Referenced by rsbac_init_adf().

00483   {
00484     if (rsbac_is_initialized())
00485       {
00486         rsbac_printk(KERN_WARNING "rsbac_reg_init(): RSBAC already initialized\n");
00487         return;
00488       }
00489     /* init data structures */
00490     rsbac_printk(KERN_INFO "rsbac_reg_init(): Initializing RSBAC: REG module and syscall registration\n");
00491 
00492     list_head.lock = SPIN_LOCK_UNLOCKED;
00493     list_head.readers = 0;
00494     list_head.head = NULL;
00495     list_head.tail = NULL;
00496     list_head.curr = NULL;
00497     list_head.count = 0;
00498     sc_list_head.lock = SPIN_LOCK_UNLOCKED;
00499     sc_list_head.readers = 0;
00500     sc_list_head.head = NULL;
00501     sc_list_head.tail = NULL;
00502     sc_list_head.curr = NULL;
00503     sc_list_head.count = 0;
00504 
00505     /* init proc entry */
00506     #if defined(CONFIG_RSBAC_PROC) && defined(CONFIG_PROC_FS)
00507     {
00508       struct proc_dir_entry * tmp_entry_p;
00509 
00510       tmp_entry_p = create_proc_entry(RSBAC_REG_PROC_NAME,
00511                                       S_IFREG | S_IRUGO,
00512                                       proc_rsbac_root_p);
00513       if(tmp_entry_p)
00514         {
00515           tmp_entry_p->get_info = reg_modules_proc_info;
00516         }
00517     }
00518     #endif
00519   }

rsbac_reg_handle_t rsbac_reg_register rsbac_version_t  version,
struct rsbac_reg_entry_t  entry
 

Definition at line 747 of file reg_main.c.

References add_item(), rsbac_reg_entry_t::handle, lookup_item(), rsbac_reg_entry_t::mount_func, rsbac_reg_entry_t::name, rsbac_reg_entry_t::need_overwrite_func, reg_write_lock(), reg_write_unlock(), rsbac_reg_entry_t::request_func, RSBAC_ECOULDNOTADDITEM, RSBAC_EEXISTS, RSBAC_EINVALIDVALUE, RSBAC_EINVALIDVERSION, rsbac_printk(), RSBAC_REG_NAME_LEN, RSBAC_REG_VERSION, rsbac_reg_entry_t::set_attr_func, rsbac_reg_entry_t::umount_func, and rsbac_reg_entry_t::write_func.

Referenced by init_module().

00749   {
00750     if(version != RSBAC_REG_VERSION)
00751       return(-RSBAC_EINVALIDVERSION);
00752 
00753     /* check entry */
00754     if(   (   !entry.request_func
00755            && !entry.set_attr_func
00756            && !entry.need_overwrite_func
00757            && !entry.write_func
00758            && !entry.mount_func
00759            && !entry.umount_func
00760           )
00761        || (entry.handle <= 0)
00762       )
00763       return -RSBAC_EINVALIDVALUE;
00764 
00765     reg_write_lock();
00766     if(lookup_item(entry.handle))
00767       {
00768         rsbac_printk(KERN_INFO "rsbac_reg_register: Handle in use, registering failed: %s.\n",
00769                entry.name);
00770         entry.handle = -RSBAC_EEXISTS;
00771       }
00772     else
00773       {
00774         if(!add_item(entry))
00775           {
00776             entry.name[RSBAC_REG_NAME_LEN] = 0;
00777             rsbac_printk(KERN_INFO "rsbac_reg_register: registering failed for %s.\n",
00778                    entry.name);
00779             entry.handle = -RSBAC_ECOULDNOTADDITEM;
00780           }
00781 #ifdef CONFIG_RSBAC_DEBUG
00782         else
00783           if(rsbac_debug_reg)
00784             {
00785               rsbac_printk(KERN_DEBUG "rsbac_reg_register: module %s registered.\n",
00786                      entry.name);
00787             }
00788 #endif
00789       }
00790     reg_write_unlock();
00791     return entry.handle;
00792   }

rsbac_reg_handle_t rsbac_reg_register_syscall rsbac_version_t  version,
struct rsbac_reg_syscall_entry_t  entry
 

Definition at line 880 of file reg_main.c.

References add_sc_item(), rsbac_reg_syscall_entry_t::dispatcher_handle, lookup_sc_item_dis(), lookup_sc_item_reg(), rsbac_reg_syscall_entry_t::name, reg_sc_write_lock(), reg_sc_write_unlock(), rsbac_reg_syscall_entry_t::registration_handle, RSBAC_ECOULDNOTADDITEM, RSBAC_EEXISTS, RSBAC_EINVALIDVALUE, RSBAC_EINVALIDVERSION, rsbac_printk(), RSBAC_REG_NAME_LEN, RSBAC_REG_VERSION, and rsbac_reg_syscall_entry_t::syscall_func.

Referenced by init_module().

00882   {
00883     if(version != RSBAC_REG_VERSION)
00884       return(-RSBAC_EINVALIDVERSION);
00885 
00886     /* check entry */
00887     if(   !entry.syscall_func
00888        || (entry.registration_handle <= 0)
00889        || (entry.dispatcher_handle <= 0)
00890       )
00891       return -RSBAC_EINVALIDVALUE;
00892 
00893     reg_sc_write_lock();
00894     if(lookup_sc_item_reg(entry.registration_handle))
00895       {
00896         rsbac_printk(KERN_INFO "rsbac_reg_register_syscall: Registration handle in use, registering failed: %s.\n",
00897                entry.name);
00898         entry.registration_handle = -RSBAC_EEXISTS;
00899       }
00900     else
00901     if(lookup_sc_item_dis(entry.dispatcher_handle))
00902       {
00903         rsbac_printk(KERN_INFO "rsbac_reg_register_syscall: Dispatcher handle in use, registering failed: %s.\n",
00904                entry.name);
00905         entry.registration_handle = -RSBAC_EEXISTS;
00906       }
00907     else
00908       {
00909         entry.name[RSBAC_REG_NAME_LEN] = 0;
00910         if(!add_sc_item(entry))
00911           {
00912             rsbac_printk(KERN_INFO "rsbac_reg_register_syscall: registering failed for %s.\n",
00913                    entry.name);
00914             entry.registration_handle = -RSBAC_ECOULDNOTADDITEM;
00915           }
00916 #ifdef CONFIG_RSBAC_DEBUG
00917         else
00918           if(rsbac_debug_reg)
00919             {
00920               rsbac_printk(KERN_DEBUG "rsbac_reg_register_syscall: syscall %s registered.\n",
00921                      entry.name);
00922             }
00923 #endif
00924       }
00925     reg_sc_write_unlock();
00926     return entry.registration_handle;
00927   }

int rsbac_reg_switch rsbac_reg_handle_t  handle,
rsbac_boolean_t  value
 

Definition at line 801 of file reg_main.c.

References FALSE, lookup_item(), reg_read_lock(), reg_read_unlock(), RSBAC_EINVALIDTARGET, RSBAC_EINVALIDVALUE, rsbac_printk(), and TRUE.

00802   {
00803 #ifdef CONFIG_RSBAC_SWITCH_REG
00804     struct rsbac_reg_list_item_t    * item_p;
00805            int err=0;
00806 
00807     if((value != FALSE) && (value != TRUE))
00808       return -RSBAC_EINVALIDVALUE;
00809     reg_read_lock();
00810     item_p = lookup_item(handle);
00811     if(item_p)
00812       {
00813         item_p->entry.switch_on = value;
00814 #ifdef CONFIG_RSBAC_DEBUG
00815         if(rsbac_debug_reg)
00816           {
00817             rsbac_printk(KERN_DEBUG "rsbac_reg_switch: module %s switched to %i.\n",
00818                    item_p->entry.name,
00819                    value);
00820           }
00821 #endif
00822       }
00823     else
00824       err = -RSBAC_EINVALIDTARGET;
00825     reg_read_unlock();
00826     return err;
00827 #else
00828     return(-RSBAC_EINVALIDTARGET);
00829 #endif
00830   };

int rsbac_reg_syscall rsbac_reg_handle_t  handle,
void *  arg
 

Definition at line 964 of file reg_main.c.

References lookup_sc_item_dis(), reg_sc_read_lock(), reg_sc_read_unlock(), and RSBAC_EINVALIDTARGET.

Referenced by sys_rsbac_reg().

00966   {
00967     int err = 0;
00968     struct rsbac_reg_sc_list_item_t    * item_p;
00969 
00970     reg_sc_read_lock();
00971     item_p=lookup_sc_item_dis(handle);
00972     if(item_p && item_p->entry.syscall_func)
00973       {
00974         err = item_p->entry.syscall_func(arg);
00975       }
00976     else
00977       {
00978         err = -RSBAC_EINVALIDTARGET;
00979       }
00980     reg_sc_read_unlock();
00981     return err;
00982   }

int rsbac_reg_unregister rsbac_reg_handle_t  handle  ) 
 

Definition at line 840 of file reg_main.c.

References lookup_item(), reg_write_lock(), reg_write_unlock(), remove_item(), RSBAC_EINVALIDTARGET, RSBAC_EINVALIDVALUE, and rsbac_printk().

Referenced by cleanup_module(), and init_module().

00841   {
00842     int    err=0;
00843 
00844     if(handle <= 0)
00845       return -RSBAC_EINVALIDVALUE;
00846 
00847     reg_write_lock();
00848     if(lookup_item(handle))
00849       {
00850         remove_item(handle);
00851 #ifdef CONFIG_RSBAC_DEBUG
00852         if(rsbac_debug_reg)
00853           {
00854             rsbac_printk(KERN_DEBUG "rsbac_reg_unregister: module unregistered.\n");
00855           }
00856 #endif
00857       }
00858     else
00859       {
00860         err = -RSBAC_EINVALIDTARGET;
00861 #ifdef CONFIG_RSBAC_DEBUG
00862         if(rsbac_debug_reg)
00863           {
00864             rsbac_printk(KERN_DEBUG "rsbac_reg_unregister: module unregistering failed.\n");
00865           }
00866 #endif
00867       }
00868     reg_write_unlock();
00869     return err;
00870   }

int rsbac_reg_unregister_syscall rsbac_reg_handle_t  handle  ) 
 

Definition at line 937 of file reg_main.c.

References lookup_sc_item_reg(), reg_sc_write_lock(), reg_sc_write_unlock(), remove_sc_item(), RSBAC_EINVALIDTARGET, RSBAC_EINVALIDVALUE, and rsbac_printk().

Referenced by cleanup_module(), and init_module().

00938   {
00939     int    err=0;
00940 
00941     if(handle <= 0)
00942       return -RSBAC_EINVALIDVALUE;
00943 
00944     reg_sc_write_lock();
00945     if(lookup_sc_item_reg(handle))
00946       {
00947         remove_sc_item(handle);
00948 #ifdef CONFIG_RSBAC_DEBUG
00949         if(rsbac_debug_reg)
00950           {
00951             rsbac_printk(KERN_DEBUG "rsbac_reg_unregister_syscall: syscall unregistered.\n");
00952           }
00953 #endif
00954       }
00955     else
00956       {
00957         err = -RSBAC_EINVALIDTARGET;
00958         rsbac_printk(KERN_INFO "rsbac_reg_unregister_syscall: syscall unregistering failed for invalid handle!\n");
00959       }
00960     reg_sc_write_unlock();
00961     return err;
00962   }

int rsbac_umount_reg kdev_t  kdev  ) 
 

Definition at line 649 of file reg_main.c.

References list_head, reg_read_lock(), and reg_read_unlock().

Referenced by rsbac_umount().

00650   {
00651     int error = 0;
00652     int suberror;
00653     struct rsbac_reg_list_item_t    * item_p;
00654 
00655     reg_read_lock();
00656     item_p=list_head.head;
00657     while(item_p)
00658       {
00659         if(   item_p->entry.umount_func
00660           )
00661           {
00662             suberror = item_p->entry.umount_func(kdev);
00663             if(suberror < 0)
00664               error = suberror;
00665           }
00666         item_p=item_p->next;
00667       }
00668     reg_read_unlock();
00669     return error;
00670   }


Variable Documentation

struct rsbac_reg_list_head_t list_head [static]
 

Definition at line 37 of file reg_main.c.

Referenced by add_item(), lookup_item(), reg_read_lock(), reg_read_unlock(), reg_write_lock(), reg_write_unlock(), remove_item(), rsbac_adf_request_reg(), rsbac_adf_set_attr_reg(), rsbac_check_reg(), rsbac_init(), rsbac_mount_reg(), rsbac_reg_init(), and rsbac_umount_reg().

struct rsbac_reg_sc_list_head_t sc_list_head [static]
 

Definition at line 38 of file reg_main.c.

Referenced by add_sc_item(), lookup_sc_item_dis(), lookup_sc_item_reg(), reg_sc_read_lock(), reg_sc_read_unlock(), reg_sc_write_lock(), reg_sc_write_unlock(), remove_sc_item(), and rsbac_reg_init().


Generated on Sun May 21 14:31:03 2006 for RSBAC by  doxygen 1.4.2