Created
August 13, 2010 19:46
-
-
Save crabtw/523450 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- newsyslog.c.orig 2010-08-14 03:18:48.154320748 +0800 | |
+++ newsyslog.c 2010-08-14 03:48:46.760806262 +0800 | |
@@ -106,6 +106,7 @@ | |
/* process when trimming this file. */ | |
#define CE_CREATE 0x0100 /* Create the log file if it does not exist. */ | |
#define CE_NODUMP 0x0200 /* Set 'nodump' on newly created log file. */ | |
+#define CE_ACTUALSIZE 0x0400 /* Use actual file size */ | |
#define MIN_PID 5 /* Don't touch pids lower than this */ | |
#define MAX_PID 99999 /* was lower, see /usr/include/sys/proc.h */ | |
@@ -228,7 +229,7 @@ | |
save_zipwork(const struct conf_entry *, const struct | |
sigwork_entry *, int, const char *); | |
static void set_swpid(struct sigwork_entry *, const struct conf_entry *); | |
-static int sizefile(const char *); | |
+static int sizefile(const char *, int); | |
static void expand_globs(struct cflist *work_p, struct cflist *glob_p); | |
static void free_clist(struct cflist *list); | |
static void free_entry(struct conf_entry *ent); | |
@@ -456,7 +457,7 @@ | |
else | |
printf("%s <%d>: ", ent->log, ent->numlogs); | |
} | |
- ent->fsize = sizefile(ent->log); | |
+ ent->fsize = sizefile(ent->log, ent->flags & CE_ACTUALSIZE); | |
modtime = age_old_log(ent->log); | |
ent->rotate = 0; | |
ent->firstcreate = 0; | |
@@ -1275,6 +1276,9 @@ | |
case 'z': | |
working->flags |= CE_COMPACT; | |
break; | |
+ case 's': | |
+ working->flags |= CE_ACTUALSIZE; | |
+ break; | |
case '-': | |
break; | |
case 'f': /* Used by OpenBSD for "CE_FOLLOW" */ | |
@@ -1992,7 +1996,7 @@ | |
/* Compute the size if the caller did not know it. */ | |
if (zsize < 0) | |
- zsize = sizefile(zipfname); | |
+ zsize = sizefile(zipfname, 0); | |
zprev = NULL; | |
ndiff = 1; | |
@@ -2127,13 +2131,17 @@ | |
/* Return size in kilobytes of a file */ | |
static int | |
-sizefile(const char *file) | |
+sizefile(const char *file, int actual_size) | |
{ | |
struct stat sb; | |
if (stat(file, &sb) < 0) | |
return (-1); | |
- return (kbytes(dbtob(sb.st_blocks))); | |
+ | |
+ if (actual_size) | |
+ return (kbytes(sb.st_size)); | |
+ else | |
+ return (kbytes(dbtob(sb.st_blocks))); | |
} | |
/* Return the age of old log file (file.0) */ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment