[PATCH] newsyslog - don't compress first log file

Artis Caune Artis.Caune at latnet.lv
Fri Aug 10 04:35:47 PDT 2007


How about aditional flag ("X") to newsyslog, which don't compress first 
log file?
This is useful for apache.




# cat /etc/newsyslog.conf

/var/log/httpd-access.log  www:www  640  64  *  $W1D0  BCZX 
/var/run/httpd.pid  30

# ls /var/log/archive2/
httpd-access.log.0
httpd-access.log.1.gz
httpd-access.log.2.gz
httpd-access.log.3.gz


-------------- next part --------------
--- newsyslog.c.orig	Thu Aug 17 04:20:36 2006
+++ newsyslog.c	Fri Aug 10 13:59:53 2007
@@ -104,6 +104,8 @@
 #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_NOCOMPACT1	0x0400  /* Don't compact first log file. */
+
 #define	MIN_PID         5	/* Don't touch pids lower than this */
 #define	MAX_PID		99999	/* was lower, see /usr/include/sys/proc.h */
 
@@ -1228,6 +1230,9 @@
 			case 'z':
 				working->flags |= CE_COMPACT;
 				break;
+			case 'x':
+				working->flags |= CE_NOCOMPACT1;
+				break;
 			case '-':
 				break;
 			case 'f':	/* Used by OpenBSD for "CE_FOLLOW" */
@@ -1498,8 +1503,15 @@
 		 * The zipwork_entry will include a pointer to this
 		 * conf_entry, so the conf_entry should not be freed.
 		 */
-		free_or_keep = KEEP_ENT;
-		save_zipwork(ent, swork, ent->fsize, file1);
+		if (flags & (CE_NOCOMPACT1)) {
+			if (!lstat(file2, &st)) {
+				free_or_keep = KEEP_ENT;
+				save_zipwork(ent, swork, ent->fsize, file2);
+			}
+		} else {
+			free_or_keep = KEEP_ENT;
+			save_zipwork(ent, swork, ent->fsize, file1);
+		}
 	}
 
 	return (free_or_keep);


More information about the freebsd-hackers mailing list