1*4882a593Smuzhiyun /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ 2*4882a593Smuzhiyun /* 3*4882a593Smuzhiyun * Inode based directory notification for Linux 4*4882a593Smuzhiyun * 5*4882a593Smuzhiyun * Copyright (C) 2005 John McCutchan 6*4882a593Smuzhiyun */ 7*4882a593Smuzhiyun 8*4882a593Smuzhiyun #ifndef _UAPI_LINUX_INOTIFY_H 9*4882a593Smuzhiyun #define _UAPI_LINUX_INOTIFY_H 10*4882a593Smuzhiyun 11*4882a593Smuzhiyun /* For O_CLOEXEC and O_NONBLOCK */ 12*4882a593Smuzhiyun #include <linux/fcntl.h> 13*4882a593Smuzhiyun #include <linux/types.h> 14*4882a593Smuzhiyun 15*4882a593Smuzhiyun /* 16*4882a593Smuzhiyun * struct inotify_event - structure read from the inotify device for each event 17*4882a593Smuzhiyun * 18*4882a593Smuzhiyun * When you are watching a directory, you will receive the filename for events 19*4882a593Smuzhiyun * such as IN_CREATE, IN_DELETE, IN_OPEN, IN_CLOSE, ..., relative to the wd. 20*4882a593Smuzhiyun */ 21*4882a593Smuzhiyun struct inotify_event { 22*4882a593Smuzhiyun __s32 wd; /* watch descriptor */ 23*4882a593Smuzhiyun __u32 mask; /* watch mask */ 24*4882a593Smuzhiyun __u32 cookie; /* cookie to synchronize two events */ 25*4882a593Smuzhiyun __u32 len; /* length (including nulls) of name */ 26*4882a593Smuzhiyun char name[0]; /* stub for possible name */ 27*4882a593Smuzhiyun }; 28*4882a593Smuzhiyun 29*4882a593Smuzhiyun /* the following are legal, implemented events that user-space can watch for */ 30*4882a593Smuzhiyun #define IN_ACCESS 0x00000001 /* File was accessed */ 31*4882a593Smuzhiyun #define IN_MODIFY 0x00000002 /* File was modified */ 32*4882a593Smuzhiyun #define IN_ATTRIB 0x00000004 /* Metadata changed */ 33*4882a593Smuzhiyun #define IN_CLOSE_WRITE 0x00000008 /* Writtable file was closed */ 34*4882a593Smuzhiyun #define IN_CLOSE_NOWRITE 0x00000010 /* Unwrittable file closed */ 35*4882a593Smuzhiyun #define IN_OPEN 0x00000020 /* File was opened */ 36*4882a593Smuzhiyun #define IN_MOVED_FROM 0x00000040 /* File was moved from X */ 37*4882a593Smuzhiyun #define IN_MOVED_TO 0x00000080 /* File was moved to Y */ 38*4882a593Smuzhiyun #define IN_CREATE 0x00000100 /* Subfile was created */ 39*4882a593Smuzhiyun #define IN_DELETE 0x00000200 /* Subfile was deleted */ 40*4882a593Smuzhiyun #define IN_DELETE_SELF 0x00000400 /* Self was deleted */ 41*4882a593Smuzhiyun #define IN_MOVE_SELF 0x00000800 /* Self was moved */ 42*4882a593Smuzhiyun 43*4882a593Smuzhiyun /* the following are legal events. they are sent as needed to any watch */ 44*4882a593Smuzhiyun #define IN_UNMOUNT 0x00002000 /* Backing fs was unmounted */ 45*4882a593Smuzhiyun #define IN_Q_OVERFLOW 0x00004000 /* Event queued overflowed */ 46*4882a593Smuzhiyun #define IN_IGNORED 0x00008000 /* File was ignored */ 47*4882a593Smuzhiyun 48*4882a593Smuzhiyun /* helper events */ 49*4882a593Smuzhiyun #define IN_CLOSE (IN_CLOSE_WRITE | IN_CLOSE_NOWRITE) /* close */ 50*4882a593Smuzhiyun #define IN_MOVE (IN_MOVED_FROM | IN_MOVED_TO) /* moves */ 51*4882a593Smuzhiyun 52*4882a593Smuzhiyun /* special flags */ 53*4882a593Smuzhiyun #define IN_ONLYDIR 0x01000000 /* only watch the path if it is a directory */ 54*4882a593Smuzhiyun #define IN_DONT_FOLLOW 0x02000000 /* don't follow a sym link */ 55*4882a593Smuzhiyun #define IN_EXCL_UNLINK 0x04000000 /* exclude events on unlinked objects */ 56*4882a593Smuzhiyun #define IN_MASK_CREATE 0x10000000 /* only create watches */ 57*4882a593Smuzhiyun #define IN_MASK_ADD 0x20000000 /* add to the mask of an already existing watch */ 58*4882a593Smuzhiyun #define IN_ISDIR 0x40000000 /* event occurred against dir */ 59*4882a593Smuzhiyun #define IN_ONESHOT 0x80000000 /* only send event once */ 60*4882a593Smuzhiyun 61*4882a593Smuzhiyun /* 62*4882a593Smuzhiyun * All of the events - we build the list by hand so that we can add flags in 63*4882a593Smuzhiyun * the future and not break backward compatibility. Apps will get only the 64*4882a593Smuzhiyun * events that they originally wanted. Be sure to add new events here! 65*4882a593Smuzhiyun */ 66*4882a593Smuzhiyun #define IN_ALL_EVENTS (IN_ACCESS | IN_MODIFY | IN_ATTRIB | IN_CLOSE_WRITE | \ 67*4882a593Smuzhiyun IN_CLOSE_NOWRITE | IN_OPEN | IN_MOVED_FROM | \ 68*4882a593Smuzhiyun IN_MOVED_TO | IN_DELETE | IN_CREATE | IN_DELETE_SELF | \ 69*4882a593Smuzhiyun IN_MOVE_SELF) 70*4882a593Smuzhiyun 71*4882a593Smuzhiyun /* Flags for sys_inotify_init1. */ 72*4882a593Smuzhiyun #define IN_CLOEXEC O_CLOEXEC 73*4882a593Smuzhiyun #define IN_NONBLOCK O_NONBLOCK 74*4882a593Smuzhiyun 75*4882a593Smuzhiyun /* 76*4882a593Smuzhiyun * ioctl numbers: inotify uses 'I' prefix for all ioctls, 77*4882a593Smuzhiyun * except historical FIONREAD, which is based on 'T'. 78*4882a593Smuzhiyun * 79*4882a593Smuzhiyun * INOTIFY_IOC_SETNEXTWD: set desired number of next created 80*4882a593Smuzhiyun * watch descriptor. 81*4882a593Smuzhiyun */ 82*4882a593Smuzhiyun #define INOTIFY_IOC_SETNEXTWD _IOW('I', 0, __s32) 83*4882a593Smuzhiyun 84*4882a593Smuzhiyun #endif /* _UAPI_LINUX_INOTIFY_H */ 85