Re: How to remove a single line from a flat file (Still very off-topic.)
- From: Darren New <dnew@xxxxxxxxxx>
- Date: Sat, 19 May 2007 11:19:22 -0700
Eric wrote:
But the fact that if you want to (say) edit the syslog file you have to turn off syslog (so it's not writing to the file while you edit it), that tells me you're missing something in the kernel.
If you need to edit it, it's not a log file.
Editting includes rotating the log file, removing old entries, etc.
So you want to allow infinite log files?
Sure, why not? NTFS does, as well as anything else where you can delete from the front of the file without messing up the back of the file. Look up, for example, how the USN journal is implemented. Each entry has a unique serial number, which is the lseek() offset in the journal file where the entry was written. Entries get deleted off the front, but that doesn't change where the later entries are - it just reclaims the space for entries that everyone has presumedly seen.
Anything that writes a log
should have a way of splitting "old" from "current"
And that's my point. Every program that writes a log file under UNIX needs a way to split the old from the current. If *every* program has to implement a mechanism for doing something with a file, wouldn't it make sense to put that in the file system?
As it is, it's fairly difficult to split a log file at a precise boundary, such as exactly at midnight, unless it's built into the program that happens to be writing the log file, and you know in advance that's what you want to do. (BTDT.)
Contrast with a file system that actually stores records you can delete. Simply open the log file, copy the records you want to "rotate", and delete them off the front of the log file as you go. You can even delete "normal" records and keep the "abnormal" records in the log file, for example. I've never seen, for example, anyone write a "SQL Table Rotate" program. You just select into another table, and delete from the original, and you rotate exactly the records you want to rotate.
Missing? If two processes need to change the same thing you need a
lock (type unspecified).
Yes. And that lock (or contention resolution) should be in the file system, rather than as a user-level work-around for a lack of functionality. I shouldn't have to lock the entire file to delete one message out of it. I shouldn't need 2G of disk space to delete data from a file holding 1G of data. Try working with a 40-gig tar file some time, trying to keep it synced to a directory tree somewhere, just for example. It takes way longer than syncing two file systems, because you have to frob 80 gig of data for every operation. As data gets bigger, this will get more and more painful over time, to the point where folks with big data are already reimplementing the file system in various ways to use better semantics.
If I could delete individual records from a file, sendmail could just append messages as new records, and my MUA could delete anything already there, and neither of us would have to explicitly lock the file. Of course, there would be locking of some sort inside the code implementing the file system, but that's where it belongs, so everyone can use it consistently.
Note that you can say "well, implement that sort of thing yourself", but then all your tools like grep and CRM114 and all that have to know your privileged file format.
If you think "work-around" you will do the wrong thing. Unix/Linux is
a low-level platform.
That's what I'm saying, yes. The things I mention are work-arounds for the fact that Linux is a low-level platform. You may not view them that way, but I've used enough FSes to view them that way.
I program mostly in Tcl, too, because C is a low-level platform. Anything I want to do in Tcl, I can obviously do in C also. That doesn't mean that C is as good as Tcl.
--
Darren New / San Diego, CA, USA (PST)
His kernel fu is strong.
He studied at the Shao Linux Temple.
.
- Follow-Ups:
- Re: How to remove a single line from a flat file (Still very off-topic.)
- From: Larry W. Virden
- Re: How to remove a single line from a flat file (Still very off-topic.)
- From: Donal K. Fellows
- Re: How to remove a single line from a flat file (Still very off-topic.)
- References:
- Re: How to remove a single line from a flat file
- From: Larry W. Virden
- Re: How to remove a single line from a flat file
- From: Atte Kojo
- Re: How to remove a single line from a flat file
- From: Larry W. Virden
- Re: How to remove a single line from a flat file
- From: Darren New
- Re: How to remove a single line from a flat file
- From: billposer
- Re: How to remove a single line from a flat file
- From: Donal K. Fellows
- Re: How to remove a single line from a flat file
- From: Darren New
- Re: How to remove a single line from a flat file
- From: Atte Kojo
- Re: How to remove a single line from a flat file
- From: Darren New
- Re: How to remove a single line from a flat file
- From: Eric
- Re: How to remove a single line from a flat file
- Prev by Date: Re: TCLers Unite! COM question
- Next by Date: Re: tklib tooltips don't work on menu items?
- Previous by thread: Re: How to remove a single line from a flat file
- Next by thread: Re: How to remove a single line from a flat file (Still very off-topic.)
- Index(es):
Relevant Pages
|
|