Advertisement
hongkongkiwi

from-4.9.18_inotify-IN_MASK_CREATE_to_4.9.0.diff

Feb 10th, 2022
30
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.55 KB | None | 0 0
  1. Index: fs/notify/inotify/inotify_user.c
  2. ===================================================================
  3. --- fs.orig/notify/inotify/inotify_user.c
  4. +++ fs/notify/inotify/inotify_user.c
  5. @@ -522,6 +522,7 @@ static int inotify_update_existing_watch
  6. __u32 old_mask, new_mask;
  7. __u32 mask;
  8. int add = (arg & IN_MASK_ADD);
  9. + int create = (arg & IN_MASK_CREATE);
  10. int ret;
  11.  
  12. mask = inotify_arg_to_mask(arg);
  13. @@ -529,6 +530,8 @@ static int inotify_update_existing_watch
  14. fsn_mark = fsnotify_find_inode_mark(group, inode);
  15. if (!fsn_mark)
  16. return -ENOENT;
  17. + else if (create)
  18. + return -EEXIST;
  19.  
  20. i_mark = container_of(fsn_mark, struct inotify_inode_mark, fsn_mark);
  21.  
  22. @@ -726,6 +729,10 @@ SYSCALL_DEFINE3(inotify_add_watch, int,
  23. if (unlikely(!f.file))
  24. return -EBADF;
  25.  
  26. + /* IN_MASK_ADD and IN_MASK_CREATE don't make sense together */
  27. + if (unlikely((mask & IN_MASK_ADD) && (mask & IN_MASK_CREATE)))
  28. + return -EINVAL;
  29. +
  30. /* verify that this is indeed an inotify instance */
  31. if (unlikely(f.file->f_op != &inotify_fops)) {
  32. ret = -EINVAL;
  33. @@ -814,7 +821,7 @@ static int __init inotify_user_setup(voi
  34. BUILD_BUG_ON(IN_ISDIR != FS_ISDIR);
  35. BUILD_BUG_ON(IN_ONESHOT != FS_IN_ONESHOT);
  36.  
  37. - BUG_ON(hweight32(ALL_INOTIFY_BITS) != 21);
  38. + BUG_ON(hweight32(ALL_INOTIFY_BITS) != 22);
  39.  
  40. inotify_inode_mark_cachep = KMEM_CACHE(inotify_inode_mark, SLAB_PANIC);
  41.  
  42. Index: include/linux/inotify.h
  43. ===================================================================
  44. --- include.orig/linux/inotify.h
  45. +++ include/linux/inotify.h
  46. @@ -17,6 +17,6 @@ extern struct ctl_table inotify_table[];
  47. IN_DELETE_SELF | IN_MOVE_SELF | IN_UNMOUNT | \
  48. IN_Q_OVERFLOW | IN_IGNORED | IN_ONLYDIR | \
  49. IN_DONT_FOLLOW | IN_EXCL_UNLINK | IN_MASK_ADD | \
  50. - IN_ISDIR | IN_ONESHOT)
  51. + IN_MASK_CREATE | IN_ISDIR | IN_ONESHOT)
  52.  
  53. #endif /* _LINUX_INOTIFY_H */
  54. Index: include/uapi/linux/inotify.h
  55. ===================================================================
  56. --- include.orig/uapi/linux/inotify.h
  57. +++ include/uapi/linux/inotify.h
  58. @@ -52,6 +52,7 @@ struct inotify_event {
  59. #define IN_ONLYDIR 0x01000000 /* only watch the path if it is a directory */
  60. #define IN_DONT_FOLLOW 0x02000000 /* don't follow a sym link */
  61. #define IN_EXCL_UNLINK 0x04000000 /* exclude events on unlinked objects */
  62. +#define IN_MASK_CREATE 0x10000000 /* only create watches */
  63. #define IN_MASK_ADD 0x20000000 /* add to the mask of an already existing watch */
  64. #define IN_ISDIR 0x40000000 /* event occurred against dir */
  65. #define IN_ONESHOT 0x80000000 /* only send event once */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement