fanotify.h 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. #include <linux/fsnotify_backend.h>
  2. #include <linux/path.h>
  3. #include <linux/slab.h>
  4. extern struct kmem_cache *fanotify_mark_cache;
  5. extern struct kmem_cache *fanotify_event_cachep;
  6. extern struct kmem_cache *fanotify_perm_event_cachep;
  7. /*
  8. * Structure for normal fanotify events. It gets allocated in
  9. * fanotify_handle_event() and freed when the information is retrieved by
  10. * userspace
  11. */
  12. struct fanotify_event_info {
  13. struct fsnotify_event fse;
  14. /*
  15. * We hold ref to this path so it may be dereferenced at any point
  16. * during this object's lifetime
  17. */
  18. struct path path;
  19. struct pid *tgid;
  20. };
  21. #ifdef CONFIG_FANOTIFY_ACCESS_PERMISSIONS
  22. /*
  23. * Structure for permission fanotify events. It gets allocated and freed in
  24. * fanotify_handle_event() since we wait there for user response. When the
  25. * information is retrieved by userspace the structure is moved from
  26. * group->notification_list to group->fanotify_data.access_list to wait for
  27. * user response.
  28. */
  29. struct fanotify_perm_event_info {
  30. struct fanotify_event_info fae;
  31. int response; /* userspace answer to question */
  32. int fd; /* fd we passed to userspace for this event */
  33. };
  34. static inline struct fanotify_perm_event_info *
  35. FANOTIFY_PE(struct fsnotify_event *fse)
  36. {
  37. return container_of(fse, struct fanotify_perm_event_info, fae.fse);
  38. }
  39. #endif
  40. static inline struct fanotify_event_info *FANOTIFY_E(struct fsnotify_event *fse)
  41. {
  42. return container_of(fse, struct fanotify_event_info, fse);
  43. }
  44. struct fanotify_event_info *fanotify_alloc_event(struct inode *inode, u32 mask,
  45. const struct path *path);