Skip to contentSkip to conversation

on circular files and an extension to truncate()

DISCUSSION [email protected] 1 participant 1 message Mar 18, 2009

lore
Share & tools
lore
#0 lore raw

Hello,

How about extending the truncate() system call to enable truncating files from the beginning also ?
This would be useful to help handle history files (logs ...).

One step further -- and i guess many people have already thought about this:
Circular files could be introduced. I mean files whose size remains fixed when written to, with the data wrapping in a circular fashion. This would typically require an additionnal position parameter ("cursor offset") in userland stat_t structures.

So circular files would be a sub-category of regular files, where the write() system call has special handling and updates the cursor offset.

One advantage of such an implementation is that is would not depend on the filesystem, and would help in many applications in which big amounts of data is copied to another file.

I have poor knowledge of the linux kernel so i cannot see if this suggestion has annoying side-effects and/or poses compatibility issues.

However, the weaker idea of implementing truncate() with the possibility to discard data at the beginning of files, then extending the file, would help a lot.

Phil