Date: Wed, 15 Jan 1997 23:02:40 +0000 From: Brian Somers <brian@awfulhak.demon.co.uk> To: Terry Lambert <terry@lambert.org> Cc: stesin@gu.net, karpen@ocean.campus.luth.se, hackers@freebsd.org Subject: Re: truss, trace ?? Message-ID: <199701152302.XAA14961@awfulhak.demon.co.uk> In-Reply-To: Your message of "Tue, 14 Jan 1997 09:46:17 MST." <199701141646.JAA29888@phaeton.artisoft.com>
next in thread | previous in thread | raw e-mail | index | archive | help
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 <brian@awfulhak.demon.co.uk>, <brian@freebsd.org> <http://www.awfulhak.demon.co.uk/> Don't _EVER_ lose your sense of humour....
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199701152302.XAA14961>