1 /*
2 * Copyright (c) International Business Machines Corp., 2004
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
12 * the GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17 */
18
19 /*
20 * TEST CASE : event_sn.c
21 *
22 * VARIATIONS : 20
23 *
24 * EVENTS TESTED: DM_EVENT_CREATE
25 * DM_EVENT_REMOVE
26 * DM_EVENT_RENAME
27 * DM_EVENT_SYMLINK
28 * DM_EVENT_LINK
29 */
30 #include <string.h>
31 #include <stdio.h>
32 #include <stdlib.h>
33 #include <errno.h>
34 #include <pthread.h>
35 #include <unistd.h>
36 #include <sys/stat.h>
37 #include <sys/mount.h>
38 #include <fcntl.h>
39 #include "dm_test.h"
40
41 pthread_t tid;
42 dm_sessid_t sid;
43 char dmMsgBuf[4096];
44 char command[4096];
45 char *mountPt;
46 char *deviceNm;
47 char DummyFile[FILENAME_MAX];
48 char DummyFile2[FILENAME_MAX];
49 char DummySubdir[FILENAME_MAX];
50 char DummySubdir2[FILENAME_MAX];
51 char DummyLink[FILENAME_MAX];
52
53 /* Variables for thread communications */
54 dm_eventtype_t eventExpected;
55 dm_eventtype_t eventReceived;
56 dm_response_t eventResponse;
57 void *hanp1, *hanp2;
58 size_t hlen1, hlen2;
59 char name1[FILENAME_MAX], name2[FILENAME_MAX];
60 dm_mode_t mode;
61
62 void *Thread(void *);
63
main(int argc,char ** argv)64 int main(int argc, char **argv)
65 {
66
67 char *varstr;
68 int rc;
69 int varStatus;
70 char *szSessionInfo = "dm_test session info";
71 dm_eventset_t events;
72
73 DMOPT_PARSE(argc, argv);
74 DMLOG_START();
75
76 DMEV_ZERO(events);
77 DMEV_SET(DM_EVENT_MOUNT, events);
78
79 /* CANNOT DO ANYTHING WITHOUT SUCCESSFUL INITIALIZATION!!! */
80 if ((rc = dm_init_service(&varstr)) != 0) {
81 DMLOG_PRINT(DMLVL_ERR,
82 "dm_init_service failed! (rc = %d, errno = %d)\n",
83 rc, errno);
84 DM_EXIT();
85 } else if ((rc = dm_create_session(DM_NO_SESSION, szSessionInfo, &sid))
86 == -1) {
87 DMLOG_PRINT(DMLVL_ERR,
88 "dm_create_session failed! (rc = %d, errno = %d)\n",
89 rc, errno);
90 DM_EXIT();
91 } else
92 if ((rc =
93 dm_set_disp(sid, DM_GLOBAL_HANP, DM_GLOBAL_HLEN, DM_NO_TOKEN,
94 &events, DM_EVENT_MAX)) == -1) {
95 DMLOG_PRINT(DMLVL_ERR,
96 "dm_set_disp failed! (rc = %d, errno = %d)\n", rc,
97 errno);
98 dm_destroy_session(sid);
99 DM_EXIT();
100 } else if ((rc = pthread_create(&tid, NULL, Thread, NULL)) != 0) {
101 DMLOG_PRINT(DMLVL_ERR,
102 "pthread_create failed! (rc = %d, errno = %d)\n",
103 rc, errno);
104 dm_destroy_session(sid);
105 DM_EXIT();
106 } else if ((rc = dmimpl_mount(&mountPt, &deviceNm)) == -1) {
107 DMLOG_PRINT(DMLVL_ERR,
108 "dmimpl_mount failed! (rc = %d, errno = %d)\n", rc,
109 errno);
110 dm_destroy_session(sid);
111 DM_EXIT();
112 } else {
113 sprintf(DummyFile, "%s/%s", mountPt, DUMMY_FILE);
114 sprintf(DummyFile2, "%s/%s", mountPt, DUMMY_FILE2);
115 sprintf(DummySubdir, "%s/%s", mountPt, DUMMY_SUBDIR);
116 sprintf(DummySubdir2, "%s/%s", mountPt, DUMMY_SUBDIR2);
117 sprintf(DummyLink, "%s/%s", mountPt, DUMMY_LINK);
118
119 remove(DummyFile);
120 remove(DummyFile2);
121 unlink(DummyLink);
122 rmdir(DummySubdir);
123 rmdir(DummySubdir2);
124 }
125
126 DMLOG_PRINT(DMLVL_DEBUG,
127 "Starting DMAPI synchronous namespace event tests\n");
128
129 /*
130 * TEST : mkdir - DM_RESP_CONTINUE
131 * EXPECTED: DM_EVENT_CREATE
132 */
133 if (DMVAR_EXEC(DIR_SYNC_NAMESP_EVENT_BASE + 1)) {
134 dm_ino_t ino;
135
136 /* Variation set up */
137 eventExpected = DM_EVENT_CREATE;
138 eventReceived = DM_EVENT_INVALID;
139 eventResponse = DM_RESP_CONTINUE;
140
141 /* Variation */
142 EVENT_DELIVERY_DELAY;
143 DMLOG_PRINT(DMLVL_DEBUG, "mkdir(%s)\n", DummySubdir);
144 rc = mkdir(DummySubdir, DUMMY_DIR_RW_MODE);
145 DMLOG_PRINT(DMLVL_DEBUG, "mkdir(%s) returned %d\n", DummySubdir,
146 rc);
147 if ((varStatus =
148 DMVAR_CHKPASSEXP(0, rc, eventExpected,
149 eventReceived)) == DMSTAT_PASS) {
150 rc = dm_handle_to_ino(hanp1, hlen1, &ino);
151 if (rc == -1) {
152 DMLOG_PRINT(DMLVL_ERR,
153 "Unable to obtain inode!\n");
154 varStatus = DMSTAT_FAIL;
155 } else if (ino != ROOT_INODE) {
156 DMLOG_PRINT(DMLVL_ERR,
157 "Parent handle NOT root! (%lld vs %d)\n",
158 ino, ROOT_INODE);
159 varStatus = DMSTAT_FAIL;
160 } else if (strcmp(name1, DUMMY_SUBDIR) != 0) {
161 DMLOG_PRINT(DMLVL_ERR,
162 "Entry name NOT correct! (%s vs %s)\n",
163 name1, DUMMY_SUBDIR);
164 varStatus = DMSTAT_FAIL;
165 }
166 }
167 DMVAR_END(varStatus);
168
169 /* Variation clean up */
170 EVENT_DELIVERY_DELAY;
171 rc = rmdir(DummySubdir);
172 if (rc == -1) {
173 DMLOG_PRINT(DMLVL_DEBUG,
174 "Unable to clean up variation! (errno = %d)\n",
175 errno);
176 }
177 }
178
179 /*
180 * TEST : mkdir - DM_RESP_ABORT
181 * EXPECTED: DM_EVENT_CREATE
182 */
183 if (DMVAR_EXEC(DIR_SYNC_NAMESP_EVENT_BASE + 2)) {
184 dm_ino_t ino;
185
186 /* Variation set up */
187 eventExpected = DM_EVENT_CREATE;
188 eventReceived = DM_EVENT_INVALID;
189 eventResponse = DM_RESP_ABORT;
190
191 /* Variation */
192 EVENT_DELIVERY_DELAY;
193 DMLOG_PRINT(DMLVL_DEBUG, "mkdir(%s)\n", DummySubdir);
194 rc = mkdir(DummySubdir, DUMMY_DIR_RW_MODE);
195 DMLOG_PRINT(DMLVL_DEBUG, "mkdir(%s) returned %d\n", DummySubdir,
196 rc);
197 if ((varStatus =
198 DMVAR_CHKFAILEXP(-1, rc, ABORT_ERRNO, eventExpected,
199 eventReceived)) == DMSTAT_PASS) {
200 rc = dm_handle_to_ino(hanp1, hlen1, &ino);
201 if (rc == -1) {
202 DMLOG_PRINT(DMLVL_ERR,
203 "Unable to obtain inode!\n");
204 varStatus = DMSTAT_FAIL;
205 } else if (ino != ROOT_INODE) {
206 DMLOG_PRINT(DMLVL_ERR,
207 "Parent handle NOT root! (%lld vs %d)\n",
208 ino, ROOT_INODE);
209 varStatus = DMSTAT_FAIL;
210 } else if (strcmp(name1, DUMMY_SUBDIR) != 0) {
211 DMLOG_PRINT(DMLVL_ERR,
212 "Entry name NOT correct! (%s vs %s)\n",
213 name1, DUMMY_SUBDIR);
214 varStatus = DMSTAT_FAIL;
215 }
216 }
217 DMVAR_END(varStatus);
218
219 /* Variation clean up */
220 }
221
222 /*
223 * TEST : rmdir - DM_RESP_CONTINUE
224 * EXPECTED: DM_EVENT_REMOVE
225 */
226 if (DMVAR_EXEC(DIR_SYNC_NAMESP_EVENT_BASE + 3)) {
227 dm_ino_t ino;
228
229 /* Variation set up */
230 eventExpected = DM_EVENT_REMOVE;
231 eventReceived = DM_EVENT_INVALID;
232 eventResponse = DM_RESP_CONTINUE;
233 EVENT_DELIVERY_DELAY;
234 rc = mkdir(DummySubdir, DUMMY_DIR_RW_MODE);
235 if (rc == -1) {
236 DMLOG_PRINT(DMLVL_DEBUG,
237 "Unable to set up variation! (errno = %d)\n",
238 errno);
239 DMVAR_SKIP();
240 } else {
241 /* Variation */
242 EVENT_DELIVERY_DELAY;
243 DMLOG_PRINT(DMLVL_DEBUG, "rmdir(%s)\n", DummySubdir);
244 rc = rmdir(DummySubdir);
245 DMLOG_PRINT(DMLVL_DEBUG, "rmdir(%s) returned %d\n",
246 DummySubdir, rc);
247 if ((varStatus =
248 DMVAR_CHKPASSEXP(0, rc, eventExpected,
249 eventReceived)) == DMSTAT_PASS) {
250 rc = dm_handle_to_ino(hanp1, hlen1, &ino);
251 if (rc == -1) {
252 DMLOG_PRINT(DMLVL_ERR,
253 "Unable to obtain inode!\n");
254 varStatus = DMSTAT_FAIL;
255 } else if (ino != ROOT_INODE) {
256 DMLOG_PRINT(DMLVL_ERR,
257 "Parent handle NOT root! (%lld vs %d)\n",
258 ino, ROOT_INODE);
259 varStatus = DMSTAT_FAIL;
260 } else if (strcmp(name1, DUMMY_SUBDIR) != 0) {
261 DMLOG_PRINT(DMLVL_ERR,
262 "Entry name NOT correct! (%s vs %s)\n",
263 name1, DUMMY_SUBDIR);
264 varStatus = DMSTAT_FAIL;
265 }
266 }
267 DMVAR_END(varStatus);
268
269 /* Variation clean up */
270 }
271 }
272
273 /*
274 * TEST : rmdir - DM_RESP_ABORT
275 * EXPECTED: DM_EVENT_REMOVE
276 */
277 if (DMVAR_EXEC(DIR_SYNC_NAMESP_EVENT_BASE + 4)) {
278 dm_ino_t ino;
279
280 /* Variation set up */
281 eventExpected = DM_EVENT_REMOVE;
282 eventReceived = DM_EVENT_INVALID;
283 eventResponse = DM_RESP_CONTINUE;
284 EVENT_DELIVERY_DELAY;
285 rc = mkdir(DummySubdir, DUMMY_DIR_RW_MODE);
286 if (rc == -1) {
287 DMLOG_PRINT(DMLVL_DEBUG,
288 "Unable to set up variation! (errno = %d)\n",
289 errno);
290 DMVAR_SKIP();
291 } else {
292 /* Variation */
293 eventResponse = DM_RESP_ABORT;
294 EVENT_DELIVERY_DELAY;
295 DMLOG_PRINT(DMLVL_DEBUG, "rmdir(%s)\n", DummySubdir);
296 rc = rmdir(DummySubdir);
297 DMLOG_PRINT(DMLVL_DEBUG, "rmdir(%s) returned %d\n",
298 DummySubdir, rc);
299 if ((varStatus =
300 DMVAR_CHKFAILEXP(-1, rc, ABORT_ERRNO,
301 eventExpected,
302 eventReceived)) == DMSTAT_PASS) {
303 rc = dm_handle_to_ino(hanp1, hlen1, &ino);
304 if (rc == -1) {
305 DMLOG_PRINT(DMLVL_ERR,
306 "Unable to obtain inode!\n");
307 varStatus = DMSTAT_FAIL;
308 } else if (ino != ROOT_INODE) {
309 DMLOG_PRINT(DMLVL_ERR,
310 "Parent handle NOT root! (%lld vs %d)\n",
311 ino, ROOT_INODE);
312 varStatus = DMSTAT_FAIL;
313 } else if (strcmp(name1, DUMMY_SUBDIR) != 0) {
314 DMLOG_PRINT(DMLVL_ERR,
315 "Entry name NOT correct! (%s vs %s)\n",
316 name1, DUMMY_SUBDIR);
317 varStatus = DMSTAT_FAIL;
318 }
319 }
320 DMVAR_END(varStatus);
321
322 /* Variation clean up */
323 eventResponse = DM_RESP_CONTINUE;
324 EVENT_DELIVERY_DELAY;
325 rc = rmdir(DummySubdir);
326 if (rc == -1) {
327 DMLOG_PRINT(DMLVL_DEBUG,
328 "Unable to clean up variation! (errno = %d)\n",
329 errno);
330 }
331 }
332 }
333
334 /*
335 * TEST : mv - DM_RESP_CONTINUE
336 * EXPECTED: DM_EVENT_RENAME
337 */
338 if (DMVAR_EXEC(DIR_SYNC_NAMESP_EVENT_BASE + 5)) {
339 dm_ino_t ino1, ino2;
340
341 /* Variation set up */
342 eventExpected = DM_EVENT_RENAME;
343 eventReceived = DM_EVENT_INVALID;
344 eventResponse = DM_RESP_CONTINUE;
345 sprintf(command, "mv %s %s", DummySubdir, DummySubdir2);
346 EVENT_DELIVERY_DELAY;
347 rc = mkdir(DummySubdir, DUMMY_DIR_RW_MODE);
348 if (rc == -1) {
349 DMLOG_PRINT(DMLVL_DEBUG,
350 "Unable to set up variation! (errno = %d)\n",
351 errno);
352 DMVAR_SKIP();
353 } else {
354 /* Variation */
355 EVENT_DELIVERY_DELAY;
356 DMLOG_PRINT(DMLVL_DEBUG, "system(mv %s %s)\n",
357 DummySubdir, DummySubdir2);
358 rc = system(command);
359 DMLOG_PRINT(DMLVL_DEBUG,
360 "system(mv %s %s) returned %d\n",
361 DummySubdir, DummySubdir2, rc);
362 if ((varStatus =
363 DMVAR_CHKPASSEXP(0, rc, eventExpected,
364 eventReceived)) == DMSTAT_PASS) {
365 rc = dm_handle_to_ino(hanp1, hlen1, &ino1);
366 rc |= dm_handle_to_ino(hanp2, hlen2, &ino2);
367 if (rc == -1) {
368 DMLOG_PRINT(DMLVL_ERR,
369 "Unable to obtain inode!\n");
370 varStatus = DMSTAT_FAIL;
371 } else if (ino1 != ROOT_INODE) {
372 DMLOG_PRINT(DMLVL_ERR,
373 "Old parent handle NOT root! (%lld vs %d)\n",
374 ino1, ROOT_INODE);
375 varStatus = DMSTAT_FAIL;
376 } else if (ino2 != ROOT_INODE) {
377 DMLOG_PRINT(DMLVL_ERR,
378 "New parent handle NOT root! (%lld vs %d)\n",
379 ino2, ROOT_INODE);
380 varStatus = DMSTAT_FAIL;
381 } else
382 if (dm_handle_cmp
383 (hanp1, hlen1, hanp2, hlen2) != 0) {
384 DMLOG_PRINT(DMLVL_ERR,
385 "Old parent handle NOT equal to new parent handle!\n");
386 varStatus = DMSTAT_FAIL;
387 } else if (strcmp(name1, DUMMY_SUBDIR) != 0) {
388 DMLOG_PRINT(DMLVL_ERR,
389 "Old entry name NOT correct! (%s vs %s)\n",
390 name1, DUMMY_SUBDIR);
391 varStatus = DMSTAT_FAIL;
392 } else if (strcmp(name2, DUMMY_SUBDIR2) != 0) {
393 DMLOG_PRINT(DMLVL_ERR,
394 "New entry name NOT correct! (%s vs %s)\n",
395 name2, DUMMY_SUBDIR2);
396 varStatus = DMSTAT_FAIL;
397 }
398 }
399 DMVAR_END(varStatus);
400
401 /* Variation clean up */
402 EVENT_DELIVERY_DELAY;
403 rc = rmdir(DummySubdir2);
404 if (rc == -1) {
405 DMLOG_PRINT(DMLVL_DEBUG,
406 "Unable to clean up variation! (errno = %d)\n",
407 errno);
408 }
409 }
410 }
411
412 /*
413 * TEST : mv - DM_RESP_ABORT
414 * EXPECTED: DM_EVENT_RENAME
415 */
416 if (DMVAR_EXEC(DIR_SYNC_NAMESP_EVENT_BASE + 6)) {
417 dm_ino_t ino1, ino2;
418
419 /* Variation set up */
420 eventExpected = DM_EVENT_RENAME;
421 eventReceived = DM_EVENT_INVALID;
422 eventResponse = DM_RESP_CONTINUE;
423 sprintf(command, "mv %s %s", DummySubdir, DummySubdir2);
424 EVENT_DELIVERY_DELAY;
425 rc = mkdir(DummySubdir, DUMMY_DIR_RW_MODE);
426 if (rc == -1) {
427 DMLOG_PRINT(DMLVL_DEBUG,
428 "Unable to set up variation! (errno = %d)\n",
429 errno);
430 DMVAR_SKIP();
431 } else {
432 /* Variation */
433 eventResponse = DM_RESP_ABORT;
434 EVENT_DELIVERY_DELAY;
435 DMLOG_PRINT(DMLVL_DEBUG, "system(mv %s %s)\n",
436 DummySubdir, DummySubdir2);
437 rc = system(command);
438 DMLOG_PRINT(DMLVL_DEBUG,
439 "system(mv %s %s) returned %d\n",
440 DummySubdir, DummySubdir2, rc);
441 if ((varStatus =
442 (rc == 0 ? DMSTAT_FAIL : DMSTAT_PASS)) ==
443 DMSTAT_PASS) {
444 rc = dm_handle_to_ino(hanp1, hlen1, &ino1);
445 rc |= dm_handle_to_ino(hanp2, hlen2, &ino2);
446 if (rc == -1) {
447 DMLOG_PRINT(DMLVL_ERR,
448 "Unable to obtain inode!\n");
449 varStatus = DMSTAT_FAIL;
450 } else if (ino1 != ROOT_INODE) {
451 DMLOG_PRINT(DMLVL_ERR,
452 "Old parent handle NOT root! (%lld vs %d)\n",
453 ino1, ROOT_INODE);
454 varStatus = DMSTAT_FAIL;
455 } else if (ino2 != ROOT_INODE) {
456 DMLOG_PRINT(DMLVL_ERR,
457 "New parent handle NOT root! (%lld vs %d)\n",
458 ino2, ROOT_INODE);
459 varStatus = DMSTAT_FAIL;
460 } else
461 if (dm_handle_cmp
462 (hanp1, hlen1, hanp2, hlen2) != 0) {
463 DMLOG_PRINT(DMLVL_ERR,
464 "Old parent handle NOT equal to new parent handle!\n");
465 varStatus = DMSTAT_FAIL;
466 } else if (strcmp(name1, DUMMY_SUBDIR) != 0) {
467 DMLOG_PRINT(DMLVL_ERR,
468 "Old entry name NOT correct! (%s vs %s)\n",
469 name1, DUMMY_SUBDIR);
470 varStatus = DMSTAT_FAIL;
471 } else if (strcmp(name2, DUMMY_SUBDIR2) != 0) {
472 DMLOG_PRINT(DMLVL_ERR,
473 "New entry name NOT correct! (%s vs %s)\n",
474 name2, DUMMY_SUBDIR2);
475 varStatus = DMSTAT_FAIL;
476 }
477 }
478 DMVAR_END(varStatus);
479
480 /* Variation clean up */
481 eventResponse = DM_RESP_CONTINUE;
482 EVENT_DELIVERY_DELAY;
483 rc = rmdir(DummySubdir);
484 if (rc == -1) {
485 DMLOG_PRINT(DMLVL_DEBUG,
486 "Unable to clean up variation! (errno = %d)\n",
487 errno);
488 }
489 }
490 }
491
492 /*
493 * TEST : symlink - DM_RESP_CONTINUE
494 * EXPECTED: DM_EVENT_SYMLINK
495 */
496 if (DMVAR_EXEC(DIR_SYNC_NAMESP_EVENT_BASE + 7)) {
497 dm_ino_t ino;
498
499 /* Variation set up */
500 eventExpected = DM_EVENT_SYMLINK;
501 eventReceived = DM_EVENT_INVALID;
502 eventResponse = DM_RESP_CONTINUE;
503 EVENT_DELIVERY_DELAY;
504 rc = mkdir(DummySubdir, DUMMY_DIR_RW_MODE);
505 if (rc == -1) {
506 DMLOG_PRINT(DMLVL_DEBUG,
507 "Unable to set up variation! (errno = %d)\n",
508 errno);
509 DMVAR_SKIP();
510 } else {
511 /* Variation */
512 EVENT_DELIVERY_DELAY;
513 DMLOG_PRINT(DMLVL_DEBUG, "symlink(%s, %s)\n",
514 DummySubdir, DummySubdir2);
515 rc = symlink(DummySubdir, DummySubdir2);
516 DMLOG_PRINT(DMLVL_DEBUG,
517 "symlink(%s, %s) returned %d\n",
518 DummySubdir, DummySubdir2, rc);
519 if ((varStatus =
520 DMVAR_CHKPASSEXP(0, rc, eventExpected,
521 eventReceived)) == DMSTAT_PASS) {
522 rc = dm_handle_to_ino(hanp1, hlen1, &ino);
523 if (rc == -1) {
524 DMLOG_PRINT(DMLVL_ERR,
525 "Unable to obtain inode!\n");
526 varStatus = DMSTAT_FAIL;
527 } else if (ino != ROOT_INODE) {
528 DMLOG_PRINT(DMLVL_ERR,
529 "Parent handle NOT root! (%lld vs %d)\n",
530 ino, ROOT_INODE);
531 varStatus = DMSTAT_FAIL;
532 } else if (strcmp(name1, DUMMY_SUBDIR2) != 0) {
533 DMLOG_PRINT(DMLVL_ERR,
534 "Symlink entry name NOT correct! (%s vs %s)\n",
535 name1, DUMMY_SUBDIR2);
536 varStatus = DMSTAT_FAIL;
537 } else if (strcmp(name2, DummySubdir) != 0) {
538 DMLOG_PRINT(DMLVL_ERR,
539 "Symlink contents NOT correct! (%s vs %s)\n",
540 name2, DummySubdir);
541 varStatus = DMSTAT_FAIL;
542 }
543 }
544 DMVAR_END(varStatus);
545
546 /* Variation clean up */
547 EVENT_DELIVERY_DELAY;
548 rc = unlink(DummySubdir2);
549 rc |= rmdir(DummySubdir);
550 if (rc == -1) {
551 DMLOG_PRINT(DMLVL_DEBUG,
552 "Unable to clean up variation! (errno = %d)\n",
553 errno);
554 }
555 }
556 }
557
558 /*
559 * TEST : symlink - DM_RESP_ABORT
560 * EXPECTED: DM_EVENT_SYMLINK
561 */
562 if (DMVAR_EXEC(DIR_SYNC_NAMESP_EVENT_BASE + 8)) {
563 dm_ino_t ino;
564
565 /* Variation set up */
566 eventExpected = DM_EVENT_SYMLINK;
567 eventReceived = DM_EVENT_INVALID;
568 eventResponse = DM_RESP_CONTINUE;
569 EVENT_DELIVERY_DELAY;
570 rc = mkdir(DummySubdir, DUMMY_DIR_RW_MODE);
571 if (rc == -1) {
572 DMLOG_PRINT(DMLVL_DEBUG,
573 "Unable to set up variation! (errno = %d)\n",
574 errno);
575 DMVAR_SKIP();
576 } else {
577 /* Variation */
578 eventResponse = DM_RESP_ABORT;
579 EVENT_DELIVERY_DELAY;
580 DMLOG_PRINT(DMLVL_DEBUG, "symlink(%s, %s)\n",
581 DummySubdir, DummySubdir2);
582 rc = symlink(DummySubdir, DummySubdir2);
583 DMLOG_PRINT(DMLVL_DEBUG,
584 "symlink(%s, %s) returned %d\n",
585 DummySubdir, DummySubdir2, rc);
586 EVENT_DELIVERY_DELAY;
587 if ((varStatus =
588 DMVAR_CHKFAILEXP(-1, rc, ABORT_ERRNO,
589 eventExpected,
590 eventReceived)) == DMSTAT_PASS) {
591 rc = dm_handle_to_ino(hanp1, hlen1, &ino);
592 if (rc == -1) {
593 DMLOG_PRINT(DMLVL_ERR,
594 "Unable to obtain inode!\n");
595 varStatus = DMSTAT_FAIL;
596 } else if (ino != ROOT_INODE) {
597 DMLOG_PRINT(DMLVL_ERR,
598 "Parent handle NOT root! (%lld vs %d)\n",
599 ino, ROOT_INODE);
600 varStatus = DMSTAT_FAIL;
601 } else if (strcmp(name1, DUMMY_SUBDIR2) != 0) {
602 DMLOG_PRINT(DMLVL_ERR,
603 "Symlink entry name NOT correct! (%s vs %s)\n",
604 name1, DUMMY_SUBDIR2);
605 varStatus = DMSTAT_FAIL;
606 } else if (strcmp(name2, DummySubdir) != 0) {
607 DMLOG_PRINT(DMLVL_ERR,
608 "Symlink contents NOT correct! (%s vs %s)\n",
609 name2, DummySubdir);
610 varStatus = DMSTAT_FAIL;
611 }
612 }
613 DMVAR_END(varStatus);
614
615 /* Variation clean up */
616 eventResponse = DM_RESP_CONTINUE;
617 EVENT_DELIVERY_DELAY;
618 rc = rmdir(DummySubdir);
619 if (rc == -1) {
620 DMLOG_PRINT(DMLVL_DEBUG,
621 "Unable to clean up variation! (errno = %d)\n",
622 errno);
623 }
624 }
625 }
626
627 /*
628 * TEST : link - DM_RESP_CONTINUE
629 * EXPECTED: DM_EVENT_LINK
630 */
631 if (DMVAR_EXEC(DIR_SYNC_NAMESP_EVENT_BASE + 9)) {
632 #ifdef DIRECTORY_LINKS
633 dm_ino_t ino1, ino2, ino3;
634 void *hanp;
635 size_t hlen;
636
637 /* Variation set up */
638 eventExpected = DM_EVENT_LINK;
639 eventReceived = DM_EVENT_INVALID;
640 eventResponse = DM_RESP_CONTINUE;
641 EVENT_DELIVERY_DELAY;
642 if ((rc = mkdir(DummySubdir, DUMMY_DIR_RW_MODE)) == -1) {
643 /* No clean up */
644 } else if ((rc = dm_path_to_handle(DummySubdir, &hanp, &hlen))
645 == -1) {
646 rmdir(DummySubdir);
647 }
648 if (rc == -1) {
649 DMLOG_PRINT(DMLVL_DEBUG,
650 "Unable to set up variation! (errno = %d)\n",
651 errno);
652 DMVAR_SKIP();
653 } else {
654 /* Variation */
655 EVENT_DELIVERY_DELAY;
656 DMLOG_PRINT(DMLVL_DEBUG, "link(%s, %s)\n", DummySubdir,
657 DummyLink);
658 rc = link(DummySubdir, DummyLink);
659 DMLOG_PRINT(DMLVL_DEBUG, "link(%s, %s) returned %d\n",
660 DummySubdir, DummyLink, rc);
661 if ((varStatus =
662 DMVAR_CHKPASSEXP(0, rc, eventExpected,
663 eventReceived)) == DMSTAT_PASS) {
664 rc = dm_handle_to_ino(hanp1, hlen1, &ino1);
665 rc |= dm_handle_to_ino(hanp2, hlen2, &ino2);
666 rc |= dm_handle_to_ino(hanp, hlen, &ino3);
667 if (rc == -1) {
668 DMLOG_PRINT(DMLVL_ERR,
669 "Unable to obtain inode!\n");
670 varStatus = DMSTAT_FAIL;
671 } else if (ino1 != ROOT_INODE) {
672 DMLOG_PRINT(DMLVL_ERR,
673 "Parent handle NOT root! (%lld vs %d)\n",
674 ino1, ROOT_INODE);
675 varStatus = DMSTAT_FAIL;
676 } else if (ino2 != ino3) {
677 DMLOG_PRINT(DMLVL_ERR,
678 "Source link handle NOT correct! (%lld vs %lld)\n",
679 ino2, ino3);
680 varStatus = DMSTAT_FAIL;
681 } else if (strcmp(name1, DUMMY_LINK) != 0) {
682 DMLOG_PRINT(DMLVL_ERR,
683 "Target entry name NOT correct! (%s vs %s)\n",
684 name1, DUMMY_LINK);
685 varStatus = DMSTAT_FAIL;
686 }
687 }
688 DMVAR_END(varStatus);
689
690 /* Variation clean up */
691 EVENT_DELIVERY_DELAY;
692 rc = rmdir(DummySubdir);
693 rc |= unlink(DummyLink);
694 if (rc == -1) {
695 DMLOG_PRINT(DMLVL_DEBUG,
696 "Unable to clean up variation! (errno = %d)\n",
697 errno);
698 }
699 dm_handle_free(hanp, hlen);
700 }
701 #else
702 DMLOG_PRINT(DMLVL_WARN,
703 "Test case not built with DIRECTORY_LINKS defined\n");
704 DMVAR_SKIP();
705 #endif
706 }
707
708 /*
709 * TEST : link - DM_RESP_ABORT
710 * EXPECTED: DM_EVENT_LINK
711 */
712 if (DMVAR_EXEC(DIR_SYNC_NAMESP_EVENT_BASE + 10)) {
713 #ifdef DIRECTORY_LINKS
714 dm_ino_t ino1, ino2, ino3;
715 void *hanp;
716 size_t hlen;
717
718 /* Variation set up */
719 eventExpected = DM_EVENT_LINK;
720 eventReceived = DM_EVENT_INVALID;
721 eventResponse = DM_RESP_CONTINUE;
722 EVENT_DELIVERY_DELAY;
723 if ((rc = mkdir(DummySubdir, DUMMY_DIR_RW_MODE)) == -1) {
724 /* No clean up */
725 } else if ((rc = dm_path_to_handle(DummySubdir, &hanp, &hlen))
726 == -1) {
727 rmdir(DummySubdir);
728 }
729 if (rc == -1) {
730 DMLOG_PRINT(DMLVL_DEBUG,
731 "Unable to set up variation! (errno = %d)\n",
732 errno);
733 DMVAR_SKIP();
734 } else {
735 /* Variation */
736 eventResponse = DM_RESP_ABORT;
737 EVENT_DELIVERY_DELAY;
738 DMLOG_PRINT(DMLVL_DEBUG, "link(%s, %s)\n", DummySubdir,
739 DummyLink);
740 rc = link(DummySubdir, DummyLink);
741 DMLOG_PRINT(DMLVL_DEBUG, "link(%s, %s) returned %d\n",
742 DummySubdir, DummyLink, rc);
743 if ((varStatus =
744 DMVAR_CHKFAILEXP(-1, rc, ABORT_ERRNO,
745 eventExpected,
746 eventReceived)) == DMSTAT_PASS) {
747 rc = dm_handle_to_ino(hanp1, hlen1, &ino1);
748 rc |= dm_handle_to_ino(hanp2, hlen2, &ino2);
749 rc |= dm_handle_to_ino(hanp, hlen, &ino3);
750 if (rc == -1) {
751 DMLOG_PRINT(DMLVL_ERR,
752 "Unable to obtain inode!\n");
753 varStatus = DMSTAT_FAIL;
754 } else if (ino1 != ROOT_INODE) {
755 DMLOG_PRINT(DMLVL_ERR,
756 "Parent handle NOT root! (%lld vs %d)\n",
757 ino1, ROOT_INODE);
758 varStatus = DMSTAT_FAIL;
759 } else if (ino2 != ino3) {
760 DMLOG_PRINT(DMLVL_ERR,
761 "Source link handle NOT correct! (%lld vs %lld)\n",
762 ino2, ino3);
763 varStatus = DMSTAT_FAIL;
764 } else if (strcmp(name1, DUMMY_LINK) != 0) {
765 DMLOG_PRINT(DMLVL_ERR,
766 "Target entry name NOT correct! (%s vs %s)\n",
767 name1, DUMMY_LINK);
768 varStatus = DMSTAT_FAIL;
769 }
770 }
771 DMVAR_END(varStatus);
772
773 /* Variation clean up */
774 eventResponse = DM_RESP_CONTINUE;
775 EVENT_DELIVERY_DELAY;
776 rc = rmdir(DummySubdir);
777 if (rc == -1) {
778 DMLOG_PRINT(DMLVL_DEBUG,
779 "Unable to clean up variation! (errno = %d)\n",
780 errno);
781 }
782 dm_handle_free(hanp, hlen);
783 }
784 #else
785 DMLOG_PRINT(DMLVL_WARN,
786 "Test case not built with DIRECTORY_LINKS defined\n");
787 DMVAR_SKIP();
788 #endif
789 }
790
791 /*
792 * TEST : open
793 * EXPECTED: DM_EVENT_CREATE, DM_RESP_CONTINUE
794 */
795 if (DMVAR_EXEC(FILE_SYNC_NAMESP_EVENT_BASE + 1)) {
796 int fd;
797 dm_ino_t ino;
798
799 /* Variation set up */
800 eventExpected = DM_EVENT_CREATE;
801 eventReceived = DM_EVENT_INVALID;
802 eventResponse = DM_RESP_CONTINUE;
803
804 /* Variation */
805 EVENT_DELIVERY_DELAY;
806 DMLOG_PRINT(DMLVL_DEBUG, "open(%s)\n", DummyFile);
807 fd = open(DummyFile, O_RDWR | O_CREAT, DUMMY_FILE_RW_MODE);
808 DMLOG_PRINT(DMLVL_DEBUG, "open(%s) returned %d\n", DummyFile,
809 fd);
810 rc = (fd == -1) ? -1 : 0;
811 if ((varStatus =
812 DMVAR_CHKPASSEXP(0, rc, eventExpected,
813 eventReceived)) == DMSTAT_PASS) {
814 rc = dm_handle_to_ino(hanp1, hlen1, &ino);
815 if (rc == -1) {
816 DMLOG_PRINT(DMLVL_ERR,
817 "Unable to obtain inode!\n");
818 varStatus = DMSTAT_FAIL;
819 } else if (ino != ROOT_INODE) {
820 DMLOG_PRINT(DMLVL_ERR,
821 "Parent handle NOT root! (%lld vs %d)\n",
822 ino, ROOT_INODE);
823 varStatus = DMSTAT_FAIL;
824 } else if (strcmp(name1, DUMMY_FILE) != 0) {
825 DMLOG_PRINT(DMLVL_ERR,
826 "Entry name NOT correct! (%s %s)\n",
827 name1, DUMMY_SUBDIR);
828 varStatus = DMSTAT_FAIL;
829 }
830 }
831 DMVAR_END(varStatus);
832
833 /* Variation clean up */
834 EVENT_DELIVERY_DELAY;
835 rc = close(fd);
836 rc |= remove(DummyFile);
837 if (rc == -1) {
838 DMLOG_PRINT(DMLVL_DEBUG,
839 "Unable to clean up variation! (errno = %d)\n",
840 errno);
841 }
842 }
843
844 /*
845 * TEST : open
846 * EXPECTED: DM_EVENT_CREATE, DM_RESP_ABORT
847 */
848 if (DMVAR_EXEC(FILE_SYNC_NAMESP_EVENT_BASE + 2)) {
849 dm_ino_t ino;
850 int fd;
851
852 /* Variation set up */
853 eventExpected = DM_EVENT_CREATE;
854 eventReceived = DM_EVENT_INVALID;
855 eventResponse = DM_RESP_ABORT;
856
857 /* Variation */
858 EVENT_DELIVERY_DELAY;
859 DMLOG_PRINT(DMLVL_DEBUG, "open(%s)\n", DummyFile);
860 fd = open(DummyFile, O_RDWR | O_CREAT, DUMMY_FILE_RW_MODE);
861 DMLOG_PRINT(DMLVL_DEBUG, "open(%s) returned %d\n", DummyFile,
862 fd);
863 if ((varStatus =
864 DMVAR_CHKFAILEXP(-1, fd, ABORT_ERRNO, eventExpected,
865 eventReceived)) == DMSTAT_PASS) {
866 rc = dm_handle_to_ino(hanp1, hlen1, &ino);
867 if (rc == -1) {
868 DMLOG_PRINT(DMLVL_ERR,
869 "Unable to obtain inode!\n");
870 varStatus = DMSTAT_FAIL;
871 } else if (ino != ROOT_INODE) {
872 DMLOG_PRINT(DMLVL_ERR,
873 "Parent handle NOT root! (%lld vs %d)\n",
874 ino, ROOT_INODE);
875 varStatus = DMSTAT_FAIL;
876 } else if (strcmp(name1, DUMMY_FILE) != 0) {
877 DMLOG_PRINT(DMLVL_ERR,
878 "Entry name NOT correct! (%s vs %s)\n",
879 name1, DUMMY_FILE);
880 varStatus = DMSTAT_FAIL;
881 }
882 }
883 DMVAR_END(varStatus);
884
885 /* Variation clean up */
886 }
887
888 /*
889 * TEST : remove
890 * EXPECTED: DM_EVENT_REMOVE, DM_RESP_CONTINUE
891 */
892 if (DMVAR_EXEC(FILE_SYNC_NAMESP_EVENT_BASE + 3)) {
893 dm_ino_t ino;
894 int fd;
895
896 /* Variation set up */
897 eventExpected = DM_EVENT_REMOVE;
898 eventReceived = DM_EVENT_INVALID;
899 eventResponse = DM_RESP_CONTINUE;
900 EVENT_DELIVERY_DELAY;
901 if ((fd =
902 open(DummyFile, O_RDWR | O_CREAT,
903 DUMMY_FILE_RW_MODE)) != -1) {
904 rc = close(fd);
905 }
906 if (fd == -1 || rc == -1) {
907 DMLOG_PRINT(DMLVL_DEBUG,
908 "Unable to set up variation! (errno = %d)\n",
909 errno);
910 DMVAR_SKIP();
911 } else {
912 /* Variation */
913 EVENT_DELIVERY_DELAY;
914 DMLOG_PRINT(DMLVL_DEBUG, "remove(%s)\n", DummyFile);
915 rc = remove(DummyFile);
916 DMLOG_PRINT(DMLVL_DEBUG, "remove(%s) returned %d\n",
917 DummyFile, rc);
918 if ((varStatus =
919 DMVAR_CHKPASSEXP(0, rc, eventExpected,
920 eventReceived)) == DMSTAT_PASS) {
921 rc = dm_handle_to_ino(hanp1, hlen1, &ino);
922 if (rc == -1) {
923 DMLOG_PRINT(DMLVL_ERR,
924 "Unable to obtain inode!\n");
925 varStatus = DMSTAT_FAIL;
926 } else if (ino != ROOT_INODE) {
927 DMLOG_PRINT(DMLVL_ERR,
928 "Parent handle NOT root! (%lld vs %d)\n",
929 ino, ROOT_INODE);
930 varStatus = DMSTAT_FAIL;
931 } else if (strcmp(name1, DUMMY_FILE) != 0) {
932 DMLOG_PRINT(DMLVL_ERR,
933 "Entry name NOT correct! (%s vs %s)\n",
934 name1, DUMMY_FILE);
935 varStatus = DMSTAT_FAIL;
936 }
937 }
938 DMVAR_END(varStatus);
939
940 /* Variation clean up */
941 }
942 }
943
944 /*
945 * TEST : remove
946 * EXPECTED: DM_EVENT_REMOVE, DM_RESP_ABORT
947 */
948 if (DMVAR_EXEC(FILE_SYNC_NAMESP_EVENT_BASE + 4)) {
949 dm_ino_t ino;
950 int fd;
951
952 /* Variation set up */
953 eventExpected = DM_EVENT_REMOVE;
954 eventReceived = DM_EVENT_INVALID;
955 eventResponse = DM_RESP_CONTINUE;
956 EVENT_DELIVERY_DELAY;
957 if ((fd =
958 open(DummyFile, O_RDWR | O_CREAT,
959 DUMMY_FILE_RW_MODE)) != -1) {
960 rc = close(fd);
961 }
962 if (fd == -1 || rc == -1) {
963 DMLOG_PRINT(DMLVL_DEBUG,
964 "Unable to set up variation! (errno = %d)\n",
965 errno);
966 DMVAR_SKIP();
967 } else {
968 /* Variation */
969 eventResponse = DM_RESP_ABORT;
970 EVENT_DELIVERY_DELAY;
971 DMLOG_PRINT(DMLVL_DEBUG, "remove(%s)\n", DummyFile);
972 rc = remove(DummyFile);
973 DMLOG_PRINT(DMLVL_DEBUG, "remove(%s) returned %d\n",
974 DummyFile, rc);
975 if ((varStatus =
976 DMVAR_CHKFAILEXP(-1, rc, ABORT_ERRNO,
977 eventExpected,
978 eventReceived)) == DMSTAT_PASS) {
979 rc = dm_handle_to_ino(hanp1, hlen1, &ino);
980 if (rc == -1) {
981 DMLOG_PRINT(DMLVL_ERR,
982 "Unable to obtain inode!\n");
983 varStatus = DMSTAT_FAIL;
984 } else if (ino != ROOT_INODE) {
985 DMLOG_PRINT(DMLVL_ERR,
986 "Parent handle NOT root! (%lld vs %d)\n",
987 ino, ROOT_INODE);
988 varStatus = DMSTAT_FAIL;
989 } else if (strcmp(name1, DUMMY_FILE) != 0) {
990 DMLOG_PRINT(DMLVL_ERR,
991 "Entry name NOT correct! (%s vs %s)\n",
992 name1, DUMMY_FILE);
993 varStatus = DMSTAT_FAIL;
994 }
995 }
996 DMVAR_END(varStatus);
997
998 /* Variation clean up */
999 eventResponse = DM_RESP_CONTINUE;
1000 EVENT_DELIVERY_DELAY;
1001 rc = remove(DummyFile);
1002 if (rc == -1) {
1003 DMLOG_PRINT(DMLVL_DEBUG,
1004 "Unable to clean up variation! (errno = %d)\n",
1005 errno);
1006 }
1007 }
1008 }
1009
1010 /*
1011 * TEST : mv
1012 * EXPECTED: DM_EVENT_RENAME, DM_RESP_CONTINUE
1013 */
1014 if (DMVAR_EXEC(FILE_SYNC_NAMESP_EVENT_BASE + 5)) {
1015 dm_ino_t ino1, ino2;
1016 int fd;
1017
1018 /* Variation set up */
1019 eventExpected = DM_EVENT_RENAME;
1020 eventReceived = DM_EVENT_INVALID;
1021 eventResponse = DM_RESP_CONTINUE;
1022 sprintf(command, "mv %s %s", DummyFile, DummyFile2);
1023 EVENT_DELIVERY_DELAY;
1024 if ((fd =
1025 open(DummyFile, O_RDWR | O_CREAT,
1026 DUMMY_FILE_RW_MODE)) != -1) {
1027 rc = close(fd);
1028 }
1029 if (fd == -1 || rc == -1) {
1030 DMLOG_PRINT(DMLVL_DEBUG,
1031 "Unable to set up variation! (errno = %d)\n",
1032 errno);
1033 DMVAR_SKIP();
1034 } else {
1035 /* Variation */
1036 EVENT_DELIVERY_DELAY;
1037 DMLOG_PRINT(DMLVL_DEBUG, "system(mv %s %s)\n",
1038 DummyFile, DummyFile2);
1039 rc = system(command);
1040 DMLOG_PRINT(DMLVL_DEBUG,
1041 "system(mv %s %s) returned %d\n", DummyFile,
1042 DummyFile2, rc);
1043 if ((varStatus =
1044 DMVAR_CHKPASSEXP(0, rc, eventExpected,
1045 eventReceived)) == DMSTAT_PASS) {
1046 rc = dm_handle_to_ino(hanp1, hlen1, &ino1);
1047 rc |= dm_handle_to_ino(hanp2, hlen2, &ino2);
1048 if (rc == -1) {
1049 DMLOG_PRINT(DMLVL_ERR,
1050 "Unable to obtain inode!\n");
1051 varStatus = DMSTAT_FAIL;
1052 } else if (ino1 != ROOT_INODE) {
1053 DMLOG_PRINT(DMLVL_ERR,
1054 "Old parent handle NOT root! (%lld vs %d)\n",
1055 ino1, ROOT_INODE);
1056 varStatus = DMSTAT_FAIL;
1057 } else if (ino2 != ROOT_INODE) {
1058 DMLOG_PRINT(DMLVL_ERR,
1059 "New parent handle NOT root! (%lld vs %d)\n",
1060 ino2, ROOT_INODE);
1061 varStatus = DMSTAT_FAIL;
1062 } else
1063 if (dm_handle_cmp
1064 (hanp1, hlen1, hanp2, hlen2) != 0) {
1065 DMLOG_PRINT(DMLVL_ERR,
1066 "Old parent handle NOT equal to new parent handle!\n");
1067 varStatus = DMSTAT_FAIL;
1068 } else if (strcmp(name1, DUMMY_FILE) != 0) {
1069 DMLOG_PRINT(DMLVL_ERR,
1070 "Old entry name NOT correct! (%s vs %s)\n",
1071 name1, DUMMY_FILE);
1072 varStatus = DMSTAT_FAIL;
1073 } else if (strcmp(name2, DUMMY_FILE2) != 0) {
1074 DMLOG_PRINT(DMLVL_ERR,
1075 "New entry name NOT correct! (%s vs %s)\n",
1076 name2, DUMMY_FILE2);
1077 varStatus = DMSTAT_FAIL;
1078 }
1079 }
1080 DMVAR_END(varStatus);
1081
1082 /* Variation clean up */
1083 EVENT_DELIVERY_DELAY;
1084 rc = remove(DummyFile2);
1085 if (rc == -1) {
1086 DMLOG_PRINT(DMLVL_DEBUG,
1087 "Unable to set up variation! (errno = %d)\n",
1088 errno);
1089 }
1090 }
1091 }
1092
1093 /*
1094 * TEST : mv
1095 * EXPECTED: DM_EVENT_RENAME, DM_RESP_ABORT
1096 */
1097 if (DMVAR_EXEC(FILE_SYNC_NAMESP_EVENT_BASE + 6)) {
1098 dm_ino_t ino1, ino2;
1099 int fd;
1100
1101 /* Variation set up */
1102 eventExpected = DM_EVENT_RENAME;
1103 eventReceived = DM_EVENT_INVALID;
1104 eventResponse = DM_RESP_CONTINUE;
1105 sprintf(command, "mv %s %s", DummyFile, DummyFile2);
1106 EVENT_DELIVERY_DELAY;
1107 if ((fd =
1108 open(DummyFile, O_RDWR | O_CREAT,
1109 DUMMY_FILE_RW_MODE)) != -1) {
1110 rc = close(fd);
1111 }
1112 if (fd == -1 || rc == -1) {
1113 DMLOG_PRINT(DMLVL_DEBUG,
1114 "Unable to set up variation! (errno = %d)\n",
1115 errno);
1116 DMVAR_SKIP();
1117 } else {
1118 /* Variation */
1119 eventResponse = DM_RESP_ABORT;
1120 EVENT_DELIVERY_DELAY;
1121 DMLOG_PRINT(DMLVL_DEBUG, "system(mv %s %s)\n",
1122 DummyFile, DummyFile2);
1123 rc = system(command);
1124 DMLOG_PRINT(DMLVL_DEBUG,
1125 "system(mv %s %s) returned %d\n", DummyFile,
1126 DummyFile2, rc);
1127 if ((varStatus =
1128 (rc == 0 ? DMSTAT_FAIL : DMSTAT_PASS)) ==
1129 DMSTAT_PASS) {
1130 rc = dm_handle_to_ino(hanp1, hlen1, &ino1);
1131 rc |= dm_handle_to_ino(hanp2, hlen2, &ino2);
1132 if (rc == -1) {
1133 DMLOG_PRINT(DMLVL_ERR,
1134 "Unable to obtain inode!\n");
1135 varStatus = DMSTAT_FAIL;
1136 } else if (ino1 != ROOT_INODE) {
1137 DMLOG_PRINT(DMLVL_ERR,
1138 "Old parent handle NOT root! (%lld vs %d)\n",
1139 ino1, ROOT_INODE);
1140 varStatus = DMSTAT_FAIL;
1141 } else if (ino2 != ROOT_INODE) {
1142 DMLOG_PRINT(DMLVL_ERR,
1143 "New parent handle NOT root! (%lld vs %d)\n",
1144 ino2, ROOT_INODE);
1145 varStatus = DMSTAT_FAIL;
1146 } else
1147 if (dm_handle_cmp
1148 (hanp1, hlen1, hanp2, hlen2) != 0) {
1149 DMLOG_PRINT(DMLVL_ERR,
1150 "Old parent handle NOT equal to new parent handle!\n");
1151 varStatus = DMSTAT_FAIL;
1152 } else if (strcmp(name1, DUMMY_FILE) != 0) {
1153 DMLOG_PRINT(DMLVL_ERR,
1154 "Old entry name NOT correct! (%s vs %s)\n",
1155 name1, DUMMY_FILE);
1156 varStatus = DMSTAT_FAIL;
1157 } else if (strcmp(name2, DUMMY_FILE2) != 0) {
1158 DMLOG_PRINT(DMLVL_ERR,
1159 "New entry name NOT correct! (%s vs %s)\n",
1160 name2, DUMMY_FILE2);
1161 varStatus = DMSTAT_FAIL;
1162 }
1163 }
1164 DMVAR_END(varStatus);
1165
1166 /* Variation clean up */
1167 eventResponse = DM_RESP_CONTINUE;
1168 EVENT_DELIVERY_DELAY;
1169 rc = remove(DummyFile);
1170 if (rc == -1) {
1171 DMLOG_PRINT(DMLVL_DEBUG,
1172 "Unable to clean up variation! (errno = %d)\n",
1173 errno);
1174 }
1175 }
1176 }
1177
1178 /*
1179 * TEST : symlink
1180 * EXPECTED: DM_EVENT_SYMLINK, DM_RESP_CONTINUE
1181 */
1182 if (DMVAR_EXEC(FILE_SYNC_NAMESP_EVENT_BASE + 7)) {
1183 dm_ino_t ino;
1184 int fd;
1185
1186 /* Variation set up */
1187 eventExpected = DM_EVENT_SYMLINK;
1188 eventReceived = DM_EVENT_INVALID;
1189 eventResponse = DM_RESP_CONTINUE;
1190 EVENT_DELIVERY_DELAY;
1191 if ((fd =
1192 open(DummyFile, O_RDWR | O_CREAT,
1193 DUMMY_FILE_RW_MODE)) != -1) {
1194 rc = close(fd);
1195 }
1196 if (fd == -1 || rc == -1) {
1197 DMLOG_PRINT(DMLVL_DEBUG,
1198 "Unable to set up variation! (errno = %d)\n",
1199 errno);
1200 DMVAR_SKIP();
1201 } else {
1202 /* Variation */
1203 EVENT_DELIVERY_DELAY;
1204 DMLOG_PRINT(DMLVL_DEBUG, "symlink(%s, %s)\n", DummyFile,
1205 DummyLink);
1206 rc = symlink(DummyFile, DummyLink);
1207 DMLOG_PRINT(DMLVL_DEBUG,
1208 "symlink(%s, %s) returned %d\n", DummyFile,
1209 DummyLink, rc);
1210 if ((varStatus =
1211 DMVAR_CHKPASSEXP(0, rc, eventExpected,
1212 eventReceived)) == DMSTAT_PASS) {
1213 rc = dm_handle_to_ino(hanp1, hlen1, &ino);
1214 if (rc == -1) {
1215 DMLOG_PRINT(DMLVL_ERR,
1216 "Unable to obtain inode!\n");
1217 varStatus = DMSTAT_FAIL;
1218 } else if (ino != ROOT_INODE) {
1219 DMLOG_PRINT(DMLVL_ERR,
1220 "Parent handle NOT root! (%lld vs %d)\n",
1221 ino, ROOT_INODE);
1222 varStatus = DMSTAT_FAIL;
1223 } else if (strcmp(name1, DUMMY_LINK) != 0) {
1224 DMLOG_PRINT(DMLVL_ERR,
1225 "Symlink entry name NOT correct! (%s vs %s)\n",
1226 name1, DUMMY_LINK);
1227 varStatus = DMSTAT_FAIL;
1228 } else if (strcmp(name2, DummyFile) != 0) {
1229 DMLOG_PRINT(DMLVL_ERR,
1230 "Symlink contents NOT correct! (%s vs %s)\n",
1231 name2, DummyFile);
1232 varStatus = DMSTAT_FAIL;
1233 }
1234 }
1235 DMVAR_END(varStatus);
1236
1237 /* Variation clean up */
1238 EVENT_DELIVERY_DELAY;
1239 rc = unlink(DummyLink);
1240 rc |= remove(DummyFile);
1241 if (rc == -1) {
1242 DMLOG_PRINT(DMLVL_DEBUG,
1243 "Unable to clean up variation! (errno = %d)\n",
1244 errno);
1245 }
1246 }
1247 }
1248
1249 /*
1250 * TEST : symlink
1251 * EXPECTED: DM_EVENT_SYMLINK, DM_RESP_ABORT
1252 */
1253 if (DMVAR_EXEC(FILE_SYNC_NAMESP_EVENT_BASE + 8)) {
1254 dm_ino_t ino;
1255 int fd;
1256
1257 /* Variation set up */
1258 eventExpected = DM_EVENT_SYMLINK;
1259 eventReceived = DM_EVENT_INVALID;
1260 eventResponse = DM_RESP_CONTINUE;
1261 EVENT_DELIVERY_DELAY;
1262 if ((fd =
1263 open(DummyFile, O_RDWR | O_CREAT,
1264 DUMMY_FILE_RW_MODE)) != -1) {
1265 rc = close(fd);
1266 }
1267 if (fd == -1 || rc == -1) {
1268 DMLOG_PRINT(DMLVL_DEBUG,
1269 "Unable to set up variation! (errno = %d)\n",
1270 errno);
1271 DMVAR_SKIP();
1272 } else {
1273 /* Variation */
1274 eventResponse = DM_RESP_ABORT;
1275 EVENT_DELIVERY_DELAY;
1276 DMLOG_PRINT(DMLVL_DEBUG, "symlink(%s, %s)\n", DummyFile,
1277 DummyLink);
1278 rc = symlink(DummyFile, DummyLink);
1279 DMLOG_PRINT(DMLVL_DEBUG,
1280 "symlink(%s, %s) returned %d\n", DummyFile,
1281 DummyLink, rc);
1282 if ((varStatus =
1283 DMVAR_CHKFAILEXP(-1, rc, ABORT_ERRNO,
1284 eventExpected,
1285 eventReceived)) == DMSTAT_PASS) {
1286 rc = dm_handle_to_ino(hanp1, hlen1, &ino);
1287 if (rc == -1) {
1288 DMLOG_PRINT(DMLVL_ERR,
1289 "Unable to obtain inode!\n");
1290 varStatus = DMSTAT_FAIL;
1291 } else if (ino != ROOT_INODE) {
1292 DMLOG_PRINT(DMLVL_ERR,
1293 "Parent handle NOT root! (%lld vs %d)\n",
1294 ino, ROOT_INODE);
1295 varStatus = DMSTAT_FAIL;
1296 } else if (strcmp(name1, DUMMY_LINK) != 0) {
1297 DMLOG_PRINT(DMLVL_ERR,
1298 "Symlink entry name NOT correct! (%s vs %s)\n",
1299 name1, DUMMY_LINK);
1300 varStatus = DMSTAT_FAIL;
1301 } else if (strcmp(name2, DummyFile) != 0) {
1302 DMLOG_PRINT(DMLVL_ERR,
1303 "Symlink contents NOT correct! (%s vs %s)\n",
1304 name2, DummyFile);
1305 varStatus = DMSTAT_FAIL;
1306 }
1307 }
1308 DMVAR_END(varStatus);
1309
1310 /* Variation clean up */
1311 eventResponse = DM_RESP_CONTINUE;
1312 EVENT_DELIVERY_DELAY;
1313 rc = remove(DummyFile);
1314 if (rc == -1) {
1315 DMLOG_PRINT(DMLVL_DEBUG,
1316 "Unable to clean up variation! (errno = %d)\n",
1317 errno);
1318 }
1319 }
1320 }
1321
1322 /*
1323 * TEST : link
1324 * EXPECTED: DM_EVENT_LINK, DM_RESP_CONTINUE
1325 */
1326 if (DMVAR_EXEC(FILE_SYNC_NAMESP_EVENT_BASE + 9)) {
1327 dm_ino_t ino1, ino2, ino3;
1328 void *hanp;
1329 size_t hlen;
1330 int fd;
1331
1332 /* Variation set up */
1333 eventExpected = DM_EVENT_LINK;
1334 eventReceived = DM_EVENT_INVALID;
1335 eventResponse = DM_RESP_CONTINUE;
1336 EVENT_DELIVERY_DELAY;
1337 if ((fd =
1338 open(DummyFile, O_RDWR | O_CREAT,
1339 DUMMY_FILE_RW_MODE)) == -1) {
1340 /* No clean up */
1341 } else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
1342 close(fd);
1343 }
1344 if (fd == -1 || rc == -1) {
1345 DMLOG_PRINT(DMLVL_DEBUG,
1346 "Unable to set up variation! (errno = %d)\n",
1347 errno);
1348 DMVAR_SKIP();
1349 } else {
1350 /* Variation */
1351 EVENT_DELIVERY_DELAY;
1352 DMLOG_PRINT(DMLVL_DEBUG, "link(%s, %s)\n", DummyFile,
1353 DummyLink);
1354 rc = link(DummyFile, DummyLink);
1355 DMLOG_PRINT(DMLVL_DEBUG, "link(%s, %s) returned %d\n",
1356 DummyFile, DummyLink, rc);
1357 if ((varStatus =
1358 DMVAR_CHKPASSEXP(0, rc, eventExpected,
1359 eventReceived)) == DMSTAT_PASS) {
1360 rc = dm_handle_to_ino(hanp1, hlen1, &ino1);
1361 rc |= dm_handle_to_ino(hanp2, hlen2, &ino2);
1362 rc |= dm_handle_to_ino(hanp, hlen, &ino3);
1363 if (rc == -1) {
1364 DMLOG_PRINT(DMLVL_ERR,
1365 "Unable to obtain inode!\n");
1366 varStatus = DMSTAT_FAIL;
1367 } else if (ino1 != ROOT_INODE) {
1368 DMLOG_PRINT(DMLVL_ERR,
1369 "Parent handle NOT root! (%lld vs %d)\n",
1370 ino1, ROOT_INODE);
1371 varStatus = DMSTAT_FAIL;
1372 } else if (ino2 != ino3) {
1373 DMLOG_PRINT(DMLVL_ERR,
1374 "Source link handle NOT correct! (%lld vs %lld)\n",
1375 ino2, ino3);
1376 varStatus = DMSTAT_FAIL;
1377 } else if (strcmp(name1, DUMMY_LINK) != 0) {
1378 DMLOG_PRINT(DMLVL_ERR,
1379 "Target entry name NOT correct! (%s vs %s)\n",
1380 name1, DUMMY_LINK);
1381 varStatus = DMSTAT_FAIL;
1382 }
1383 }
1384 DMVAR_END(varStatus);
1385
1386 /* Variation clean up */
1387 EVENT_DELIVERY_DELAY;
1388 rc = close(fd);
1389 rc |= remove(DummyFile);
1390 rc |= remove(DummyLink);
1391 if (rc == -1) {
1392 DMLOG_PRINT(DMLVL_DEBUG,
1393 "Unable to clean up variation! (errno = %d)\n",
1394 errno);
1395 }
1396 dm_handle_free(hanp, hlen);
1397 }
1398 }
1399
1400 /*
1401 * TEST : link
1402 * EXPECTED: DM_EVENT_LINK, DM_RESP_ABORT
1403 */
1404 if (DMVAR_EXEC(FILE_SYNC_NAMESP_EVENT_BASE + 10)) {
1405 dm_ino_t ino1, ino2, ino3;
1406 void *hanp;
1407 size_t hlen;
1408 int fd;
1409
1410 /* Variation set up */
1411 eventExpected = DM_EVENT_LINK;
1412 eventReceived = DM_EVENT_INVALID;
1413 eventResponse = DM_RESP_CONTINUE;
1414 EVENT_DELIVERY_DELAY;
1415 if ((fd =
1416 open(DummyFile, O_RDWR | O_CREAT,
1417 DUMMY_FILE_RW_MODE)) == -1) {
1418 /* No clean up */
1419 } else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
1420 close(fd);
1421 }
1422 if (fd == -1 || rc == -1) {
1423 DMLOG_PRINT(DMLVL_DEBUG,
1424 "Unable to set up variation! (errno = %d)\n",
1425 errno);
1426 DMVAR_SKIP();
1427 } else {
1428 /* Variation */
1429 eventResponse = DM_RESP_ABORT;
1430 EVENT_DELIVERY_DELAY;
1431 DMLOG_PRINT(DMLVL_DEBUG, "link(%s, %s)\n", DummyFile,
1432 DummyLink);
1433 rc = link(DummyFile, DummyLink);
1434 DMLOG_PRINT(DMLVL_DEBUG, "link(%s, %s) returned %d\n",
1435 DummyFile, DummyLink, rc);
1436 if ((varStatus =
1437 DMVAR_CHKFAILEXP(-1, rc, ABORT_ERRNO,
1438 eventExpected,
1439 eventReceived)) == DMSTAT_PASS) {
1440 rc = dm_handle_to_ino(hanp1, hlen1, &ino1);
1441 rc |= dm_handle_to_ino(hanp2, hlen2, &ino2);
1442 rc |= dm_handle_to_ino(hanp, hlen, &ino3);
1443 if (rc == -1) {
1444 DMLOG_PRINT(DMLVL_ERR,
1445 "Unable to obtain inode!\n");
1446 varStatus = DMSTAT_FAIL;
1447 } else if (ino1 != ROOT_INODE) {
1448 DMLOG_PRINT(DMLVL_ERR,
1449 "Parent handle NOT root! (%lld vs %d)\n",
1450 ino1, ROOT_INODE);
1451 varStatus = DMSTAT_FAIL;
1452 } else if (ino2 != ino3) {
1453 DMLOG_PRINT(DMLVL_ERR,
1454 "Source link handle NOT correct! (%lld vs %lld)\n",
1455 ino2, ino3);
1456 varStatus = DMSTAT_FAIL;
1457 } else if (strcmp(name1, DUMMY_LINK) != 0) {
1458 DMLOG_PRINT(DMLVL_ERR,
1459 "Target entry name NOT correct! (%s vs %s)\n",
1460 name1, DUMMY_LINK);
1461 varStatus = DMSTAT_FAIL;
1462 }
1463 }
1464 DMVAR_END(varStatus);
1465
1466 /* Variation clean up */
1467 eventResponse = DM_RESP_CONTINUE;
1468 EVENT_DELIVERY_DELAY;
1469 rc = close(fd);
1470 rc |= remove(DummyFile);
1471 if (rc == -1) {
1472 DMLOG_PRINT(DMLVL_DEBUG,
1473 "Unable to clean up variation! (errno = %d)\n",
1474 errno);
1475 }
1476 dm_handle_free(hanp, hlen);
1477 }
1478 }
1479
1480 rc = umount(mountPt);
1481 if (rc == -1) {
1482 DMLOG_PRINT(DMLVL_ERR, "umount failed! (rc = %d, errno = %d)\n",
1483 rc, errno);
1484 }
1485
1486 pthread_join(tid, NULL);
1487
1488 rc = dm_destroy_session(sid);
1489 if (rc == -1) {
1490 DMLOG_PRINT(DMLVL_ERR,
1491 "dm_destroy_session failed! (rc = %d, errno = %d)\n",
1492 rc, errno);
1493 }
1494
1495 DMLOG_STOP();
1496
1497 tst_exit();
1498 }
1499
Thread(void * parm)1500 void *Thread(void *parm)
1501 {
1502 int rc;
1503 size_t dmMsgBufLen;
1504 dm_eventmsg_t *dmMsg;
1505 int bMounted = DM_FALSE;
1506 int type;
1507 dm_token_t token;
1508 dm_eventset_t events;
1509 dm_response_t response;
1510
1511 do {
1512 /* Loop until message received (wait could be interrupted) */
1513 do {
1514 DMLOG_PRINT(DMLVL_DEBUG, "Waiting for event...\n");
1515 dmMsgBufLen = 0;
1516
1517 rc = dm_get_events(sid, 1, DM_EV_WAIT, sizeof(dmMsgBuf),
1518 dmMsgBuf, &dmMsgBufLen);
1519 DMLOG_PRINT(DMLVL_DEBUG,
1520 "... dm_get_events returned %d (errno %d)\n",
1521 rc, errno);
1522 } while ((rc == -1) && (errno == EINTR) && (dmMsgBufLen == 0));
1523
1524 if (rc) {
1525 DMLOG_PRINT(DMLVL_ERR,
1526 "dm_get_events failed with rc = %d, errno = %d\n",
1527 rc, errno);
1528 DM_EXIT();
1529 } else {
1530 dmMsg = (dm_eventmsg_t *) dmMsgBuf;
1531 token = dmMsg->ev_token;
1532 type = dmMsg->ev_type;
1533
1534 DMLOG_PRINT(DMLVL_DEBUG, "Received message %d\n", type);
1535 }
1536
1537 if (type == DM_EVENT_MOUNT) {
1538 /* SPECIAL CASE: need to set disposition, events and response */
1539 dm_mount_event_t *me =
1540 DM_GET_VALUE(dmMsg, ev_data, dm_mount_event_t *);
1541 void *lhanp = DM_GET_VALUE(me, me_handle1, void *);
1542 size_t lhlen = DM_GET_LEN(me, me_handle1);
1543
1544 DMLOG_PRINT(DMLVL_DEBUG, "Message is DM_EVENT_MOUNT\n");
1545 DMLOG_PRINT(DMLVL_DEBUG, " Mode: %x\n", me->me_mode);
1546 DMLOG_PRINT(DMLVL_DEBUG, " File system handle: %p\n",
1547 lhanp);
1548 DMLOG_PRINT(DMLVL_DEBUG,
1549 " File system handle length: %d\n", lhlen);
1550 DMLOG_PRINT(DMLVL_DEBUG, " Mountpoint handle: %p\n",
1551 DM_GET_VALUE(me, me_handle2, void *));
1552 DMLOG_PRINT(DMLVL_DEBUG,
1553 " Mountpoint handle length: %d\n",
1554 DM_GET_LEN(me, me_handle2));
1555 DMLOG_PRINT(DMLVL_DEBUG, " Mountpoint path: %s\n",
1556 DM_GET_VALUE(me, me_name1, char *));
1557 DMLOG_PRINT(DMLVL_DEBUG, " Media designator: %s\n",
1558 DM_GET_VALUE(me, me_name2, char *));
1559 DMLOG_PRINT(DMLVL_DEBUG, " Root handle: %p\n",
1560 DM_GET_VALUE(me, me_roothandle, void *));
1561 DMLOG_PRINT(DMLVL_DEBUG, " Root handle length: %d\n",
1562 DM_GET_LEN(me, me_roothandle));
1563
1564 bMounted = dm_handle_is_valid(lhanp, lhlen);
1565
1566 rc = dm_request_right(sid, lhanp, lhlen, token,
1567 DM_RR_WAIT, DM_RIGHT_EXCL);
1568 if (rc == -1) {
1569 DMLOG_PRINT(DMLVL_ERR,
1570 "dm_request_right failed! (rc = %d, errno = %d)\n",
1571 rc, errno);
1572 dm_destroy_session(sid);
1573 DM_EXIT();
1574 }
1575
1576 DMEV_ZERO(events);
1577 DMEV_SET(DM_EVENT_PREUNMOUNT, events);
1578 DMEV_SET(DM_EVENT_UNMOUNT, events);
1579 DMEV_SET(DM_EVENT_NOSPACE, events);
1580 DMEV_SET(DM_EVENT_CREATE, events);
1581 DMEV_SET(DM_EVENT_REMOVE, events);
1582 DMEV_SET(DM_EVENT_RENAME, events);
1583 DMEV_SET(DM_EVENT_SYMLINK, events);
1584 DMEV_SET(DM_EVENT_LINK, events);
1585 rc = dm_set_disp(sid, lhanp, lhlen, token, &events,
1586 DM_EVENT_MAX);
1587 if (rc == -1) {
1588 DMLOG_PRINT(DMLVL_ERR,
1589 "dm_set_disp failed! (rc = %d, errno = %d)\n",
1590 rc, errno);
1591 dm_destroy_session(sid);
1592 DM_EXIT();
1593 }
1594
1595 rc = dm_set_eventlist(sid, lhanp, lhlen, token, &events,
1596 DM_EVENT_MAX);
1597 if (rc == -1) {
1598 DMLOG_PRINT(DMLVL_ERR,
1599 "dm_set_eventlist failed! (rc = %d, errno = %d)\n",
1600 rc, errno);
1601 dm_destroy_session(sid);
1602 DM_EXIT();
1603 }
1604
1605 rc = dm_release_right(sid, lhanp, lhlen, token);
1606 if (rc == -1) {
1607 DMLOG_PRINT(DMLVL_ERR,
1608 "dm_request_right failed! (rc = %d, errno = %d)\n",
1609 rc, errno);
1610 dm_destroy_session(sid);
1611 DM_EXIT();
1612 }
1613
1614 response = DM_RESP_CONTINUE;
1615 } else if (type == DM_EVENT_PREUNMOUNT) {
1616 /* SPECIAL CASE: need to set response */
1617 dm_namesp_event_t *nse =
1618 DM_GET_VALUE(dmMsg, ev_data, dm_namesp_event_t *);
1619
1620 DMLOG_PRINT(DMLVL_DEBUG,
1621 "Message is DM_EVENT_PREUNMOUNT\n");
1622 DMLOG_PRINT(DMLVL_DEBUG, " Unmount mode: %x\n",
1623 nse->ne_mode);
1624 DMLOG_PRINT(DMLVL_DEBUG, " File system handle: %p\n",
1625 DM_GET_VALUE(nse, ne_handle1, void *));
1626 DMLOG_PRINT(DMLVL_DEBUG,
1627 " File system handle length: %d\n",
1628 DM_GET_LEN(nse, ne_handle1));
1629 DMLOG_PRINT(DMLVL_DEBUG,
1630 " Root directory handle: %p\n",
1631 DM_GET_VALUE(nse, ne_handle2, void *));
1632 DMLOG_PRINT(DMLVL_DEBUG,
1633 " Root directory handle length: %d\n",
1634 DM_GET_LEN(nse, ne_handle2));
1635
1636 response = DM_RESP_CONTINUE;
1637 } else if (type == DM_EVENT_UNMOUNT) {
1638 /* SPECIAL CASE: need to set response and bMounted */
1639 dm_namesp_event_t *nse =
1640 DM_GET_VALUE(dmMsg, ev_data, dm_namesp_event_t *);
1641
1642 DMLOG_PRINT(DMLVL_DEBUG,
1643 "Message is DM_EVENT_UNMOUNT\n");
1644 DMLOG_PRINT(DMLVL_DEBUG, " Unmount mode: %x\n",
1645 nse->ne_mode);
1646 DMLOG_PRINT(DMLVL_DEBUG, " File system handle: %p\n",
1647 DM_GET_VALUE(nse, ne_handle1, void *));
1648 DMLOG_PRINT(DMLVL_DEBUG,
1649 " File system handle length: %d\n",
1650 DM_GET_LEN(nse, ne_handle1));
1651 DMLOG_PRINT(DMLVL_DEBUG, " Return code: %x\n",
1652 nse->ne_retcode);
1653 if (nse->ne_retcode == 0) {
1654 bMounted = DM_FALSE;
1655 }
1656
1657 response = DM_RESP_CONTINUE;
1658 } else {
1659 eventReceived = type;
1660 response = eventResponse;
1661
1662 switch (type) {
1663 case DM_EVENT_CREATE:
1664 {
1665 dm_namesp_event_t *nse =
1666 DM_GET_VALUE(dmMsg, ev_data,
1667 dm_namesp_event_t *);
1668 mode = nse->ne_mode;
1669 hanp1 =
1670 DM_GET_VALUE(nse, ne_handle1,
1671 void *);
1672 hlen1 = DM_GET_LEN(nse, ne_handle1);
1673 strcpy(name1,
1674 DM_GET_VALUE(nse, ne_name1,
1675 char *));
1676
1677 DMLOG_PRINT(DMLVL_DEBUG,
1678 "Message is DM_EVENT_CREATE\n");
1679 DMLOG_PRINT(DMLVL_DEBUG, " Mode: %x\n",
1680 mode);
1681 DMLOG_PRINT(DMLVL_DEBUG,
1682 " Parent handle: %p\n",
1683 hanp1);
1684 DMLOG_PRINT(DMLVL_DEBUG,
1685 " Parent handle length: %d\n",
1686 hlen1);
1687 DMLOG_PRINT(DMLVL_DEBUG,
1688 " Entry name: %s\n",
1689 name1);
1690
1691 break;
1692 }
1693
1694 case DM_EVENT_REMOVE:
1695 {
1696 dm_namesp_event_t *nse =
1697 DM_GET_VALUE(dmMsg, ev_data,
1698 dm_namesp_event_t *);
1699 mode = nse->ne_mode;
1700 hanp1 =
1701 DM_GET_VALUE(nse, ne_handle1,
1702 void *);
1703 hlen1 = DM_GET_LEN(nse, ne_handle1);
1704 strcpy(name1,
1705 DM_GET_VALUE(nse, ne_name1,
1706 char *));
1707
1708 DMLOG_PRINT(DMLVL_DEBUG,
1709 "Message is DM_EVENT_REMOVE\n");
1710 DMLOG_PRINT(DMLVL_DEBUG, " Mode: %x\n",
1711 mode);
1712 DMLOG_PRINT(DMLVL_DEBUG,
1713 " Parent handle: %p\n",
1714 hanp1);
1715 DMLOG_PRINT(DMLVL_DEBUG,
1716 " Parent handle length: %d\n",
1717 hlen1);
1718 DMLOG_PRINT(DMLVL_DEBUG,
1719 " Entry name: %s\n",
1720 name1);
1721
1722 break;
1723 }
1724
1725 case DM_EVENT_RENAME:
1726 {
1727 dm_namesp_event_t *nse =
1728 DM_GET_VALUE(dmMsg, ev_data,
1729 dm_namesp_event_t *);
1730 hanp1 =
1731 DM_GET_VALUE(nse, ne_handle1,
1732 void *);
1733 hlen1 = DM_GET_LEN(nse, ne_handle1);
1734 hanp2 =
1735 DM_GET_VALUE(nse, ne_handle2,
1736 void *);
1737 hlen2 = DM_GET_LEN(nse, ne_handle2);
1738 strcpy(name1,
1739 DM_GET_VALUE(nse, ne_name1,
1740 char *));
1741 strcpy(name2,
1742 DM_GET_VALUE(nse, ne_name2,
1743 char *));
1744
1745 DMLOG_PRINT(DMLVL_DEBUG,
1746 "Message is DM_EVENT_RENAME\n");
1747 DMLOG_PRINT(DMLVL_DEBUG,
1748 " Old parent handle: %p\n",
1749 hanp1);
1750 DMLOG_PRINT(DMLVL_DEBUG,
1751 " Old parent handle length: %d\n",
1752 hlen1);
1753 DMLOG_PRINT(DMLVL_DEBUG,
1754 " New parent handle: %p\n",
1755 hanp2);
1756 DMLOG_PRINT(DMLVL_DEBUG,
1757 " New parent handle length: %d\n",
1758 hlen2);
1759 DMLOG_PRINT(DMLVL_DEBUG,
1760 " Old entry name: %s\n",
1761 name1);
1762 DMLOG_PRINT(DMLVL_DEBUG,
1763 " New entry name: %s\n",
1764 name2);
1765
1766 break;
1767 }
1768
1769 case DM_EVENT_SYMLINK:
1770 {
1771 dm_namesp_event_t *nse =
1772 DM_GET_VALUE(dmMsg, ev_data,
1773 dm_namesp_event_t *);
1774 hanp1 =
1775 DM_GET_VALUE(nse, ne_handle1,
1776 void *);
1777 hlen1 = DM_GET_LEN(nse, ne_handle1);
1778 strcpy(name1,
1779 DM_GET_VALUE(nse, ne_name1,
1780 char *));
1781 strcpy(name2,
1782 DM_GET_VALUE(nse, ne_name2,
1783 char *));
1784
1785 DMLOG_PRINT(DMLVL_DEBUG,
1786 "Message is DM_EVENT_SYMLINK\n");
1787 DMLOG_PRINT(DMLVL_DEBUG,
1788 " Parent handle: %p\n",
1789 hanp1);
1790 DMLOG_PRINT(DMLVL_DEBUG,
1791 " Parent handle length: %d\n",
1792 hlen1);
1793 DMLOG_PRINT(DMLVL_DEBUG,
1794 " Symlink entry name: %s\n",
1795 name1);
1796 DMLOG_PRINT(DMLVL_DEBUG,
1797 " Symlink contents: %s\n",
1798 name2);
1799
1800 break;
1801 }
1802
1803 case DM_EVENT_LINK:
1804 {
1805 dm_namesp_event_t *nse =
1806 DM_GET_VALUE(dmMsg, ev_data,
1807 dm_namesp_event_t *);
1808 hanp1 =
1809 DM_GET_VALUE(nse, ne_handle1,
1810 void *);
1811 hlen1 = DM_GET_LEN(nse, ne_handle1);
1812 hanp2 =
1813 DM_GET_VALUE(nse, ne_handle2,
1814 void *);
1815 hlen2 = DM_GET_LEN(nse, ne_handle2);
1816 strcpy(name1,
1817 DM_GET_VALUE(nse, ne_name1,
1818 char *));
1819
1820 DMLOG_PRINT(DMLVL_DEBUG,
1821 "Message is DM_EVENT_LINK\n");
1822 DMLOG_PRINT(DMLVL_DEBUG,
1823 " Parent handle: %p\n",
1824 hanp1);
1825 DMLOG_PRINT(DMLVL_DEBUG,
1826 " Parent handle length: %d\n",
1827 hlen1);
1828 DMLOG_PRINT(DMLVL_DEBUG,
1829 " Source link handle: %p\n",
1830 hanp2);
1831 DMLOG_PRINT(DMLVL_DEBUG,
1832 " Source link handle length: %d\n",
1833 hlen2);
1834 DMLOG_PRINT(DMLVL_DEBUG,
1835 " Target entry name: %s\n",
1836 name1);
1837
1838 break;
1839 }
1840
1841 default:
1842 {
1843 DMLOG_PRINT(DMLVL_ERR,
1844 "Message is unexpected!\n");
1845 response = DM_RESP_ABORT;
1846 break;
1847 }
1848 }
1849 }
1850
1851 if (response != DM_RESP_INVALID) {
1852 DMLOG_PRINT(DMLVL_DEBUG,
1853 "Responding to message %d with %d\n", type,
1854 response);
1855 rc = dm_respond_event(sid, token, response,
1856 response ==
1857 DM_RESP_ABORT ? ABORT_ERRNO : 0,
1858 0, NULL);
1859 }
1860 } while (bMounted);
1861
1862 pthread_exit(0);
1863 }
1864