9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
* [9fans] truncate syscall
@ 2000-04-10 13:33 Roman
  0 siblings, 0 replies; 13+ messages in thread
From: Roman @ 2000-04-10 13:33 UTC (permalink / raw)


Hi,

does somebody know if there is a [f]truncate syscall in Plan 9? Or it it is not
there, may be someone could suggest the similar functionality?

Thanks,
Roman.




^ permalink raw reply	[flat|nested] 13+ messages in thread

* [9fans] truncate syscall
@ 2000-04-11  7:12 Bengt
  0 siblings, 0 replies; 13+ messages in thread
From: Bengt @ 2000-04-11  7:12 UTC (permalink / raw)


> From: jmk@plan9.bell-labs.com
> just out of curiosity, what are the practical uses of truncation

I use truncation (in a comm library for miniml Posix systems, ie AS400 too)
to make sure that a shared file (both sides have a file descriptor to it) only
contains the new data. The other side reads the whole file and knows that is all.


Best Wishes, Bengt
===============================================================
Everything aforementioned should be regarded as totally private
opinions, and nothing else. bengt@softwell.se
``His great strength is that he is uncompromising. It would make
him physically ill to think of programming in C++.''




^ permalink raw reply	[flat|nested] 13+ messages in thread

* [9fans] truncate syscall
@ 2000-04-10 18:01 Tom
  0 siblings, 0 replies; 13+ messages in thread
From: Tom @ 2000-04-10 18:01 UTC (permalink / raw)


On Apr 10, 10:18am, Tom Duff wrote:
> Subject: Re: [9fans] truncate syscall
> > 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);
> 	}
Also, Plan 9 doesn't have mmap, does it?
Certainly it's missing from ape.

-- 
Tom Duff.  If it's in stock, we've got it.




^ permalink raw reply	[flat|nested] 13+ messages in thread

* [9fans] truncate syscall
@ 2000-04-10 17:59 gdb
  0 siblings, 0 replies; 13+ messages in thread
From: gdb @ 2000-04-10 17:59 UTC (permalink / raw)


Instead of fsync I  made each 9P message atomic using a log.

>---- Original Message ---
>From: Scott Schwartz <schwartz@bio.cse.psu.edu>
>To: 9fans@cse.psu.edu
>Cc: 
>Subject: Re: [9fans] truncate syscall
>
>I don't know about ftruncate, but I sometimes miss fsync.





^ permalink raw reply	[flat|nested] 13+ messages in thread

* [9fans] truncate syscall
@ 2000-04-10 17:41 Alexander
  0 siblings, 0 replies; 13+ messages in thread
From: Alexander @ 2000-04-10 17:41 UTC (permalink / raw)




On Mon, 10 Apr 2000, Tom Duff wrote:

> > 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?

Almost noting (except that you may want to change the size of existing
file and thus it turns into lseek(...,SEEK_END) and comparing the sizes).
However, I suspect that I know the reason why this question appeared -
implementation of 9p _client_. And ->setattr() or equivalents in many
variants of VFS allow changing the size. So it boils down to graceful
error value or finding a way to do it over 9p...

> 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?

Usually OK for applications, but putting this kind of code into the
kernel... Ewww...





^ permalink raw reply	[flat|nested] 13+ messages in thread

* [9fans] truncate syscall
@ 2000-04-10 17:36 Tom
  0 siblings, 0 replies; 13+ messages in thread
From: Tom @ 2000-04-10 17:36 UTC (permalink / raw)


> 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.




^ permalink raw reply	[flat|nested] 13+ messages in thread

* [9fans] truncate syscall
@ 2000-04-10 17:36 Tom
  0 siblings, 0 replies; 13+ messages in thread
From: Tom @ 2000-04-10 17:36 UTC (permalink / raw)


On Apr 10, 10:18am, Tom Duff wrote:
> Subject: Re: [9fans] truncate syscall
> > 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);
> 	}
Also, Plan 9 doesn't have mmap, does it?
Certainly it's missing from ape.

-- 
Tom Duff.  If it's in stock, we've got it.




^ permalink raw reply	[flat|nested] 13+ messages in thread

* [9fans] truncate syscall
@ 2000-04-10 17:18 Tom
  0 siblings, 0 replies; 13+ messages in thread
From: Tom @ 2000-04-10 17:18 UTC (permalink / raw)


> 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.




^ permalink raw reply	[flat|nested] 13+ messages in thread

* [9fans] truncate syscall
@ 2000-04-10 17:00 Alexander
  0 siblings, 0 replies; 13+ messages in thread
From: Alexander @ 2000-04-10 17:00 UTC (permalink / raw)




On Mon, 10 Apr 2000 jmk@plan9.bell-labs.com 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).





^ permalink raw reply	[flat|nested] 13+ messages in thread

* [9fans] truncate syscall
@ 2000-04-10 16:51 Scott
  0 siblings, 0 replies; 13+ messages in thread
From: Scott @ 2000-04-10 16:51 UTC (permalink / raw)


I don't know about ftruncate, but I sometimes miss fsync.




^ permalink raw reply	[flat|nested] 13+ messages in thread

* [9fans] truncate syscall
@ 2000-04-10 16:45 jmk
  0 siblings, 0 replies; 13+ messages in thread
From: jmk @ 2000-04-10 16:45 UTC (permalink / raw)


just out of curiosity, what are the practical uses of truncation
(other than to 0-length)?




^ permalink raw reply	[flat|nested] 13+ messages in thread

* [9fans] truncate syscall
@ 2000-04-10 16:23 gdb
  0 siblings, 0 replies; 13+ messages in thread
From: gdb @ 2000-04-10 16:23 UTC (permalink / raw)


Yeah wstat, that is what I thought.
Since I have already gone there perhaps I could add that too.  Is there any interest in this functionality?

>---- Original Message ---
>From: "Russ Cox" <rsc@plan9.bell-labs.com>
>To: 9fans@cse.psu.edu
>Cc: 
>Subject: Re: [9fans] truncate syscall
>
>  does somebody know if there is a [f]truncate syscall in Plan 9? Or it it is not
>  there, may be someone could suggest the similar functionality?
>There is none, and there is no way to
>implement it, as 9P does not support
>such a thing.  I suppose if you were
>really dying to have it, you could make
>wstat pay attention to the length, but
>that would be a departure from the
>9P definition.
>Russ





^ permalink raw reply	[flat|nested] 13+ messages in thread

* [9fans] truncate syscall
@ 2000-04-10 15:48 Russ
  0 siblings, 0 replies; 13+ messages in thread
From: Russ @ 2000-04-10 15:48 UTC (permalink / raw)


  does somebody know if there is a [f]truncate syscall in Plan 9? Or it it is not
  there, may be someone could suggest the similar functionality?

There is none, and there is no way to
implement it, as 9P does not support
such a thing.  I suppose if you were
really dying to have it, you could make
wstat pay attention to the length, but
that would be a departure from the
9P definition.

Russ





^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2000-04-11  7:12 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2000-04-10 13:33 [9fans] truncate syscall Roman
2000-04-10 15:48 Russ
2000-04-10 16:23 gdb
2000-04-10 16:45 jmk
2000-04-10 16:51 Scott
2000-04-10 17:00 Alexander
2000-04-10 17:18 Tom
2000-04-10 17:36 Tom
2000-04-10 17:36 Tom
2000-04-10 17:41 Alexander
2000-04-10 17:59 gdb
2000-04-10 18:01 Tom
2000-04-11  7:12 Bengt

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).