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