15
15
/*
16
16
* This is also regression test for:
17
17
* c285a2f01d69 ("fanotify: update connector fsid cache on add mark")
18
+ *
19
+ * The test variants 1-2 are regression tests for:
20
+ * bc2473c90fca ("ovl: enable fsnotify events on underlying real files")
21
+ *
22
+ * The test variants 3-4 are tests for overlay fid events supprted since v6.6:
23
+ * 16aac5ad1fa9 ("ovl: support encoding non-decodable file handles")
24
+ *
25
+ * The last test case for FAN_DELETE_SELF is a regression test for:
26
+ * c45beebfde34a ("ovl: support encoding fid from inode with no alias")
18
27
*/
19
28
20
29
#define _GNU_SOURCE
@@ -86,7 +95,12 @@ static struct test_case_t {
86
95
{
87
96
INIT_FANOTIFY_MARK_TYPE (FILESYSTEM ),
88
97
FAN_OPEN | FAN_CLOSE_NOWRITE | FAN_ONDIR
89
- }
98
+ },
99
+ /* Keep this test case last because it deletes the test files */
100
+ {
101
+ INIT_FANOTIFY_MARK_TYPE (INODE ),
102
+ FAN_DELETE_SELF | FAN_ONDIR
103
+ },
90
104
};
91
105
92
106
static int ovl_mounted ;
@@ -111,6 +125,18 @@ static void create_objects(void)
111
125
}
112
126
}
113
127
128
+ static void delete_objects (void )
129
+ {
130
+ unsigned int i ;
131
+
132
+ for (i = 0 ; i < ARRAY_SIZE (objects ); i ++ ) {
133
+ if (objects [i ].is_dir )
134
+ SAFE_RMDIR (objects [i ].path );
135
+ else
136
+ SAFE_UNLINK (objects [i ].path );
137
+ }
138
+ }
139
+
114
140
static void get_object_stats (void )
115
141
{
116
142
unsigned int i ;
@@ -155,8 +181,10 @@ static void do_test(unsigned int number)
155
181
struct fanotify_mark_type * mark = & tc -> mark ;
156
182
157
183
tst_res (TINFO ,
158
- "Test #%d.%d: FAN_REPORT_FID with mark flag: %s" ,
159
- number , tst_variant , mark -> name );
184
+ "Test #%d.%d: FAN_REPORT_FID of %s events with mark type %s" ,
185
+ number , tst_variant ,
186
+ (tc -> mask & FAN_DELETE_SELF ) ? "delete" : "open/close" ,
187
+ mark -> name );
160
188
161
189
if (tst_variant && !ovl_mounted ) {
162
190
tst_res (TCONF , "overlayfs not supported on %s" , tst_device -> fs_type );
@@ -184,23 +212,40 @@ static void do_test(unsigned int number)
184
212
tst_res (TCONF , "overlayfs base fs cannot be watched with mount mark" );
185
213
goto out ;
186
214
}
215
+ if (tc -> mask & FAN_DELETE_SELF ) {
216
+ /* The eviction of base fs inodes is defered due to overlay held reference */
217
+ tst_res (TCONF , "overlayfs base fs cannot be watched for delete self events" );
218
+ goto out ;
219
+ }
187
220
SAFE_MOUNT (OVL_MNT , MOUNT_PATH , "none" , MS_BIND , NULL );
188
221
}
189
222
190
223
/* Generate sequence of FAN_OPEN events on objects */
191
- for (i = 0 ; i < ARRAY_SIZE (objects ); i ++ )
192
- fds [i ] = SAFE_OPEN (objects [i ].path , O_RDONLY );
224
+ if (tc -> mask & FAN_OPEN ) {
225
+ for (i = 0 ; i < ARRAY_SIZE (objects ); i ++ )
226
+ fds [i ] = SAFE_OPEN (objects [i ].path , O_RDONLY );
227
+ }
193
228
194
229
/*
195
- * Generate sequence of FAN_CLOSE_NOWRITE events on objects. Each
196
- * FAN_CLOSE_NOWRITE event is expected to be merged with its
197
- * respective FAN_OPEN event that was performed on the same object.
230
+ * Generate sequence of FAN_CLOSE_NOWRITE events on objects.
231
+ * Each FAN_CLOSE_NOWRITE event is expected to be merged with the
232
+ * respective FAN_OPEN event that was reported on the same object.
198
233
*/
199
- for (i = 0 ; i < ARRAY_SIZE (objects ); i ++ ) {
200
- if (fds [i ] > 0 )
201
- SAFE_CLOSE (fds [i ]);
234
+ if (tc -> mask & FAN_CLOSE ) {
235
+ for (i = 0 ; i < ARRAY_SIZE (objects ); i ++ ) {
236
+ if (fds [i ] > 0 )
237
+ SAFE_CLOSE (fds [i ]);
238
+ }
202
239
}
203
240
241
+ /*
242
+ * Generate sequence of FAN_DELETE_SELF events on objects.
243
+ * Each FAN_DELETE_SELF event is expected to be merged with the
244
+ * respective OPEN/CLOSE events that were reported on the same object.
245
+ */
246
+ if (tc -> mask & FAN_DELETE_SELF )
247
+ delete_objects ();
248
+
204
249
if (tst_variant && !ovl_bind_mounted )
205
250
SAFE_UMOUNT (MOUNT_PATH );
206
251
@@ -392,6 +437,7 @@ static struct tst_test test = {
392
437
.tags = (const struct tst_tag []) {
393
438
{"linux-git" , "c285a2f01d69" },
394
439
{"linux-git" , "bc2473c90fca" },
440
+ {"linux-git" , "c45beebfde34a" },
395
441
{}
396
442
}
397
443
};
0 commit comments