[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.86 and 1.87

version 1.86, 2009/10/27 23:59:40 version 1.87, 2010/03/20 15:15:45
Line 750 
Line 750 
 rotate(struct conf_entry *ent, const char *oldlog)  rotate(struct conf_entry *ent, const char *oldlog)
 {  {
         char file1[MAXPATHLEN], file2[MAXPATHLEN], *suffix;          char file1[MAXPATHLEN], file2[MAXPATHLEN], *suffix;
         int numdays = ent->numlogs;          int numdays = ent->numlogs - 1;
           int done = 0;
   
         /* Remove oldest log (may not exist) */          /* Remove old logs */
         (void)snprintf(file1, sizeof(file1), "%s.%d", oldlog, numdays);          do {
         (void)snprintf(file2, sizeof(file2), "%s.%d%s", oldlog, numdays,                  (void)snprintf(file1, sizeof(file1), "%s.%d", oldlog, numdays);
             COMPRESS_POSTFIX);                  (void)snprintf(file2, sizeof(file2), "%s.%d%s", oldlog,
                       numdays, COMPRESS_POSTFIX);
                   if (noaction) {
                           printf("\trm -f %s %s\n", file1, file2);
                           done = access(file1, 0) && access(file2, 0);
                   } else {
                           done = unlink(file1) && unlink(file2);
                   }
                   numdays++;
           } while (done == 0);
   
         if (noaction) {  
                 printf("\trm -f %s %s\n", file1, file2);  
         } else {  
                 (void)unlink(file1);  
                 (void)unlink(file2);  
         }  
   
         /* Move down log files */          /* Move down log files */
         while (numdays--) {          for (numdays = ent->numlogs - 2; numdays >= 0; numdays--) {
                 /*                  /*
                  * If both the compressed archive and the non-compressed archive                   * If both the compressed archive and the non-compressed archive
                  * exist, we decide which to rotate based on the CE_COMPACT flag                   * exist, we decide which to rotate based on the CE_COMPACT flag

Legend:
Removed from v.1.86  
changed lines
  Added in v.1.87