^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) /* SPDX-License-Identifier: GPL-2.0 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) #include <linux/fsnotify_backend.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) #include <linux/inotify.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) #include <linux/slab.h> /* struct kmem_cache */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) struct inotify_event_info {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) struct fsnotify_event fse;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) u32 mask;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) int wd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) u32 sync_cookie;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) int name_len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) char name[];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) struct inotify_inode_mark {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) struct fsnotify_mark fsn_mark;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) int wd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) static inline struct inotify_event_info *INOTIFY_E(struct fsnotify_event *fse)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) return container_of(fse, struct inotify_event_info, fse);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) extern void inotify_ignored_and_remove_idr(struct fsnotify_mark *fsn_mark,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) struct fsnotify_group *group);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) extern int inotify_handle_inode_event(struct fsnotify_mark *inode_mark,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) u32 mask, struct inode *inode,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) struct inode *dir,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) const struct qstr *name, u32 cookie);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) extern const struct fsnotify_ops inotify_fsnotify_ops;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) extern struct kmem_cache *inotify_inode_mark_cachep;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) #ifdef CONFIG_INOTIFY_USER
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) static inline void dec_inotify_instances(struct ucounts *ucounts)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) dec_ucount(ucounts, UCOUNT_INOTIFY_INSTANCES);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) static inline struct ucounts *inc_inotify_watches(struct ucounts *ucounts)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) return inc_ucount(ucounts->ns, ucounts->uid, UCOUNT_INOTIFY_WATCHES);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) static inline void dec_inotify_watches(struct ucounts *ucounts)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) dec_ucount(ucounts, UCOUNT_INOTIFY_WATCHES);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) #endif