From owner-freebsd-arch Fri Feb 14 19:55:56 2003 Delivered-To: freebsd-arch@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 6CF4237B401 for ; Fri, 14 Feb 2003 19:55:54 -0800 (PST) Received: from puffin.mail.pas.earthlink.net (puffin.mail.pas.earthlink.net [207.217.120.139]) by mx1.FreeBSD.org (Postfix) with ESMTP id A7A4043FB1 for ; Fri, 14 Feb 2003 19:55:53 -0800 (PST) (envelope-from tlambert2@mindspring.com) Received: from pool0018.cvx21-bradley.dialup.earthlink.net ([209.179.192.18] helo=mindspring.com) by puffin.mail.pas.earthlink.net with asmtp (SSLv3:RC4-MD5:128) (Exim 3.33 #1) id 18jtQZ-0004cf-00; Fri, 14 Feb 2003 19:55:48 -0800 Message-ID: <3E4DB9F1.83B7746D@mindspring.com> Date: Fri, 14 Feb 2003 19:54:25 -0800 From: Terry Lambert X-Mailer: Mozilla 4.79 [en] (Win98; U) X-Accept-Language: en MIME-Version: 1.0 To: Wes Peters Cc: Gordon Tetlow , Garance A Drosihn , arch@FreeBSD.ORG Subject: Re: syslog.conf syntax change (multiple program/host specifications) References: <20030210114930.GB90800@melusine.cuivre.fr.eu.org> <20030214220145.GM83215@roark.gnf.org> <3E4D7C2B.DDFC9DBE@mindspring.com> <200302141725.00421.wes@softweyr.com> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-ELNK-Trace: b1a02af9316fbb217a47c185c03b154d40683398e744b8a4713b82fa6aa363421933c9ba2b6fea3c3ca473d225a0f487350badd9bab72f9c350badd9bab72f9c Sender: owner-freebsd-arch@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG Wes Peters wrote: > On Friday 14 February 2003 15:30, Terry Lambert wrote: > > Only newsyslog is stupid. > > > > No matter what options you gave it, the first thing it would do is > > the moral equivalent of -F. > > > > So instead of a 60M Samba log file "/var/log/samba", you ended up > > with a "/var/log/samba.1" that was 60M, and a "/var/log/samba" > > that was empty. > > The real problem we're looking at is that ftruncate(2) doesn't take a > third argument describing which end you want to truncate at. Such a > facility would end this argument quickly, syslog could simply truncate > the first (filesize - desired log size) bytes of the file and be done > with it. This would solve the immediate "file too large" problem, but it wouldn't maintain the history properly; you'd end up with 0, 40K, a 60M-40K gap in the history, and then realy old 40K x 3. Probably the right interface is "donate this block range to file X starting at block offset Q, zeroing the corresponding blocks in this file, sparsely, if you can". It's a twisty little problem, probably not worth a general API, unless you can know the block granularity on the underlying FS, at which sparse blocks existed, and constrain it to use that. BTW: the SVR4 fcntl() that's the moral equivalent of ftruncate supports exactly the syntax you want (e.g. free up space at the start of the file for 60M-120K, replacing with sparseness -- it can put sparse blocks in the middle of files). What might be more useful, in this particular case, since you want only the last 120K is a means of truncating deleting cytes off the front of a file. You'd probably want to allow any value, but in terms of avoiding rewriting, in practice, you probably want to constrain it to an even multiple of the FS block size. > Short of getting ufs2 to provide frag blocks at both ends of the file, > this is about as good as it gets. I'll get my -current system up this > weekend and have a patch to review in a few days. If you do this, just implement the SVR4 fcntl(); it basically takes an fcntl() lock structure, e.g.: fcntl( fd, F_FREESP, struct flock *) l_whence SEEK_SET/SEEK_CUR/SEEK_END l_start l_len FWIW, the manual allows restriction to the end of the file, but in practice, that's not what happens on SVR4 systems. -- Terry To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-arch" in the body of the message