home *** CD-ROM | disk | FTP | other *** search
/ PC Plus SuperCD (UK) 1999 May / pcp151c.iso / misc / src / install / modutils / kerneld / check_persist.c < prev    next >
Encoding:
C/C++ Source or Header  |  1998-01-06  |  656 b   |  38 lines

  1. #include <linux/module.h>
  2. #include <errno.h>
  3. #include <linux/kerneld.h>
  4.  
  5. /*
  6.  * Test persistent module storage by doing:
  7.  *
  8.  *  insmod ./check_persist.o value=1
  9.  */
  10.  
  11. #define Key "you can use any string as a key"
  12.  
  13. /* You can use _anything_ as a value as long as you know its size! */
  14. static int value;
  15.  
  16. int
  17. init_module(void)
  18. {
  19.     int oldval;
  20.  
  21.     if (get_persist(Key, (void *)&oldval, sizeof(int)) > 0)
  22.         printk("found old value: %d\n", oldval);
  23.     else
  24.         printk("no old value\n");
  25.  
  26.     if (set_persist(Key, (void *)&value, sizeof(int)) < 0)
  27.         printk("set_persist failed\n");
  28.     else
  29.         printk("new value: %d\n", value);
  30.  
  31.     return -EBUSY;
  32. }
  33.  
  34. void
  35. cleanup_module(void)
  36. {
  37. }
  38.