[comp.lang.perl] truncate

jsb@cs.brown.edu (John Bazik) (08/02/90)

Is it possible to truncate an open file in perl?  (like truncate(2)).

I don't see it in the man page.

John Bazik
jsb@cs.brown.edu

lwall@jpl-devvax.JPL.NASA.GOV (Larry Wall) (08/03/90)

In article <46447@brunix.UUCP> jsb@cs.brown.edu (John Bazik) writes:
: Is it possible to truncate an open file in perl?  (like truncate(2)).

It will be after the next patch, if your machine supports it.

Larry

ronald@robobar.co.uk (Ronald S H Khoo) (08/04/90)

In article <8977@jpl-devvax.JPL.NASA.GOV> lwall@jpl-devvax.JPL.NASA.GOV (Larry Wall) writes:

>: Is it possible to truncate an open file in perl?  (like truncate(2)).
>
>It will be after the next patch, if your machine supports it.

I hope you won't forget those of us who pronounce "ftruncate" as
"chsize" and have to utter -lx to load it when hacking Configure ...

BTW are you going to consider allowing limited setting of $< on systems
that don't set[re]uid  as was suggested some time back ?  I can't remember
who it was who suggested a nice way to hack that, but whoever you are, if you
did implement it, can you mail me your patch ? I'll buy you a few beers
at the next London Unix User Group meet you manage to attend :-)
-- 
Eunet: Ronald.Khoo@robobar.Co.Uk  Phone: +44 81 991 1142  Fax: +44 81 998 8343
Paper: Robobar Ltd. 22 Wadsworth Road, Perivale, Middx., UB6 7JD ENGLAND.

pim@cti-software.nl (Pim Zandbergen) (08/05/90)

ronald@robobar.co.uk (Ronald S H Khoo) writes:


>I hope you won't forget those of us who pronounce "ftruncate" as
>"chsize" and have to utter -lx to load it when hacking Configure ...

Or those who have to play with fcntl(F_FREESP) to accomplish
the same (System V Release 3).
-- 
Pim Zandbergen                            domain : pim@cti-software.nl
CTI Software BV                           uucp   : uunet!mcsun!hp4nl!ctisbv!pim
Laan Copes van Cattenburch 70             phone  : +31 70 3542302
2585 GD The Hague, The Netherlands        fax    : +31 70 3512837

lwall@jpl-devvax.JPL.NASA.GOV (Larry Wall) (08/07/90)

In article <1990Aug4.154852.6468@robobar.co.uk> ronald@robobar.co.uk (Ronald S H Khoo) writes:
: In article <8977@jpl-devvax.JPL.NASA.GOV> lwall@jpl-devvax.JPL.NASA.GOV (Larry Wall) writes:
: 
: >: Is it possible to truncate an open file in perl?  (like truncate(2)).
: >
: >It will be after the next patch, if your machine supports it.
: 
: I hope you won't forget those of us who pronounce "ftruncate" as
: "chsize" and have to utter -lx to load it when hacking Configure ...

Ok, it's in there, presuming chsize has the same arguments as ftruncate.
You'll have utter -lx to Configure yourself.

: BTW are you going to consider allowing limited setting of $< on systems
: that don't set[re]uid  as was suggested some time back ?  I can't remember
: who it was who suggested a nice way to hack that, but whoever you are, if you
: did implement it, can you mail me your patch ? I'll buy you a few beers
: at the next London Unix User Group meet you manage to attend :-)

You'll be able to say $< = $> and $> = $<.  The patch will look like this
(This is not an offical patch!!!  If you apply it, expect two rejected hunks
on the next official patch!!!):

*** /tmp/,RCSt1018459	Mon Aug  6 10:37:13 1990
--- stab.c	Mon Aug  6 10:31:46 1990
***************
***************
*** 366,372 ****
  	    if (setreuid((UIDTYPE)uid, (UIDTYPE)-1) < 0)
  		uid = (int)getuid();
  #else
! 	    fatal("setruid() not implemented");
  #endif
  #endif
  	    break;
--- 387,396 ----
  	    if (setreuid((UIDTYPE)uid, (UIDTYPE)-1) < 0)
  		uid = (int)getuid();
  #else
! 	    if (uid == euid)		/* special case $< = $> */
! 		setuid(uid);
! 	    else
! 		fatal("setruid() not implemented");
  #endif
  #endif
  	    break;
***************
*** 386,392 ****
  	    if (setreuid((UIDTYPE)-1, (UIDTYPE)euid) < 0)
  		euid = (int)geteuid();
  #else
! 	    fatal("seteuid() not implemented");
  #endif
  #endif
  	    break;
--- 410,419 ----
  	    if (setreuid((UIDTYPE)-1, (UIDTYPE)euid) < 0)
  		euid = (int)geteuid();
  #else
! 	    if (euid == uid)		/* special case $> = $< */
! 		setuid(euid);
! 	    else
! 		fatal("seteuid() not implemented");
  #endif
  #endif
  	    break;

Can I trade the beers for airfare?   :-)

Larry

clewis@eci386.uucp (Chris Lewis) (08/08/90)

> In article <1990Aug4.154852.6468@robobar.co.uk> ronald@robobar.co.uk (Ronald S H Khoo) writes:

(to Larry)

: BTW are you going to consider allowing limited setting of $< on systems
: that don't set[re]uid  as was suggested some time back ?  I can't remember
: who it was who suggested a nice way to hack that, but whoever you are, if you
: did implement it, can you mail me your patch ? I'll buy you a few beers
: at the next London Unix User Group meet you manage to attend :-)

You mean in addition to the one you already owe me for psroff? ;-)

Unfortunately, I didn't implement it, I made my program setuid root as
a workaround.  I guess you owe Larry...
-- 
Chris Lewis, Elegant Communications Inc, {uunet!attcan,utzoo}!lsuc!eci386!clewis
Ferret mailing list: eci386!ferret-list, psroff mailing list: eci386!psroff-list
Psroff information/questions: psroff-request@eci386