Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

linux_inotify.h

Go to the documentation of this file.
00001 /*
00002  * Inode based directory notification for Linux
00003  *
00004  * Copyright (C) 2005 John McCutchan
00005  */
00006 
00007 #ifndef _LINUX_INOTIFY_H
00008 #define _LINUX_INOTIFY_H
00009 
00010 #include <sys/types.h>
00011 #include <linux/limits.h>
00012 #include <linux/types.h>
00013 
00014 /*
00015  * struct inotify_event - structure read from the inotify device for each event
00016  *
00017  * When you are watching a directory, you will receive the filename for events
00018  * such as IN_CREATE, IN_DELETE, IN_OPEN, IN_CLOSE, ..., relative to the wd.
00019  */
00020 struct inotify_event {
00021         __s32           wd;             /* watch descriptor */
00022         __u32           mask;           /* watch mask */
00023         __u32           cookie;         /* cookie to synchronize two events */
00024         __u32           len;            /* length (including nulls) of name */
00025         char            name[0];        /* stub for possible name */
00026 };
00027 
00028 /*
00029  * struct inotify_watch_request - represents a watch request
00030  *
00031  * Pass to the inotify device via the INOTIFY_WATCH ioctl
00032  */
00033 struct inotify_watch_request {
00034         char            *name;          /* filename name */
00035         __u32           mask;           /* event mask */
00036 };
00037 
00038 /* the following are legal, implemented events */
00039 #define IN_ACCESS               0x00000001      /* File was accessed */
00040 #define IN_MODIFY               0x00000002      /* File was modified */
00041 #define IN_ATTRIB               0x00000004      /* File changed attributes */
00042 #define IN_CLOSE_WRITE          0x00000008      /* Writtable file was closed */
00043 #define IN_CLOSE_NOWRITE        0x00000010      /* Unwrittable file closed */
00044 #define IN_OPEN                 0x00000020      /* File was opened */
00045 #define IN_MOVED_FROM           0x00000040      /* File was moved from X */
00046 #define IN_MOVED_TO             0x00000080      /* File was moved to Y */
00047 #define IN_DELETE_SUBDIR        0x00000100      /* Subdir was deleted */
00048 #define IN_DELETE_FILE          0x00000200      /* Subfile was deleted */
00049 #define IN_CREATE_SUBDIR        0x00000400      /* Subdir was created */
00050 #define IN_CREATE_FILE          0x00000800      /* Subfile was created */
00051 #define IN_DELETE_SELF          0x00001000      /* Self was deleted */
00052 #define IN_UNMOUNT              0x00002000      /* Backing fs was unmounted */
00053 #define IN_Q_OVERFLOW           0x00004000      /* Event queued overflowed */
00054 #define IN_IGNORED              0x00008000      /* File was ignored */
00055 
00056 /* special flags */
00057 #define IN_ALL_EVENTS           0xffffffff      /* All the events */
00058 #define IN_CLOSE                (IN_CLOSE_WRITE | IN_CLOSE_NOWRITE)
00059 
00060 #define INOTIFY_IOCTL_MAGIC     'Q'
00061 #define INOTIFY_IOCTL_MAXNR     2
00062 
00063 #define INOTIFY_WATCH           _IOR(INOTIFY_IOCTL_MAGIC, 1, struct inotify_watch_request)
00064 #define INOTIFY_IGNORE          _IOR(INOTIFY_IOCTL_MAGIC, 2, int)
00065 
00066 #ifdef __KERNEL__
00067 
00068 #include <linux/dcache.h>
00069 #include <linux/fs.h>
00070 #include <linux/config.h>
00071 #include <asm/atomic.h>
00072 
00073 #ifdef CONFIG_INOTIFY
00074 
00075 extern void inotify_inode_queue_event(struct inode *, __u32, __u32,
00076                                       const char *);
00077 extern void inotify_dentry_parent_queue_event(struct dentry *, __u32, __u32,
00078                                               const char *);
00079 extern void inotify_super_block_umount(struct super_block *);
00080 extern void inotify_inode_is_dead(struct inode *);
00081 extern u32 inotify_get_cookie(void);
00082 
00083 #else
00084 
00085 static inline void inotify_inode_queue_event(struct inode *inode,
00086                                              __u32 mask, __u32 cookie,
00087                                              const char *filename)
00088 {
00089 }
00090 
00091 static inline void inotify_dentry_parent_queue_event(struct dentry *dentry,
00092                                                      __u32 mask, __u32 cookie,
00093                                                      const char *filename)
00094 {
00095 }
00096 
00097 static inline void inotify_super_block_umount(struct super_block *sb)
00098 {
00099 }
00100 
00101 static inline void inotify_inode_is_dead(struct inode *inode)
00102 {
00103 }
00104 
00105 static inline u32 inotify_get_cookie(void)
00106 {
00107         return 0;
00108 }
00109 
00110 #endif  /* CONFIG_INOTIFY */
00111 
00112 #endif  /* __KERNEL __ */
00113 
00114 #endif  /* _LINUX_INOTIFY_H */

Generated on Sat Nov 5 16:16:07 2005 for OPIE by  doxygen 1.4.2