[BACK]Return to newsyslog.c CVS log [TXT][DIR] Up to [local] / src / usr.bin / newsyslog

Diff for /src/usr.bin/newsyslog/newsyslog.c between version 1.57 and 1.57.2.1

version 1.57, 2002/09/21 23:19:43 version 1.57.2.1, 2002/11/15 19:16:29
Line 134 
Line 134 
 #define CE_FOLLOW       0x10            /* Follow symbolic links */  #define CE_FOLLOW       0x10            /* Follow symbolic links */
   
 #define MIN_PID         4               /* Don't touch pids lower than this */  #define MIN_PID         4               /* Don't touch pids lower than this */
 #define MIN_SIZE        512             /* Don't rotate if smaller than this */  #define MIN_SIZE        256             /* Don't rotate if smaller (in bytes) */
   
 #define DPRINTF(x)      do { if (verbose) printf x ; } while (0)  #define DPRINTF(x)      do { if (verbose) printf x ; } while (0)
   
Line 145 
Line 145 
         uid_t   uid;            /* Owner of log */          uid_t   uid;            /* Owner of log */
         gid_t   gid;            /* Group of log */          gid_t   gid;            /* Group of log */
         int     numlogs;        /* Number of logs to keep */          int     numlogs;        /* Number of logs to keep */
         int     size;           /* Size cutoff to trigger trimming the log */          off_t   size;           /* Size cutoff to trigger trimming the log */
         int     hours;          /* Hours between log trimming */          int     hours;          /* Hours between log trimming */
         int     permissions;    /* File permissions on the log */          int     permissions;    /* File permissions on the log */
         int     signal;         /* Signal to send (defaults to SIGHUP) */          int     signal;         /* Signal to send (defaults to SIGHUP) */
Line 180 
Line 180 
 void dotrim(struct conf_entry *);  void dotrim(struct conf_entry *);
 int log_trim(char *);  int log_trim(char *);
 void compress_log(struct conf_entry *);  void compress_log(struct conf_entry *);
 int sizefile(char *);  off_t sizefile(char *);
 int age_old_log(struct conf_entry *);  int age_old_log(struct conf_entry *);
 char *sob(char *);  char *sob(char *);
 char *son(char *);  char *son(char *);
Line 301 
Line 301 
 void  void
 do_entry(struct conf_entry *ent)  do_entry(struct conf_entry *ent)
 {  {
         int modtime, size;          int modtime;
           off_t size;
         struct stat sb;          struct stat sb;
   
         if (lstat(ent->log, &sb) != 0)          if (lstat(ent->log, &sb) != 0)
Line 323 
Line 324 
                 DPRINTF(("does not exist.\n"));                  DPRINTF(("does not exist.\n"));
         } else {          } else {
                 if (ent->size > 0)                  if (ent->size > 0)
                         DPRINTF(("size (Kb): %d [%d] ", size, ent->size));                          DPRINTF(("size (KB): %.2f [%d] ", size / 1024.0,
                               (int)(ent->size / 1024)));
                 if (ent->hours > 0)                  if (ent->hours > 0)
                         DPRINTF(("age (hr): %d [%d] ", modtime, ent->hours));                          DPRINTF(("age (hr): %d [%d] ", modtime, ent->hours));
                 if (monitormode && ent->flags & CE_MONITOR)                  if (monitormode && ent->flags & CE_MONITOR)
Line 553 
Line 555 
                 q = parse = missing_field(sob(++parse), errline);                  q = parse = missing_field(sob(++parse), errline);
                 *(parse = son(parse)) = '\0';                  *(parse = son(parse)) = '\0';
                 if (isdigit(*q))                  if (isdigit(*q))
                         working->size = atoi(q);                          working->size = atoi(q) * 1024;
                 else                  else
                         working->size = -1;                          working->size = -1;
   
Line 842 
Line 844 
 }  }
   
 /* Return size in kilobytes of a file */  /* Return size in kilobytes of a file */
 int  off_t
 sizefile(char *file)  sizefile(char *file)
 {  {
         struct stat sb;          struct stat sb;
   
         if (stat(file, &sb) < 0)          if (stat(file, &sb) < 0)
                 return (-1);                  return (-1);
         return (sb.st_blocks / (1024.0 / DEV_BSIZE));  
           /* For sparse files, return the size based on number of blocks used. */
           if (sb.st_size / DEV_BSIZE > sb.st_blocks)
                   return (sb.st_blocks * DEV_BSIZE);
           else
                   return (sb.st_size);
 }  }
   
 /* Return the age (in hours) of old log file (file.0), or -1 if none */  /* Return the age (in hours) of old log file (file.0), or -1 if none */

Legend:
Removed from v.1.57  
changed lines
  Added in v.1.57.2.1