9fans archive / 2000 / 04 / 28 / prev next From: Alexander Viro viro@mat... Subject: [9fans] truncate syscall Date: Mon, 10 Apr 2000 13:00:44 -0400 (EDT) On Mon, 10 Apr 2000 jmk@pla... wrote: > just out of curiosity, what are the practical uses of truncation > (other than to 0-length)? 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).