- Timestamp:
- Nov 1, 2011, 12:33:37 AM (13 years ago)
- Location:
- trunk
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/sh_inotify.h
r371 r372 23 23 #define SH_INOTIFY_INITIALIZER { NULL, NULL, 0, 0 } 24 24 25 #define SH_INOTIFY_FILE 0 26 #define SH_INOTIFY_DIR 1 27 25 28 int sh_inotify_wait_for_change(char * filename, sh_watches * watches, 26 29 int * errnum, int waitsec); … … 29 32 30 33 int sh_inotify_add_watch(char * filename, sh_watches * watches, int * errnum, 31 int class, unsigned long check_mask );34 int class, unsigned long check_mask, int type); 32 35 33 36 int sh_inotify_add_watch_later(char * filename, sh_watches * watches, int * errnum, 34 int class, unsigned long check_mask );37 int class, unsigned long check_mask, int type); 35 38 36 char * sh_inotify_pop_dormant(sh_watches * watches, int * class, unsigned long * check_mask );39 char * sh_inotify_pop_dormant(sh_watches * watches, int * class, unsigned long * check_mask, int * type); 37 40 38 41 void sh_inotify_purge_dormant(sh_watches * watches); … … 41 44 42 45 char * sh_inotify_search_item(sh_watches * watches, int watch, 43 int * class, unsigned long * check_mask );46 int * class, unsigned long * check_mask, int * type); 44 47 ssize_t sh_inotify_read(char * buffer, size_t count); 45 48 ssize_t sh_inotify_read_timeout(char * buffer, size_t count, int timeout); -
trunk/src/sh_fInotify.c
r371 r372 111 111 static int sh_fInotify_process(struct inotify_event * event); 112 112 static int sh_fInotify_report(struct inotify_event * event, char * filename, 113 int class, unsigned long check_mask );113 int class, unsigned long check_mask, int ftype); 114 114 115 115 int sh_fInotify_init(struct mod_type * arg) … … 168 168 ssize_t len = -1; 169 169 char * buffer = SH_ALLOC(16384); 170 static int count = 0; 170 static int count = 0; 171 static int count2 = 0; 171 172 172 173 if (ShfInotifyActive == S_FALSE) … … 211 212 sh_inotify_recheck_watches (&sh_file_watches, &sh_file_missing); 212 213 213 ++count; 214 ++count; 215 ++count2; 214 216 215 217 if (count >= 10) 216 218 { 217 count = 0; /* Re-expand glob patterns to discover added files */219 count = 0; /* Re-expand glob patterns to discover added files. */ 218 220 sh_files_check_globFilePatterns(); 221 } 222 223 if (count2 >= 300) 224 { 225 count2 = 0; /* Update baseline database. */ 226 if (sh.flag.checkSum == SH_CHECK_CHECK && 227 sh.flag.update == S_TRUE) 228 sh_hash_writeout (); 219 229 } 220 230 … … 303 313 char * filename; 304 314 int class; 315 int type; 305 316 unsigned long check_mask; 306 317 int retval; … … 323 334 324 335 while (NULL != (filename = sh_inotify_pop_dormant(&sh_file_watches, 325 &class, &check_mask )))336 &class, &check_mask, &type))) 326 337 { 327 338 retval = sh_inotify_add_watch(filename, &sh_file_watches, &errnum, 328 class, check_mask );339 class, check_mask, type); 329 340 330 341 if (retval < 0) … … 367 378 { 368 379 int class; 380 int ftype; 369 381 unsigned long check_mask; 370 382 char * filename; … … 374 386 { 375 387 char dbgbuf[256]; 388 376 389 sl_strlcpy (dbgbuf, "inotify mask: ", sizeof(dbgbuf)); 390 377 391 if (event->mask & IN_ACCESS) sl_strlcat(dbgbuf, "IN_ACCESS ", sizeof(dbgbuf)); 378 392 if (event->mask & IN_ATTRIB) sl_strlcat(dbgbuf, "IN_ATTRIB ", sizeof(dbgbuf)); … … 391 405 if (event->mask & IN_Q_OVERFLOW) sl_strlcat(dbgbuf, "IN_Q_OVERFLOW ", sizeof(dbgbuf)); 392 406 if (event->mask & IN_UNMOUNT) sl_strlcat(dbgbuf, "IN_UNMOUNT ", sizeof(dbgbuf)); 407 393 408 SH_MUTEX_LOCK(mutex_thread_nolog); 394 409 sh_error_handle(SH_ERR_ALL, FIL__, __LINE__, 0, MSG_E_SUBGEN, … … 401 416 { 402 417 filename = sh_inotify_search_item(&sh_file_watches, event->wd, 403 &class, &check_mask );418 &class, &check_mask, &ftype); 404 419 405 420 if (filename) 406 421 { 407 sh_fInotify_report(event, filename, class, check_mask );422 sh_fInotify_report(event, filename, class, check_mask, ftype); 408 423 409 424 SH_FREE(filename); … … 417 432 /* Remove watch ? Seems reasonable. */ 418 433 sh_inotify_rm_watch(NULL, NULL, event->wd); 434 419 435 SH_MUTEX_LOCK(mutex_thread_nolog); 420 436 sh_error_handle((-1), FIL__, __LINE__, event->wd, MSG_E_SUBGEN, … … 466 482 467 483 static int sh_fInotify_report(struct inotify_event * event, char * filename, 468 int class, unsigned long check_mask )484 int class, unsigned long check_mask, int ftype) 469 485 { 470 486 char * fullpath = NULL; … … 484 500 if ( (event->mask & (IN_ATTRIB|IN_MODIFY)) != 0) 485 501 { 486 sh_files_search_file(path, &class, &check_mask, &reported); 487 488 sh_files_filecheck (class, check_mask, filename, 489 (event->len > 0) ? event->name : NULL, 490 &reported, 0); 502 int ret = sh_files_search_file(path, &class, &check_mask, &reported); 503 504 if ((ret == 0) && (event->len > 0) && (ftype == SH_INOTIFY_FILE)) 505 { 506 ; /* do nothing */ 507 } 508 else 509 { 510 sh_files_filecheck (class, check_mask, filename, 511 (event->len > 0) ? event->name : NULL, 512 &reported, 0); 513 } 491 514 } 492 515 else if ((event->mask & (IN_DELETE|IN_DELETE_SELF|IN_MOVE_SELF|IN_MOVED_FROM)) != 0) … … 501 524 if (0 != hashreport_missing(path, level)) 502 525 { 503 sh_fInotify_report_miss(path, level); 526 int ret = sh_files_search_file(path, &class, &check_mask, &reported); 527 528 if ((ret == 0) && (event->len > 0) && (ftype == SH_INOTIFY_FILE)) 529 { 530 ; /* do nothing */ 531 } 532 else 533 { 534 sh_fInotify_report_miss(path, level); 535 } 504 536 } 505 537 } … … 513 545 sh_files_set_file_reported(path); 514 546 515 /* Move to 'dormant' list .547 /* Move to 'dormant' list, if not file within directory. 516 548 */ 517 sh_inotify_rm_watch(&sh_file_watches, &sh_file_missing, event->wd); 549 if (event->len == 0) 550 sh_inotify_rm_watch(&sh_file_watches, &sh_file_missing, event->wd); 518 551 } 519 552 else if((event->mask & (IN_CREATE|IN_MOVED_TO)) != 0) … … 527 560 ret = sh_files_search_file(path, &class, &check_mask, &reported); 528 561 529 sh_files_filecheck (class, check_mask, filename, 530 (event->len > 0) ? event->name : NULL, 531 &reported, 0); 562 if ((ret == 0) && (event->len > 0) && (ftype == SH_INOTIFY_FILE)) 563 { 564 ; /* do nothing */ 565 } 566 else 567 { 568 sh_files_filecheck (class, check_mask, filename, 569 (event->len > 0) ? event->name : NULL, 570 &reported, 0); 571 } 572 532 573 if (SH_FFLAG_REPORTED_SET(reported)) 533 574 sh_files_set_file_reported(path); … … 536 577 { 537 578 sh_inotify_add_watch(path, &sh_file_watches, &ret, 538 class, check_mask );579 class, check_mask, SH_INOTIFY_FILE); 539 580 } 540 581 } -
trunk/src/sh_files.c
r371 r372 370 370 { 371 371 sh_inotify_add_watch_later(ptr->name, &sh_file_watches, NULL, 372 ptr->class, ptr->check_mask );372 ptr->class, ptr->check_mask, SH_INOTIFY_FILE); 373 373 } 374 374 … … 1907 1907 } 1908 1908 1909 if ((sh.flag.inotify & SH_INOTIFY_DOSCAN) != 0)1910 {1911 sh_inotify_add_watch_later(iname, &sh_file_watches, &status,1912 iclass, check_mask);1913 }1914 1915 1909 /* ---- stat the directory ---- 1916 1910 */ … … 1955 1949 } 1956 1950 1951 if ((sh.flag.inotify & SH_INOTIFY_DOSCAN) != 0) 1952 { 1953 sh_inotify_add_watch_later(iname, &sh_file_watches, &status, 1954 iclass, check_mask, SH_INOTIFY_DIR); 1955 } 1956 1957 1957 hardlink_num = theFile->hardlinks; 1958 1958 -
trunk/src/sh_inotify.c
r371 r372 125 125 { 126 126 int watch; 127 int flag; 127 short flag; 128 short type; 128 129 int class; 129 130 unsigned long check_mask; … … 355 356 356 357 char * sh_inotify_pop_dormant(sh_watches * watches, 357 int * class, unsigned long * check_mask )358 int * class, unsigned long * check_mask, int * type) 358 359 { 359 360 char * popret = NULL; … … 372 373 { 373 374 *class = this->watch->class; 375 *type = this->watch->type; 374 376 *check_mask = this->watch->check_mask; 375 377 popret = sh_util_strdup(this->watch->file); … … 472 474 int sh_inotify_add_watch_later(char * filename, sh_watches * watches, 473 475 int * errnum, 474 int class, unsigned long check_mask )476 int class, unsigned long check_mask, int type) 475 477 { 476 478 sh_watch * item; … … 479 481 480 482 item->class = class; 483 item->type = (short) type; 481 484 item->check_mask = check_mask; 482 485 … … 571 574 */ 572 575 int sh_inotify_add_watch(char * filename, sh_watches * watches, int * errnum, 573 int class, unsigned long check_mask )576 int class, unsigned long check_mask, int type) 574 577 { 575 578 volatile int retval = 0; … … 614 617 615 618 item->class = class; 619 item->type = type; 616 620 item->check_mask = check_mask; 617 621 … … 651 655 652 656 char * sh_inotify_search_item(sh_watches * watches, int watch, 653 int * class, unsigned long * check_mask )657 int * class, unsigned long * check_mask, int * type) 654 658 { 655 659 sh_watch * item; … … 668 672 *class = item->class; 669 673 *check_mask = item->check_mask; 674 *type = item->type; 670 675 sret = sh_util_strdup(item->file); 671 676 } … … 705 710 if (filename) 706 711 { 707 if (sh_inotify_add_watch(filename, watches, errnum, 0, 0 ) < 0)712 if (sh_inotify_add_watch(filename, watches, errnum, 0, 0, SH_INOTIFY_FILE) < 0) 708 713 { 709 714 retry_msleep(waitsec, 0); -
trunk/src/sh_modules.c
r367 r372 178 178 N_("INOTIFY"), 179 179 -1, 180 SH_MODFL_NOTIMER,180 0, 181 181 sh_fInotify_init, 182 182 sh_fInotify_timer,
Note:
See TracChangeset
for help on using the changeset viewer.