From owner-freebsd-hackers Wed Jan 15 16:35:59 1997 Return-Path: Received: (from root@localhost) by freefall.freebsd.org (8.8.4/8.8.4) id QAA10123 for hackers-outgoing; Wed, 15 Jan 1997 16:35:59 -0800 (PST) Received: from awfulhak.demon.co.uk (awfulhak.demon.co.uk [158.152.17.1]) by freefall.freebsd.org (8.8.4/8.8.4) with ESMTP id QAA10110 for ; Wed, 15 Jan 1997 16:35:55 -0800 (PST) Received: from awfulhak.demon.co.uk (localhost.coverform.lan [127.0.0.1]) by awfulhak.demon.co.uk (8.8.4/8.7.3) with ESMTP id XAA14961; Wed, 15 Jan 1997 23:02:41 GMT Message-Id: <199701152302.XAA14961@awfulhak.demon.co.uk> X-Mailer: exmh version 1.6.9 8/22/96 To: Terry Lambert cc: stesin@gu.net, karpen@ocean.campus.luth.se, hackers@freebsd.org Subject: Re: truss, trace ?? In-reply-to: Your message of "Tue, 14 Jan 1997 09:46:17 MST." <199701141646.JAA29888@phaeton.artisoft.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Date: Wed, 15 Jan 1997 23:02:40 +0000 From: Brian Somers Sender: owner-hackers@freebsd.org X-Loop: FreeBSD.org Precedence: bulk Terry Lambert wrote: > > > Cyclic file types imply record orientation. > > [.....] > > > > Unless of course you don't mind having a truncated line at the start > > of your log ;) > > > > This (IMHO) would be more "natural", 'cos there shouldn't be any > > "record" knowledge at that level. > > "Natural" for text files, maybe. > > For the wtmp file, it's not so natural... it's wierd, even, since you > can't resync to a valid record boundry without sync data built into > the data format. > > For text files, the sync data can be "after the first \n", since it > is a variable length record format with "\n" record seperators, but > how do you resync wtmp? I'd tend to approach it with a new fs driver. Using this driver, the only way to change a file size is using truncate(). A write() will always succeed and will wrap when hitting EOF. The fs holds an internal "start" offset ("end"+1), and lseek will seek to pos%filesize. read() can return zero when it hits the internal "start" offset. With this, fixed record lengths can be dealt with by making sure you truncate() the file to a multiple of the record size, and variable records are not supported (you end up with front-truncated lines). The alternative is to maintain a whopping great list of write() sizes so that you can maintain a different "start" and "end" pointer. The only inconsistency is that the following code is broken: off_t pos = lseek (fd, 0, 1); close (fd); fd = open( file, O_RDWR ); lseek( fd, pos, 0 ); but then, doing this with log files and newsyslog running around moving them is dodgy anyway. -- Brian , Don't _EVER_ lose your sense of humour....