night@pawl.rpi.edu (Trip Martin) (03/09/90)
I'm trying to port PLP to SysV, and one of the few remaining hurdles is the ftruncate system call. Does anyone know of a way of simulating that call in SysV? BTW, root access is not a problem, although I'd like to avoid using privileged operations if I can. -- Trip Martin night@pawl.rpi.edu
cpcahil@virtech.uucp (Conor P. Cahill) (03/10/90)
In article <}*~#}T@rpi.edu> night@pawl.rpi.edu (Trip Martin) writes: >I'm trying to port PLP to SysV, and one of the few remaining hurdles >is the ftruncate system call. Does anyone know of a way of simulating >that call in SysV? BTW, root access is not a problem, although I'd >like to avoid using privileged operations if I can. Get current size of file If the ftruncate size is greater than current size lseek to ftruncate size - 1 write(fd,"",1) Else if you know the name of the file create tmpfile copy file to tmpfile upto ftruncate size mv file to file.old mv tmpfile to file close(fd) fd = open file dup(fd) untile you get it to the same fd that it was before close the extra fds created by the duping Else you're SOL (unless you want to go searching around the file system to find the name of the file which can take a very long time). -- Conor P. Cahill (703)430-9247 Virtual Technologies, Inc., uunet!virtech!cpcahil 46030 Manekin Plaza, Suite 160 Sterling, VA 22170