* [9fans] how to truncate a file?
@ 2004-10-15 0:29 YAMANASHI Takeshi
2004-10-15 0:41 ` geoff
0 siblings, 1 reply; 5+ messages in thread
From: YAMANASHI Takeshi @ 2004-10-15 0:29 UTC (permalink / raw)
To: 9fans
Is there an idiom for truncationg a file in Plan 9?
I'm suspecting it's not easy because APE ftruncate is written as:
/sys/src/ape/lib/ap/plan9/ftruncate.c
int
ftruncate(int fd, off_t length)
{
errno = EINVAL;
return -1;
}
There is OTRUNC mode, but I would like to chop off a file from
a certain position to the end of the file.
--
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [9fans] how to truncate a file?
2004-10-15 0:29 [9fans] how to truncate a file? YAMANASHI Takeshi
@ 2004-10-15 0:41 ` geoff
2004-10-15 0:52 ` Russ Cox
0 siblings, 1 reply; 5+ messages in thread
From: geoff @ 2004-10-15 0:41 UTC (permalink / raw)
To: 9fans
In theory, wstat with the desired file length will do it, though ken's
fs doesn't implement it currently. I'll take another look at how hard
it would be to do.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [9fans] how to truncate a file?
2004-10-15 0:41 ` geoff
@ 2004-10-15 0:52 ` Russ Cox
0 siblings, 0 replies; 5+ messages in thread
From: Russ Cox @ 2004-10-15 0:52 UTC (permalink / raw)
To: Fans of the OS Plan 9 from Bell Labs
ape's ftruncate predates 9P2000. on fossil you can use
int
ftruncate(int fd, vlong length)
{
Dir d;
nulldir(&d);
d.length = length;
return dirfwstat(fd, &d);
}
russ
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [9fans] how to truncate a file?
@ 2004-10-15 2:04 YAMANASHI Takeshi
0 siblings, 0 replies; 5+ messages in thread
From: YAMANASHI Takeshi @ 2004-10-15 2:04 UTC (permalink / raw)
To: 9fans
On Fri Oct 15 09:53:05 JST 2004, Russ Cox wrote:
> int
> ftruncate(int fd, vlong length)
> {
> Dir d;
> nulldir(&d);
> d.length = length;
> return dirfwstat(fd, &d);
> }
FYI, I tried and got the following results:
It worked on:
fossil
ramfs
It didn't on:
ken's fs
kfs
Thanks, again. I'm fortunate that I had moved to fossil. :)
--
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [9fans] how to truncate a file?
@ 2004-10-15 1:14 YAMANASHI Takeshi
0 siblings, 0 replies; 5+ messages in thread
From: YAMANASHI Takeshi @ 2004-10-15 1:14 UTC (permalink / raw)
To: 9fans
On Fri Oct 15 09:42:16 JST 2004, geoff@collyer.net wrote:
> In theory, wstat with the desired file length will do it, though ken's
> fs doesn't implement it currently.
Your theory seems to be approved by Russ's ftruncate.
And also, I was warned that it depends on underlying file server
if it works or not (fossil does while ken's fs doesn't).
Thanks, Geoff and Russ.
--
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2004-10-15 2:04 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-10-15 0:29 [9fans] how to truncate a file? YAMANASHI Takeshi
2004-10-15 0:41 ` geoff
2004-10-15 0:52 ` Russ Cox
2004-10-15 1:14 YAMANASHI Takeshi
2004-10-15 2:04 YAMANASHI Takeshi
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).