dm-uevent.c 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. /*
  2. * Device Mapper Uevent Support (dm-uevent)
  3. *
  4. * This program is free software; you can redistribute it and/or modify it
  5. * under the terms of the GNU General Public License as published by the
  6. * Free Software Foundation; either version 2 of the License, or (at your
  7. * option) any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful, but
  10. * WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  12. * General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License along
  15. * with this program; if not, write to the Free Software Foundation, Inc.,
  16. * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  17. *
  18. * Copyright IBM Corporation, 2007
  19. * Author: Mike Anderson <andmike@linux.vnet.ibm.com>
  20. */
  21. #include <linux/list.h>
  22. #include <linux/slab.h>
  23. #include <linux/kobject.h>
  24. #include "dm.h"
  25. #include "dm-uevent.h"
  26. #define DM_MSG_PREFIX "uevent"
  27. static struct kmem_cache *_dm_event_cache;
  28. struct dm_uevent {
  29. struct mapped_device *md;
  30. enum kobject_action action;
  31. struct kobj_uevent_env ku_env;
  32. struct list_head elist;
  33. };
  34. static void dm_uevent_free(struct dm_uevent *event)
  35. {
  36. kmem_cache_free(_dm_event_cache, event);
  37. }
  38. static struct dm_uevent *dm_uevent_alloc(struct mapped_device *md)
  39. {
  40. struct dm_uevent *event;
  41. event = kmem_cache_zalloc(_dm_event_cache, GFP_ATOMIC);
  42. if (!event)
  43. return NULL;
  44. INIT_LIST_HEAD(&event->elist);
  45. event->md = md;
  46. return event;
  47. }
  48. int dm_uevent_init(void)
  49. {
  50. _dm_event_cache = KMEM_CACHE(dm_uevent, 0);
  51. if (!_dm_event_cache)
  52. return -ENOMEM;
  53. DMINFO("version 1.0.3");
  54. return 0;
  55. }
  56. void dm_uevent_exit(void)
  57. {
  58. kmem_cache_destroy(_dm_event_cache);
  59. }