From owner-freebsd-hackers@FreeBSD.ORG Sun Aug 12 12:39:15 2007 Return-Path: Delivered-To: FreeBSD-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id F16E316A417 for ; Sun, 12 Aug 2007 12:39:15 +0000 (UTC) (envelope-from gouders@et.bocholt.fh-gelsenkirchen.de) Received: from alice.et.bocholt.fh-ge.de (alice.et.bocholt.fh-gelsenkirchen.de [193.175.197.63]) by mx1.freebsd.org (Postfix) with ESMTP id 78E0E13C459 for ; Sun, 12 Aug 2007 12:39:14 +0000 (UTC) (envelope-from gouders@et.bocholt.fh-gelsenkirchen.de) Received: from musashi.et.bocholt.fh-gelsenkirchen.de (musashi.et.bocholt.fh-gelsenkirchen.de [193.175.197.95]) by alice.et.bocholt.fh-ge.de (8.13.7/8.13.7) with ESMTP id l7CCcUMP030986 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Sun, 12 Aug 2007 14:38:30 +0200 Received: from sora.hank.home ([10.8.0.6]) by musashi.et.bocholt.fh-gelsenkirchen.de (8.14.1/8.14.1) with ESMTP id l7CCcDZZ082948; Sun, 12 Aug 2007 14:38:13 +0200 (CEST) (envelope-from hank@et.bocholt.fh-gelsenkirchen.de) Received: from localhost (localhost.hank.home [127.0.0.1]) by sora.hank.home (8.14.1/8.14.1) with ESMTP id l7CCgfQc060307; Sun, 12 Aug 2007 14:42:41 +0200 (CEST) (envelope-from hank@sora.hank.home) Message-Id: <200708121242.l7CCgfQc060307@sora.hank.home> To: David Wolfskill 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> Comments: In-reply-to David Wolfskill message dated "Sat, 11 Aug 2007 08:10:54 -0700." MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0" Content-ID: <60275.1186922359.0@sora.hank.home> Date: Sun, 12 Aug 2007 14:42:41 +0200 From: Dirk GOUDERS X-Bounce: 0/8 X-Scanned-By: MIMEDefang 2.57 on 192.168.0.63 Cc: Joost Bekkers , FreeBSD-hackers@freebsd.org Subject: Re: [PATCH] newsyslog - don't compress first log file X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 12 Aug 2007 12:39:16 -0000 ------- =_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 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--