Ignore:
Timestamp:
Jul 18, 2015, 5:06:52 PM (10 years ago)
Author:
katerina
Message:

Enhancements and fixes for tickets #374, #375, #376, #377, #378, and #379.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/sh_fInotify.c

    r433 r481  
    3535#include "sh_unix.h"
    3636#include "sh_hash.h"
     37#include "sh_dbIO.h"
    3738#include "sh_files.h"
    3839#include "sh_ignore.h"
     
    111112static int sh_fInotify_process(struct inotify_event * event);
    112113static int sh_fInotify_report(struct inotify_event * event, char * filename,
    113                               int class, unsigned long check_mask, int ftype, int rdepth);
     114                              int class, unsigned long check_flags, int ftype, int rdepth);
    114115
    115116int sh_fInotify_init(struct mod_type * arg)
     
    236237      count2 = 0; /* Update baseline database. */
    237238      if (sh.flag.checkSum == SH_CHECK_CHECK && sh.flag.update == S_TRUE)
    238         sh_hash_writeout ();
     239        sh_dbIO_writeout_update ();
    239240    }
    240241
     
    329330  int    type;
    330331  int    rdepth;
    331   unsigned long check_mask;
     332  unsigned long check_flags;
    332333  int    retval;
    333334  int    errnum;
     
    349350
    350351  while (NULL != (filename = sh_inotify_pop_dormant(&sh_file_watches,
    351                                                     &class, &check_mask,
     352                                                    &class, &check_flags,
    352353                                                    &type, &rdepth)))
    353354    {
    354355      retval = sh_inotify_add_watch(filename, &sh_file_watches, &errnum,
    355                                     class, check_mask, type, rdepth);
     356                                    class, check_flags, type, rdepth);
    356357
    357358      if (retval < 0)
     
    424425  if (event->mask & IN_UNMOUNT) sl_strlcat(dbgbuf, "IN_UNMOUNT ", sizeof(dbgbuf));
    425426 
    426   /* fprintf(stderr, "FIXME: %s\n", dbgbuf); */
    427  
    428427  SH_MUTEX_LOCK(mutex_thread_nolog);
    429428  sh_error_handle(SH_ERR_ALL, FIL__, __LINE__, 0, MSG_E_SUBGEN,
     
    437436  int ftype;
    438437  int rdepth;
    439   unsigned long check_mask;
     438  unsigned long check_flags;
    440439  char * filename;
    441440  extern int flag_err_debug;
    442441
    443   if (flag_err_debug == SL_TRUE)
     442  if (flag_err_debug == S_TRUE)
    444443    {
    445444      sh_fInotify_logmask(event);
     
    449448    {
    450449      filename = sh_inotify_search_item(&sh_file_watches, event->wd,
    451                                         &class, &check_mask, &ftype, &rdepth);
     450                                        &class, &check_flags, &ftype, &rdepth);
    452451
    453452      if (filename)
    454453        {
    455           sh_fInotify_report(event, filename, class, check_mask, ftype, rdepth);
     454          sh_fInotify_report(event, filename, class, check_flags, ftype, rdepth);
    456455          SH_FREE(filename);
    457456        }
     
    488487}
    489488
    490 void sh_fInotify_report_add(char * path, int class, unsigned long check_mask)
     489void sh_fInotify_report_add(char * path, int class, unsigned long check_flags)
    491490{
    492491  if (S_FALSE == sh_ignore_chk_new(path))
     
    496495      sh_files_clear_file_reported(path);
    497496     
    498       sh_files_search_file(path, &class, &check_mask, &reported);
     497      sh_files_search_file(path, &class, &check_flags, &reported);
    499498     
    500       sh_files_filecheck (class, check_mask, path, NULL,
     499      sh_files_filecheck (class, check_flags, path, NULL,
    501500                          &reported, 0);
    502501      if (SH_FFLAG_REPORTED_SET(reported))
     
    521520static int sh_fInotify_report_change (struct inotify_event * event,
    522521                                      char * path, char * filename,
    523                                       int class, unsigned long check_mask, int ftype)
     522                                      int class, unsigned long check_flags, int ftype)
    524523{
    525524  int    reported;
     
    529528  if (S_FALSE == sh_ignore_chk_mod(path))
    530529    {
    531       ret  = sh_files_search_file(path, &class, &check_mask, &reported);
     530      ret  = sh_files_search_file(path, &class, &check_flags, &reported);
    532531
    533532      if ((ret == 0) && (event->len > 0) && (ftype == SH_INOTIFY_FILE))
     
    537536      else
    538537        {
    539           sh_files_filecheck (class, check_mask, filename,
     538          sh_files_filecheck (class, check_flags, filename,
    540539                              (event->len > 0) ? event->name : NULL,
    541540                              &reported, 0);
     
    548547static int sh_fInotify_report_missing (struct inotify_event * event,
    549548                                       char * path,
    550                                        int class, unsigned long check_mask, int ftype)
     549                                       int class, unsigned long check_flags, int ftype)
    551550{
    552551  int    reported;
     
    560559      if (0 != hashreport_missing(path, level))
    561560        {
    562           int ret = sh_files_search_file(path, &class, &check_mask, &reported);
     561          int ret = sh_files_search_file(path, &class, &check_flags, &reported);
    563562         
    564563          if ((ret == 0) && (event->len > 0) && (ftype == SH_INOTIFY_FILE))
     
    578577    }
    579578
    580 #ifndef REPLACE_OLD
    581   sh_hash_set_visited_true(path);
    582 #else
    583579  sh_hash_set_missing(path);
    584 #endif
     580
    585581  if (sh.flag.reportonce == S_TRUE)
    586582    sh_files_set_file_reported(path);
     
    596592static int sh_fInotify_report_added (struct inotify_event * event,
    597593                                     char * path, char * filename,
    598                                      int class, unsigned long check_mask,
     594                                     int class, unsigned long check_flags,
    599595                                     int ftype, int rdepth)
    600596{
     
    608604      sh_files_clear_file_reported(path);
    609605         
    610       ret = sh_files_search_file(path, &class, &check_mask, &reported);
     606      ret = sh_files_search_file(path, &class, &check_flags, &reported);
    611607     
    612608      if ((ret == 0) && (event->len > 0) && (ftype == SH_INOTIFY_FILE))
     
    618614          int classD = class;
    619615          int reportedD = reported;
    620           unsigned long check_maskD = check_mask;
     616          unsigned long check_flagsD = check_flags;
    621617         
    622618          if (event->mask & IN_ISDIR)
    623619            {
    624               retD = sh_files_search_dir(path, &classD, &check_maskD,
     620              retD = sh_files_search_dir(path, &classD, &check_flagsD,
    625621                                         &reportedD, &rdepthD);
    626622              if (retD != 0)
     
    629625                    {
    630626                      class      = classD;
    631                       check_mask = check_maskD;
     627                      check_flags = check_flagsD;
    632628                    }
    633629                }
    634630            }
    635631         
    636           sh_files_filecheck (class, check_mask, filename,
     632          sh_files_filecheck (class, check_flags, filename,
    637633                              (event->len > 0) ? event->name : NULL,
    638634                              &reported, 0);
     
    641637            {
    642638              SH_INOTIFY_IFUSED( sh.flag.inotify |= SH_INOTIFY_INSCAN;   );
    643               sh_files_checkdir (classD, check_maskD, rdepthD,
     639              sh_files_checkdir (classD, check_flagsD, rdepthD,
    644640                                 path, (event->len > 0) ? event->name : NULL);
    645641              SH_INOTIFY_IFUSED( sh.flag.inotify &= ~SH_INOTIFY_INSCAN;  );
     
    657653        {
    658654          sh_inotify_add_watch(path, &sh_file_watches, &ret,
    659                                class, check_mask,
     655                               class, check_flags,
    660656                               (event->mask & IN_ISDIR)?SH_INOTIFY_DIR:SH_INOTIFY_FILE,
    661657                               rdepthD);
     
    666662
    667663static int sh_fInotify_report(struct inotify_event * event, char * filename,
    668                               int class, unsigned long check_mask, int ftype, int rdepth)
     664                              int class, unsigned long check_flags, int ftype, int rdepth)
    669665{
    670666  char * fullpath = NULL;
     
    684680    {
    685681      sh_fInotify_report_change (event, path, filename,
    686                                  class, check_mask, ftype);
     682                                 class, check_flags, ftype);
    687683    }
    688684  else if ((event->mask & (IN_DELETE|IN_DELETE_SELF|IN_MOVE_SELF|IN_MOVED_FROM)) != 0)
    689685    {
    690686      sh_fInotify_report_missing (event, path,
    691                                   class, check_mask, ftype);
     687                                  class, check_flags, ftype);
    692688   }
    693689  else if((event->mask & (IN_CREATE|IN_MOVED_TO)) != 0)
    694690    {
    695691      sh_fInotify_report_added (event, path, filename,
    696                                 class, check_mask,
     692                                class, check_flags,
    697693                                ftype, rdepth);
    698694    }
Note: See TracChangeset for help on using the changeset viewer.