=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/newsyslog/newsyslog.c,v retrieving revision 1.57 retrieving revision 1.57.2.1 diff -c -r1.57 -r1.57.2.1 *** src/usr.bin/newsyslog/newsyslog.c 2002/09/21 23:19:43 1.57 --- src/usr.bin/newsyslog/newsyslog.c 2002/11/15 19:16:29 1.57.2.1 *************** *** 1,4 **** ! /* $OpenBSD: newsyslog.c,v 1.57 2002/09/21 23:19:43 millert Exp $ */ /* * Copyright (c) 1999, 2002 Todd C. Miller --- 1,4 ---- ! /* $OpenBSD: newsyslog.c,v 1.57.2.1 2002/11/15 19:16:29 millert Exp $ */ /* * Copyright (c) 1999, 2002 Todd C. Miller *************** *** 86,92 **** */ #ifndef lint ! static const char rcsid[] = "$OpenBSD: newsyslog.c,v 1.57 2002/09/21 23:19:43 millert Exp $"; #endif /* not lint */ #ifndef CONF --- 86,92 ---- */ #ifndef lint ! static const char rcsid[] = "$OpenBSD: newsyslog.c,v 1.57.2.1 2002/11/15 19:16:29 millert Exp $"; #endif /* not lint */ #ifndef CONF *************** *** 134,140 **** #define CE_FOLLOW 0x10 /* Follow symbolic links */ #define MIN_PID 4 /* Don't touch pids lower than this */ ! #define MIN_SIZE 512 /* Don't rotate if smaller than this */ #define DPRINTF(x) do { if (verbose) printf x ; } while (0) --- 134,140 ---- #define CE_FOLLOW 0x10 /* Follow symbolic links */ #define MIN_PID 4 /* Don't touch pids lower than this */ ! #define MIN_SIZE 256 /* Don't rotate if smaller (in bytes) */ #define DPRINTF(x) do { if (verbose) printf x ; } while (0) *************** *** 145,151 **** uid_t uid; /* Owner of log */ gid_t gid; /* Group of log */ int numlogs; /* Number of logs to keep */ ! int size; /* Size cutoff to trigger trimming the log */ int hours; /* Hours between log trimming */ int permissions; /* File permissions on the log */ int signal; /* Signal to send (defaults to SIGHUP) */ --- 145,151 ---- uid_t uid; /* Owner of log */ gid_t gid; /* Group of log */ int numlogs; /* Number of logs to keep */ ! off_t size; /* Size cutoff to trigger trimming the log */ int hours; /* Hours between log trimming */ int permissions; /* File permissions on the log */ int signal; /* Signal to send (defaults to SIGHUP) */ *************** *** 180,186 **** void dotrim(struct conf_entry *); int log_trim(char *); void compress_log(struct conf_entry *); ! int sizefile(char *); int age_old_log(struct conf_entry *); char *sob(char *); char *son(char *); --- 180,186 ---- void dotrim(struct conf_entry *); int log_trim(char *); void compress_log(struct conf_entry *); ! off_t sizefile(char *); int age_old_log(struct conf_entry *); char *sob(char *); char *son(char *); *************** *** 301,307 **** void do_entry(struct conf_entry *ent) { ! int modtime, size; struct stat sb; if (lstat(ent->log, &sb) != 0) --- 301,308 ---- void do_entry(struct conf_entry *ent) { ! int modtime; ! off_t size; struct stat sb; if (lstat(ent->log, &sb) != 0) *************** *** 323,329 **** DPRINTF(("does not exist.\n")); } else { if (ent->size > 0) ! DPRINTF(("size (Kb): %d [%d] ", size, ent->size)); if (ent->hours > 0) DPRINTF(("age (hr): %d [%d] ", modtime, ent->hours)); if (monitormode && ent->flags & CE_MONITOR) --- 324,331 ---- DPRINTF(("does not exist.\n")); } else { if (ent->size > 0) ! DPRINTF(("size (KB): %.2f [%d] ", size / 1024.0, ! (int)(ent->size / 1024))); if (ent->hours > 0) DPRINTF(("age (hr): %d [%d] ", modtime, ent->hours)); if (monitormode && ent->flags & CE_MONITOR) *************** *** 553,559 **** q = parse = missing_field(sob(++parse), errline); *(parse = son(parse)) = '\0'; if (isdigit(*q)) ! working->size = atoi(q); else working->size = -1; --- 555,561 ---- q = parse = missing_field(sob(++parse), errline); *(parse = son(parse)) = '\0'; if (isdigit(*q)) ! working->size = atoi(q) * 1024; else working->size = -1; *************** *** 842,855 **** } /* Return size in kilobytes of a file */ ! int sizefile(char *file) { struct stat sb; if (stat(file, &sb) < 0) return (-1); ! return (sb.st_blocks / (1024.0 / DEV_BSIZE)); } /* Return the age (in hours) of old log file (file.0), or -1 if none */ --- 844,862 ---- } /* Return size in kilobytes of a file */ ! off_t sizefile(char *file) { struct stat sb; if (stat(file, &sb) < 0) return (-1); ! ! /* 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 */