@@ -40,31 +40,45 @@ struct fanotify_fh {
40
40
struct fanotify_info {
41
41
/* size of dir_fh/file_fh including fanotify_fh hdr size */
42
42
u8 dir_fh_totlen ;
43
+ u8 dir2_fh_totlen ;
43
44
u8 file_fh_totlen ;
44
45
u8 name_len ;
45
- u8 pad ;
46
+ u8 name2_len ;
47
+ u8 pad [3 ];
46
48
unsigned char buf [];
47
49
/*
48
50
* (struct fanotify_fh) dir_fh starts at buf[0]
49
- * (optional) file_fh starts at buf[dir_fh_totlen]
50
- * name starts at buf[dir_fh_totlen + file_fh_totlen]
51
+ * (optional) dir2_fh starts at buf[dir_fh_totlen]
52
+ * (optional) file_fh starts at buf[dir_fh_totlen + dir2_fh_totlen]
53
+ * name starts at buf[dir_fh_totlen + dir2_fh_totlen + file_fh_totlen]
54
+ * ...
51
55
*/
52
56
#define FANOTIFY_DIR_FH_SIZE (info ) ((info)->dir_fh_totlen)
57
+ #define FANOTIFY_DIR2_FH_SIZE (info ) ((info)->dir2_fh_totlen)
53
58
#define FANOTIFY_FILE_FH_SIZE (info ) ((info)->file_fh_totlen)
54
59
#define FANOTIFY_NAME_SIZE (info ) ((info)->name_len + 1)
60
+ #define FANOTIFY_NAME2_SIZE (info ) ((info)->name2_len + 1)
55
61
56
62
#define FANOTIFY_DIR_FH_OFFSET (info ) 0
57
- #define FANOTIFY_FILE_FH_OFFSET (info ) \
63
+ #define FANOTIFY_DIR2_FH_OFFSET (info ) \
58
64
(FANOTIFY_DIR_FH_OFFSET(info) + FANOTIFY_DIR_FH_SIZE(info))
65
+ #define FANOTIFY_FILE_FH_OFFSET (info ) \
66
+ (FANOTIFY_DIR2_FH_OFFSET(info) + FANOTIFY_DIR2_FH_SIZE(info))
59
67
#define FANOTIFY_NAME_OFFSET (info ) \
60
68
(FANOTIFY_FILE_FH_OFFSET(info) + FANOTIFY_FILE_FH_SIZE(info))
69
+ #define FANOTIFY_NAME2_OFFSET (info ) \
70
+ (FANOTIFY_NAME_OFFSET(info) + FANOTIFY_NAME_SIZE(info))
61
71
62
72
#define FANOTIFY_DIR_FH_BUF (info ) \
63
73
((info)->buf + FANOTIFY_DIR_FH_OFFSET(info))
74
+ #define FANOTIFY_DIR2_FH_BUF (info ) \
75
+ ((info)->buf + FANOTIFY_DIR2_FH_OFFSET(info))
64
76
#define FANOTIFY_FILE_FH_BUF (info ) \
65
77
((info)->buf + FANOTIFY_FILE_FH_OFFSET(info))
66
78
#define FANOTIFY_NAME_BUF (info ) \
67
79
((info)->buf + FANOTIFY_NAME_OFFSET(info))
80
+ #define FANOTIFY_NAME2_BUF (info ) \
81
+ ((info)->buf + FANOTIFY_NAME2_OFFSET(info))
68
82
} __aligned (4 );
69
83
70
84
static inline bool fanotify_fh_has_ext_buf (struct fanotify_fh * fh )
@@ -106,6 +120,20 @@ static inline struct fanotify_fh *fanotify_info_dir_fh(struct fanotify_info *inf
106
120
return (struct fanotify_fh * )FANOTIFY_DIR_FH_BUF (info );
107
121
}
108
122
123
+ static inline int fanotify_info_dir2_fh_len (struct fanotify_info * info )
124
+ {
125
+ if (!info -> dir2_fh_totlen ||
126
+ WARN_ON_ONCE (info -> dir2_fh_totlen < FANOTIFY_FH_HDR_LEN ))
127
+ return 0 ;
128
+
129
+ return info -> dir2_fh_totlen - FANOTIFY_FH_HDR_LEN ;
130
+ }
131
+
132
+ static inline struct fanotify_fh * fanotify_info_dir2_fh (struct fanotify_info * info )
133
+ {
134
+ return (struct fanotify_fh * )FANOTIFY_DIR2_FH_BUF (info );
135
+ }
136
+
109
137
static inline int fanotify_info_file_fh_len (struct fanotify_info * info )
110
138
{
111
139
if (!info -> file_fh_totlen ||
@@ -128,31 +156,55 @@ static inline char *fanotify_info_name(struct fanotify_info *info)
128
156
return FANOTIFY_NAME_BUF (info );
129
157
}
130
158
159
+ static inline char * fanotify_info_name2 (struct fanotify_info * info )
160
+ {
161
+ if (!info -> name2_len )
162
+ return NULL ;
163
+
164
+ return FANOTIFY_NAME2_BUF (info );
165
+ }
166
+
131
167
static inline void fanotify_info_init (struct fanotify_info * info )
132
168
{
133
169
BUILD_BUG_ON (FANOTIFY_FH_HDR_LEN + MAX_HANDLE_SZ > U8_MAX );
134
170
BUILD_BUG_ON (NAME_MAX > U8_MAX );
135
171
136
172
info -> dir_fh_totlen = 0 ;
173
+ info -> dir2_fh_totlen = 0 ;
137
174
info -> file_fh_totlen = 0 ;
138
175
info -> name_len = 0 ;
176
+ info -> name2_len = 0 ;
139
177
}
140
178
141
179
/* These set/copy helpers MUST be called by order */
142
180
static inline void fanotify_info_set_dir_fh (struct fanotify_info * info ,
143
181
unsigned int totlen )
144
182
{
145
- if (WARN_ON_ONCE (info -> file_fh_totlen > 0 ) ||
146
- WARN_ON_ONCE (info -> name_len > 0 ))
183
+ if (WARN_ON_ONCE (info -> dir2_fh_totlen > 0 ) ||
184
+ WARN_ON_ONCE (info -> file_fh_totlen > 0 ) ||
185
+ WARN_ON_ONCE (info -> name_len > 0 ) ||
186
+ WARN_ON_ONCE (info -> name2_len > 0 ))
147
187
return ;
148
188
149
189
info -> dir_fh_totlen = totlen ;
150
190
}
151
191
192
+ static inline void fanotify_info_set_dir2_fh (struct fanotify_info * info ,
193
+ unsigned int totlen )
194
+ {
195
+ if (WARN_ON_ONCE (info -> file_fh_totlen > 0 ) ||
196
+ WARN_ON_ONCE (info -> name_len > 0 ) ||
197
+ WARN_ON_ONCE (info -> name2_len > 0 ))
198
+ return ;
199
+
200
+ info -> dir2_fh_totlen = totlen ;
201
+ }
202
+
152
203
static inline void fanotify_info_set_file_fh (struct fanotify_info * info ,
153
204
unsigned int totlen )
154
205
{
155
- if (WARN_ON_ONCE (info -> name_len > 0 ))
206
+ if (WARN_ON_ONCE (info -> name_len > 0 ) ||
207
+ WARN_ON_ONCE (info -> name2_len > 0 ))
156
208
return ;
157
209
158
210
info -> file_fh_totlen = totlen ;
@@ -161,13 +213,24 @@ static inline void fanotify_info_set_file_fh(struct fanotify_info *info,
161
213
static inline void fanotify_info_copy_name (struct fanotify_info * info ,
162
214
const struct qstr * name )
163
215
{
164
- if (WARN_ON_ONCE (name -> len > NAME_MAX ))
216
+ if (WARN_ON_ONCE (name -> len > NAME_MAX ) ||
217
+ WARN_ON_ONCE (info -> name2_len > 0 ))
165
218
return ;
166
219
167
220
info -> name_len = name -> len ;
168
221
strcpy (fanotify_info_name (info ), name -> name );
169
222
}
170
223
224
+ static inline void fanotify_info_copy_name2 (struct fanotify_info * info ,
225
+ const struct qstr * name )
226
+ {
227
+ if (WARN_ON_ONCE (name -> len > NAME_MAX ))
228
+ return ;
229
+
230
+ info -> name2_len = name -> len ;
231
+ strcpy (fanotify_info_name2 (info ), name -> name );
232
+ }
233
+
171
234
/*
172
235
* Common structure for fanotify events. Concrete structs are allocated in
173
236
* fanotify_handle_event() and freed when the information is retrieved by
0 commit comments