Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 12 Aug 2007 14:42:41 +0200
From:      Dirk GOUDERS <gouders@et.bocholt.fh-ge.de>
To:        David Wolfskill <david@catwhisker.org>
Cc:        Joost Bekkers <joost@jodocus.org>, FreeBSD-hackers@freebsd.org
Subject:   Re: [PATCH] newsyslog - don't compress first log file 
Message-ID:  <200708121242.l7CCgfQc060307@sora.hank.home>
In-Reply-To: <20070811151054.GE77008@bunrab.catwhisker.org> 
References:  <46BC49DB.8060509@latnet.lv> <20070810161318.GX77008@bunrab.catwhisker.org> <1064.192.168.100.227.1186841549.squirrel@jodocus.org> <200708111439.l7BEdgAr045640@sora.hank.home> <20070811151054.GE77008@bunrab.catwhisker.org>

next in thread | previous in thread | raw e-mail | index | archive | help
------- =_aaaaaaaaaa0
Content-Type: text/plain; charset="us-ascii"
Content-ID: <60275.1186922359.1@sora.hank.home>

> Ah -- well, then: by all means.  I'm even more willing to test other
> folks' work than I am to hack away at code. :-}
> 
> And since I had tested my own Perl script, I think I should be able to
> help out with this.  :-)
> 
> And "after Sunday" is not a problem at all:  thank you!

I tested the changes that allow to specify that n logfiles should not
be compressed and attach a patch for version 1.107 of newsyslog.c to
this mail.  The changes do not handle cases of changes to the
configfile while compressed and uncompressed logfiles already exist.

Again, here is a configfile example:

# logfilename          [owner:group]    mode count size when  flags [/pid_file] [sig_num]
/var/log/example.log                    644  89    100  *     J39


Then, I have a question concerning the code:

    (void) snprintf(file1, sizeof(file1), "%s.%d", ent->log,
        ent->numlogs);
    (void) snprintf(zfile1, sizeof(zfile1), "%s%s", file1,
        COMPRESS_POSTFIX);
    snprintf(jfile1, sizeof(jfile1), "%s%s", file1,
        BZCOMPRESS_POSTFIX);

Is there a reason why the third call of snprintf is not casted to
(void)?

Dirk


------- =_aaaaaaaaaa0
Content-Type: text/plain; name="newsyslog.patch"; charset="us-ascii"
Content-ID: <60275.1186922359.2@sora.hank.home>
Content-Description: newsyslog.patch

--- newsyslog.c.orig	Sun Aug 12 14:13:38 2007
+++ newsyslog.c	Sun Aug 12 14:36:51 2007
@@ -127,6 +127,8 @@
 	struct ptime_data *trim_at;	/* Specific time to do trimming */
 	unsigned int permissions;	/* File permissions on the log */
 	int flags;		/* CE_COMPACT, CE_BZCOMPACT, CE_BINARY */
+	int nuncompact;		/* number of rotations that should not
+				 * be compressed; -1 turns this off */
 	int sig;		/* Signal to send */
 	int def_cfg;		/* Using the <default> rule for this file */
 	struct conf_entry *next;/* Linked list pointer */
@@ -1187,6 +1189,11 @@
 		}
 
 		for (; q && *q && !isspacech(*q); q++) {
+			if (isdigit(*q)) {
+				working->nuncompact = strtol(q, NULL, 10);
+				while(isdigit(*(q+1))) q++;
+				continue;
+			}
 			switch (tolowerch(*q)) {
 			case 'b':
 				working->flags |= CE_BINARY;
@@ -1456,6 +1463,12 @@
 			(void)rename(zfile1, zfile2);
 		}
 		change_attrs(zfile2, ent);
+		if ((flags & (CE_COMPACT | CE_BZCOMPACT)) &&
+		    (ent->nuncompact != -1) &&
+		    (numlogs_c == ent->nuncompact)) {
+			free_or_keep = KEEP_ENT;
+			save_zipwork(ent, NULL, ent->fsize, file2);
+		}
 	}
 
 	if (ent->numlogs > 0) {
@@ -1494,7 +1507,8 @@
 	swork = NULL;
 	if (ent->pid_file != NULL)
 		swork = save_sigwork(ent);
-	if (ent->numlogs > 0 && (flags & (CE_COMPACT | CE_BZCOMPACT))) {
+	if (ent->numlogs > 0 && (flags & (CE_COMPACT | CE_BZCOMPACT))
+	    && ent->nuncompact == -1) {
 		/*
 		 * The zipwork_entry will include a pointer to this
 		 * conf_entry, so the conf_entry should not be freed.

------- =_aaaaaaaaaa0--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200708121242.l7CCgfQc060307>