9fans archive / 2000 / 04 / 29 / prev next
From: Tom Duff td@pix...
Subject: [9fans] truncate syscall
Date: Mon, 10 Apr 2000 10:18:05 -0700
> mmap(). truncate() is a bad name - it's setsize(). IOW, it can extend
> files. Add the mmap() semantics in that respect and there you go -
> open()/ftruncate() to set the size/mmap() the region/start working; is
> quite common. Yes, you can kludge around it with lseek();write(); but
> that's a kludge, unless we accept that zero-length write() changes the
> file size. Which is not true under a lot of Unices (I seriously suspect
> that it's explicitly prohibited by POSIX or something like that).
int f=create("file", OREAD, 0666);
if(n){
seek(f, n-1, 0);
write(f, "", 1);
}
What exactly is kludgy about this?
I've been using UNIX & Plan 9 for 26 years,
and not once have I wanted to chop the tail
off a file. I find it really hard to believe
that you need this so badly that you want to
change 9p. Why can't you afford to rewrite
the file?
--
Tom Duff. This work was funded by The Corporation for Public Vaporware.