From mboxrd@z Thu Jan 1 00:00:00 1970 Date: Mon, 10 Apr 2000 17:36:53 +0000 From: Tom Duff td@pixar.com Subject: [9fans] truncate syscall Topicbox-Message-UUID: a1536a66-eac8-11e9-9e20-41e7f4b1d025 Message-ID: <20000410173653.bwaF7C25C3FExCYm402lhMt9Rl3ehxea_fbAU6N5rpg@z> > 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.