]>
Commit | Line | Data |
---|---|---|
2d21ac55 A |
1 | /* |
2 | * Copyright (c) 2000-2006 Apple Computer, Inc. All rights reserved. | |
3 | * | |
4 | * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ | |
5 | * | |
6 | * This file contains Original Code and/or Modifications of Original Code | |
7 | * as defined in and that are subject to the Apple Public Source License | |
8 | * Version 2.0 (the 'License'). You may not use this file except in | |
9 | * compliance with the License. The rights granted to you under the License | |
10 | * may not be used to create, or enable the creation or redistribution of, | |
11 | * unlawful or unlicensed copies of an Apple operating system, or to | |
12 | * circumvent, violate, or enable the circumvention or violation of, any | |
13 | * terms of an Apple operating system software license agreement. | |
14 | * | |
15 | * Please obtain a copy of the License at | |
16 | * http://www.opensource.apple.com/apsl/ and read it before using this file. | |
17 | * | |
18 | * The Original Code and all software distributed under the License are | |
19 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER | |
20 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, | |
21 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, | |
22 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. | |
23 | * Please see the License for the specific language governing rights and | |
24 | * limitations under the License. | |
25 | * | |
26 | * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ | |
27 | */ | |
91447636 A |
28 | #ifndef FSEVENT_H |
29 | #define FSEVENT_H 1 | |
30 | ||
31 | // Event types that you can ask to listen for | |
32 | #define FSE_INVALID -1 | |
33 | #define FSE_CREATE_FILE 0 | |
34 | #define FSE_DELETE 1 | |
35 | #define FSE_STAT_CHANGED 2 | |
36 | #define FSE_RENAME 3 | |
37 | #define FSE_CONTENT_MODIFIED 4 | |
38 | #define FSE_EXCHANGE 5 | |
39 | #define FSE_FINDER_INFO_CHANGED 6 | |
40 | #define FSE_CREATE_DIR 7 | |
41 | #define FSE_CHOWN 8 | |
2d21ac55 A |
42 | #define FSE_XATTR_MODIFIED 9 |
43 | #define FSE_XATTR_REMOVED 10 | |
22ba694c A |
44 | #define FSE_DOCID_CREATED 11 |
45 | #define FSE_DOCID_CHANGED 12 | |
91447636 | 46 | |
22ba694c | 47 | #define FSE_MAX_EVENTS 13 |
91447636 A |
48 | #define FSE_ALL_EVENTS 998 |
49 | ||
50 | #define FSE_EVENTS_DROPPED 999 | |
51 | ||
2d21ac55 A |
52 | // |
53 | // These defines only apply if you've asked for extended | |
54 | // type info. In that case the type field's low 12-bits | |
55 | // contain the basic types defined above and the top 4 | |
56 | // bits contain flags that indicate if an event had other | |
57 | // events combined with it or if it represents a directory | |
58 | // that has dropped events below it. | |
59 | // | |
60 | #define FSE_TYPE_MASK 0x0fff | |
61 | #define FSE_FLAG_MASK 0xf000 | |
62 | #define FSE_FLAG_SHIFT 12 | |
63 | #define FSE_GET_FLAGS(type) (((type) >> 12) & 0x000f) | |
64 | ||
65 | #define FSE_COMBINED_EVENTS 0x0001 | |
66 | #define FSE_CONTAINS_DROPPED_EVENTS 0x0002 | |
67 | ||
68 | ||
91447636 A |
69 | // Actions for each event type |
70 | #define FSE_IGNORE 0 | |
71 | #define FSE_REPORT 1 | |
72 | #define FSE_ASK 2 // Not implemented yet | |
73 | ||
74 | // The types of each of the arguments for an event | |
75 | // Each type is followed by the size and then the | |
76 | // data. FSE_ARG_VNODE is just a path string | |
77 | #define FSE_ARG_VNODE 0x0001 // next arg is a vnode pointer | |
78 | #define FSE_ARG_STRING 0x0002 // next arg is length followed by string ptr | |
79 | #define FSE_ARG_PATH 0x0003 // next arg is a full path | |
80 | #define FSE_ARG_INT32 0x0004 // next arg is a 32-bit int | |
81 | #define FSE_ARG_INT64 0x0005 // next arg is a 64-bit int | |
82 | #define FSE_ARG_RAW 0x0006 // next arg is a length followed by a void ptr | |
83 | #define FSE_ARG_INO 0x0007 // next arg is the inode number (ino_t) | |
84 | #define FSE_ARG_UID 0x0008 // next arg is the file's uid (uid_t) | |
85 | #define FSE_ARG_DEV 0x0009 // next arg is the file's dev_t | |
86 | #define FSE_ARG_MODE 0x000a // next arg is the file's mode (as an int32, file type only) | |
87 | #define FSE_ARG_GID 0x000b // next arg is the file's gid (gid_t) | |
2d21ac55 | 88 | #define FSE_ARG_FINFO 0x000c // next arg is a packed finfo (dev, ino, mode, uid, gid) |
91447636 A |
89 | #define FSE_ARG_DONE 0xb33f // no more arguments |
90 | ||
91 | #define FSE_MAX_ARGS 12 | |
92 | ||
2d21ac55 A |
93 | // |
94 | // These are special bits that be set in the 32-bit mode | |
95 | // field that /dev/fsevents provides. | |
96 | // | |
97 | #define FSE_MODE_HLINK (1 << 31) // notification is for a hard-link | |
98 | #define FSE_MODE_LAST_HLINK (1 << 30) // link count == 0 on a hard-link delete | |
b0d623f7 A |
99 | #define FSE_REMOTE_DIR_EVENT (1 << 29) // this is a remotely generated directory-level granularity event |
100 | #define FSE_TRUNCATED_PATH (1 << 28) // the path for this item had to be truncated | |
91447636 A |
101 | |
102 | // ioctl's on /dev/fsevents | |
b0d623f7 | 103 | #if __LP64__ |
2d21ac55 A |
104 | typedef struct fsevent_clone_args { |
105 | int8_t *event_list; | |
106 | int32_t num_events; | |
107 | int32_t event_queue_depth; | |
108 | int32_t *fd; | |
109 | } fsevent_clone_args; | |
110 | #else | |
91447636 A |
111 | typedef struct fsevent_clone_args { |
112 | int8_t *event_list; | |
2d21ac55 | 113 | int32_t pad1; |
91447636 A |
114 | int32_t num_events; |
115 | int32_t event_queue_depth; | |
116 | int32_t *fd; | |
2d21ac55 | 117 | int32_t pad2; |
91447636 | 118 | } fsevent_clone_args; |
2d21ac55 | 119 | #endif |
91447636 | 120 | |
2d21ac55 | 121 | #define FSEVENTS_CLONE _IOW('s', 1, fsevent_clone_args) |
91447636 A |
122 | |
123 | ||
124 | // ioctl's on the cloned fd | |
b0d623f7 A |
125 | #if __LP64__ |
126 | #pragma pack(push, 4) | |
2d21ac55 A |
127 | typedef struct fsevent_dev_filter_args { |
128 | uint32_t num_devices; | |
129 | dev_t *devices; | |
130 | } fsevent_dev_filter_args; | |
b0d623f7 | 131 | #pragma pack(pop) |
2d21ac55 | 132 | #else |
91447636 A |
133 | typedef struct fsevent_dev_filter_args { |
134 | uint32_t num_devices; | |
135 | dev_t *devices; | |
2d21ac55 | 136 | int32_t pad1; |
91447636 | 137 | } fsevent_dev_filter_args; |
2d21ac55 | 138 | #endif |
91447636 | 139 | |
2d21ac55 A |
140 | #define FSEVENTS_DEVICE_FILTER _IOW('s', 100, fsevent_dev_filter_args) |
141 | #define FSEVENTS_WANT_COMPACT_EVENTS _IO('s', 101) | |
142 | #define FSEVENTS_WANT_EXTENDED_INFO _IO('s', 102) | |
b0d623f7 | 143 | #define FSEVENTS_GET_CURRENT_ID _IOR('s', 103, uint64_t) |
91447636 A |
144 | |
145 | ||
146 | #ifdef KERNEL | |
147 | ||
2d21ac55 | 148 | void fsevents_init(void); |
91447636 A |
149 | int need_fsevent(int type, vnode_t vp); |
150 | int add_fsevent(int type, vfs_context_t, ...); | |
151 | void fsevent_unmount(struct mount *mp); | |
b0d623f7 A |
152 | struct vnode_attr; |
153 | void create_fsevent_from_kevent(vnode_t vp, uint32_t kevents, struct vnode_attr *vap); | |
91447636 A |
154 | |
155 | // misc utility functions for fsevent info and pathbuffers... | |
156 | typedef struct fse_info { | |
2d21ac55 | 157 | ino64_t ino; |
91447636 | 158 | dev_t dev; |
91447636 A |
159 | int32_t mode; // note: this is not a mode_t (it's 32-bits, not 16) |
160 | uid_t uid; | |
161 | gid_t gid; | |
2d21ac55 | 162 | uint64_t nlink; // only filled in if the vnode is marked as a hardlink |
91447636 A |
163 | } fse_info; |
164 | ||
165 | int get_fse_info(struct vnode *vp, fse_info *fse, vfs_context_t ctx); | |
6d2010ae | 166 | int vnode_get_fse_info_from_vap(vnode_t vp, fse_info *fse, struct vnode_attr *vap); |
91447636 A |
167 | |
168 | char *get_pathbuff(void); | |
169 | void release_pathbuff(char *path); | |
170 | ||
171 | #endif /* KERNEL */ | |
172 | ||
173 | #endif /* FSEVENT_H */ |