Changeset 114 for trunk/src


Ignore:
Timestamp:
Jul 30, 2007, 10:59:10 PM (17 years ago)
Author:
rainer
Message:

Revision of file flag code.

Location:
trunk/src
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/sh_files.c

    r94 r114  
    116116  short                   checked;
    117117  short                   childs_checked;
    118   short                   reported;
     118  short                   is_reported;
    119119  /* struct dirstack_entry * next; */
    120120} dirstack_t;
     
    234234
    235235          BREAKEXIT(sh_files_filecheck);
    236           tmp_reported = ptr->reported; /* fix aliasing warning */
     236          tmp_reported = ptr->is_reported; /* fix aliasing warning */
    237237          status = sh_files_filecheck (ptr->class, dir, file,
    238238                                       &tmp_reported, 0);
    239           ptr->reported = tmp_reported;
     239          ptr->is_reported = tmp_reported;
    240240         
    241241          TPT(( 0, FIL__, __LINE__,
    242242                _("msg=<filecheck complete: %s> status=<%d> reported=<%d>\n"),
    243                 tmp, status, ptr->reported));
    244 
    245           if (status == SH_FILE_UNKNOWN && ptr->reported == S_FALSE)
     243                tmp, status, ptr->is_reported));
     244
     245          if (status == SH_FILE_UNKNOWN && (!SH_FFLAG_REPORTED_SET(ptr->is_reported)))
    246246            {
    247247              TPT(( 0, FIL__, __LINE__, _("msg=<file: %s> status=<%d>\n"),
     
    288288#endif
    289289              if (sh.flag.reportonce == S_TRUE)
    290                 ptr->reported = S_TRUE;
     290                SET_SH_FFLAG_REPORTED(ptr->is_reported);
    291291            }
    292292          else
     
    294294              /* exists (status >= 0), but was missing (reported == TRUE)
    295295               */
    296               if (status != SH_FILE_UNKNOWN && ptr->reported == S_TRUE)
     296              if (status != SH_FILE_UNKNOWN && SH_FFLAG_REPORTED_SET(ptr->is_reported))
    297297                {
    298                   ptr->reported = S_FALSE;
     298                  CLEAR_SH_FFLAG_REPORTED(ptr->is_reported);
    299299                }
    300300              /* Catchall
     
    759759  new_item_ptr->rdepth         = 0;
    760760  new_item_ptr->checked        = S_FALSE;
    761   new_item_ptr->reported       = S_FALSE;
     761  new_item_ptr->is_reported    = 0;
    762762  new_item_ptr->childs_checked = S_FALSE;
    763763
     
    10051005                                      ptr->name);
    10061006
    1007           if (status < 0 && ptr->reported == S_FALSE)
     1007          if (status < 0 && (!SH_FFLAG_REPORTED_SET(ptr->is_reported)))
    10081008            {
    10091009              /* directory is missing
     
    10241024                }
    10251025              if (sh.flag.reportonce == S_TRUE)
    1026                 ptr->reported = S_TRUE;
     1026                SET_SH_FFLAG_REPORTED(ptr->is_reported);
    10271027            }
    10281028          else
     
    10301030              /* exists (status >= 0), but was missing (reported == TRUE)
    10311031               */
    1032               if (status >= 0 && ptr->reported == S_TRUE)
     1032              if (status >= 0 && SH_FFLAG_REPORTED_SET(ptr->is_reported))
    10331033                {
    1034                   ptr->reported = S_FALSE;
     1034                  CLEAR_SH_FFLAG_REPORTED(ptr->is_reported);
    10351035#if 0
    10361036                  /* obsoleted (really?) by the mandatory sh_files_filecheck()
     
    11631163  new_item_ptr->rdepth         = rdepth;
    11641164  new_item_ptr->checked        = S_FALSE;
    1165   new_item_ptr->reported       = S_FALSE;
     1165  new_item_ptr->is_reported    = 0;
    11661166  new_item_ptr->childs_checked = S_FALSE;
    11671167
     
    17651765         */
    17661766        if (dst_ptr && sh.flag.reportonce == S_TRUE)
    1767           dummy = dst_ptr->reported;
     1767          dummy = dst_ptr->is_reported;
    17681768
    17691769        checkit = sh_files_filecheck (file_class_next,
     
    17771777         */
    17781778        if (dst_ptr && sh.flag.reportonce == S_TRUE)
    1779           dst_ptr->reported = dummy;
     1779          dst_ptr->is_reported = dummy;
    17801780      }
    17811781   
     
    19961996   */
    19971997  sl_strlcpy (theFile.fullpath, fullpath, PATH_MAX);
    1998   theFile.check_mask  = sh_files_maskof(class);
    1999   theFile.reported    = (*reported);
    2000   theFile.attr_string = NULL;
     1998  theFile.check_mask    = sh_files_maskof(class);
     1999  theFile.file_reported = (*reported);
     2000  theFile.attr_string   = NULL;
    20012001
    20022002  TPT(( 0, FIL__, __LINE__, _("msg=<checking file: %s>\n"),  fullpath));
     
    20452045    }
    20462046 
    2047   (*reported) = theFile.reported;
     2047  (*reported) = theFile.file_reported;
    20482048
    20492049  /* reset the access time
  • trunk/src/sh_hash.c

    r107 r114  
    290290  char           * linkpath;
    291291  char           * attr_string;
    292   int              visited;
    293   int              reported;
    294   int              allignore;
     292  int              fflags;
    295293  unsigned long    modi_mask;
    296294  struct           file_info * next;
     
    487485    }
    488486
    489   /* Kernel info
     487  /* Not a fully qualified path, i.e. some info stored by some module
    490488   */
    491   if (p->fullpath[0] == 'K')
     489  if (p->fullpath[0] != '/')
    492490    {
    493491      SL_RET0(_("hash_unvisited"));
    494492    }
    495493
    496   /* visited   = FALSE: not seen;
    497    * visited   = 99:    not seen, and already checked
    498    * reported  = FALSE: not reported yet
    499    * allignore = FALSE: not under IgnoreAll
     494  /* visited   flag not set: not seen;
     495   * checked   flag     set: not seen (i.e. missing), and already checked
     496   * reported  flag not set: not reported yet
     497   * allignore flag not set: not under IgnoreAll
    500498   *
    501499   * Files/directories under IgnoreAll are noticed as missing already
    502500   * during the file check.
    503501   */
    504   if ((p->visited == S_FALSE || p->visited == 99) && p->reported == S_FALSE
    505       && p->allignore == S_FALSE)
     502  if (((!SH_FFLAG_VISITED_SET(p->fflags)) || SH_FFLAG_CHECKED_SET(p->fflags))
     503      && (!SH_FFLAG_REPORTED_SET(p->fflags))
     504      && (!SH_FFLAG_ALLIGNORE_SET(p->fflags)))
    506505    {
    507506      i = retry_lstat(FIL__, __LINE__, p->fullpath, &buf);
     
    520519              SH_FREE(ptr);
    521520            }
    522           if (p->visited != 99)
     521
     522          /* Only report if !SH_FFLAG_CHECKED_SET
     523           */
     524          if (!SH_FFLAG_CHECKED_SET(p->fflags))
    523525            {
    524526              if (S_FALSE == sh_ignore_chk_del(p->fullpath))
     
    572574              SL_RET0(_("hash_unvisited"));
    573575#else
    574               p->reported = S_TRUE;
     576              SET_SH_FFLAG_REPORTED(p->fflags);
    575577#endif
    576578            }
     
    578580    }
    579581
    580   else if (p->visited == S_TRUE && p->reported == S_TRUE
    581            && p->allignore == S_FALSE)
     582  else if (SH_FFLAG_VISITED_SET(p->fflags) && SH_FFLAG_REPORTED_SET(p->fflags)
     583           && (!SH_FFLAG_ALLIGNORE_SET(p->fflags)))
    582584    {
    583585      if (S_FALSE == sh_ignore_chk_new(p->fullpath))
     
    597599        }
    598600
    599       p->reported = S_FALSE;
     601      CLEAR_SH_FFLAG_REPORTED(p->fflags);
    600602    }
    601603
    602604  if (sh.flag.reportonce == S_FALSE)
    603     p->reported = S_FALSE;
    604 
    605   p->visited = S_FALSE;
     605    CLEAR_SH_FFLAG_REPORTED(p->fflags);
     606
     607  CLEAR_SH_FFLAG_VISITED(p->fflags);
     608  CLEAR_SH_FFLAG_CHECKED(p->fflags);
     609
    606610  SL_RET0(_("hash_unvisited"));
    607611}
     
    10491053
    10501054  memcpy( &(*p).theFile, &ft, sizeof(sh_filestore_t) );
    1051   p->visited   = S_FALSE;
    1052   p->reported  = S_FALSE;
    1053   p->allignore = S_FALSE;
     1055
     1056  p->fflags = 0;
     1057
    10541058  p->modi_mask = 0L;
    10551059  p->fullpath  = fullpath;
     
    18351839
    18361840  if (!p) return (-1);
    1837   if (p->allignore == S_FALSE &&
     1841  if ((!SH_FFLAG_ALLIGNORE_SET(p->fflags)) &&
    18381842      (p->modi_mask & MODI_CHK) != 0 &&
    18391843      (p->modi_mask & MODI_MOD) != 0)
     
    18831887  if (p == NULL)
    18841888    SL_RETURN((-1), _("sh_hash_set_visited_int"));
    1885   if (flag == 99)
    1886     {
    1887       p->visited  = 99;
    1888       p->reported = S_FALSE;
    1889     }
    1890   else
    1891     {
    1892       p->visited  = S_TRUE;
    1893       p->reported = flag;
     1889
     1890  if (flag == SH_FFLAG_CHECKED)
     1891    {
     1892      CLEAR_SH_FFLAG_REPORTED(p->fflags);
     1893      CLEAR_SH_FFLAG_VISITED(p->fflags);
     1894      SET_SH_FFLAG_CHECKED(p->fflags);
     1895    }
     1896  else
     1897    {
     1898      SET_SH_FFLAG_VISITED(p->fflags);
     1899      CLEAR_SH_FFLAG_CHECKED(p->fflags);
     1900      if (flag == SH_FFLAG_REPORTED)
     1901        SET_SH_FFLAG_REPORTED(p->fflags);
     1902      else
     1903        CLEAR_SH_FFLAG_REPORTED(p->fflags);
    18941904    }
    18951905  SL_RETURN((0), _("sh_hash_set_visited_int"));
     
    19031913  int i;
    19041914  SL_ENTER(_("sh_hash_set_visited"));
    1905   i = sh_hash_set_visited_int(newname, 99);
     1915  i = sh_hash_set_visited_int(newname, SH_FFLAG_CHECKED);
    19061916  SL_RETURN(i, _("sh_hash_set_visited"));
    19071917}
    19081918
     1919/* mark the file as visited and reported
     1920 */
    19091921int sh_hash_set_visited (char * newname)
    19101922{
    19111923  int i;
    19121924  SL_ENTER(_("sh_hash_set_visited"));
    1913   i = sh_hash_set_visited_int(newname, S_TRUE);
     1925  i = sh_hash_set_visited_int(newname, SH_FFLAG_REPORTED);
    19141926  SL_RETURN(i, _("sh_hash_set_visited"));
    19151927}
    19161928
     1929/* mark the file as visited and NOT reported
     1930 * used to avoid deletion of file from internal database
     1931 */
    19171932int sh_hash_set_visited_true (char * newname)
    19181933{
    19191934  int i;
    19201935  SL_ENTER(_("sh_hash_set_visited_true"));
    1921   i = sh_hash_set_visited_int(newname, S_FALSE);
     1936  i = sh_hash_set_visited_int(newname, 0);
    19221937  SL_RETURN(i, _("sh_hash_set_visited_true"));
    19231938}
     
    20912106
    20922107  memcpy( &(*fp).theFile, &p, sizeof(sh_filestore_t) );
    2093   fp->visited   = S_FALSE;
    2094   fp->reported  = S_FALSE;
    2095   fp->allignore = S_FALSE;
     2108  fp->fflags    = 0;
    20962109  fp->modi_mask = 0L;
    20972110
     
    25992612
    26002613      if (p)
    2601         p->visited   = S_TRUE;
     2614        {
     2615          SET_SH_FFLAG_VISITED(p->fflags);
     2616          CLEAR_SH_FFLAG_CHECKED(p->fflags);
     2617        }
     2618
    26022619      if (sh.flag.reportonce == S_TRUE)
    2603         theFile->reported = S_TRUE;
     2620        SET_SH_FFLAG_REPORTED(theFile->file_reported);
    26042621
    26052622      if (sh.flag.reportonce == S_TRUE && sh.flag.update == S_FALSE)
     
    28282845  /* --- Report on modified files. ---
    28292846   */
    2830   if (modi_mask != 0 && p->reported == S_FALSE)
     2847  if (modi_mask != 0 && (!SH_FFLAG_REPORTED_SET(p->fflags)))
    28312848    {
    28322849      tmp = SH_ALLOC(SH_BUFSIZE);
     
    31883205
    31893206#ifndef REPLACE_OLD
    3190       p->reported = S_TRUE;
     3207      SET_SH_FFLAG_REPORTED(p->fflags);
    31913208#endif
    31923209
     
    32473264              theFile->hardlinks = p->theFile.hardlinks;
    32483265             
    3249               p->visited = S_TRUE;
     3266              SET_SH_FFLAG_VISITED(p->fflags);
     3267              CLEAR_SH_FFLAG_CHECKED(p->fflags);
    32503268              SL_RETURN(1, _("sh_hash_compdata"));
    32513269            }
     
    33163334    }
    33173335
    3318   p->visited = S_TRUE;
     3336  SET_SH_FFLAG_VISITED(p->fflags);
     3337  CLEAR_SH_FFLAG_CHECKED(p->fflags);
    33193338
    33203339  SL_RETURN(0, _("sh_hash_compdata"));
     
    33343353    {
    33353354      for (p = tab[i]; p; p = p->next)
    3336         p->allignore  = S_FALSE;
     3355        CLEAR_SH_FFLAG_ALLIGNORE(p->fflags);
    33373356    }
    33383357  SL_RETURN (0, _("sh_hash_compdata"));
     
    33623381          if (p->fullpath && 0 == strncmp(s, p->fullpath, len))
    33633382            {
    3364               p->allignore  = S_TRUE;
     3383              SET_SH_FFLAG_ALLIGNORE(p->fflags);
    33653384            }
    33663385        }
  • trunk/src/sh_kern.c

    r102 r114  
    901901  (void) sl_strlcpy (theFile.fullpath, pcipath, PATH_MAX);
    902902  theFile.check_mask  = sh_files_maskof(SH_LEVEL_READONLY);
    903   theFile.reported    = S_FALSE;
     903  CLEAR_SH_FFLAG_REPORTED(theFile.file_reported);
    904904  theFile.attr_string = NULL;
    905905 
  • trunk/src/sh_suidchk.c

    r94 r114  
    976976              (void) sl_strlcpy (theFile.fullpath, tmpcat, PATH_MAX);
    977977              theFile.check_mask  = sh_files_maskof(SH_LEVEL_READONLY);
    978               theFile.reported    = S_FALSE;
     978              CLEAR_SH_FFLAG_REPORTED(theFile.file_reported);
    979979              theFile.attr_string = NULL;
    980980
  • trunk/src/sh_unix.c

    r107 r114  
    31783178      if (sh.flag.checkSum == SH_CHECK_INIT ||
    31793179          (sh_hash_have_it (theFile->fullpath) >= 0 &&
    3180            theFile->reported == S_FALSE))
     3180           (!SH_FFLAG_REPORTED_SET(theFile->file_reported))))
    31813181        {
    31823182          if (S_FALSE == sh_ignore_chk_del(theFile->fullpath)) {
Note: See TracChangeset for help on using the changeset viewer.