truncating a file opened via open()
Larry Campbell
campbell at maynard.UUCP
Wed Jun 19 22:03:49 AEST 1985
> > >In article <340 at cmu-cs-edu1.ARPA> hua at cmu-cs-edu1.ARPA (Ernest Hua) writes:
> > >>Does anyone have any idea how to truncate a file at the current point in
> > >>writing if it is opened by open()?
>
> There are precisely two solutions for non-4.2BSD systems:
> 1) implement (f)truncate on your system...
Kind of tough for people without source licenses (I know, I'm whining).
> 2) Copy the entire file, up to the point of truncation, to a temporary file,
> then copy it back to the original file.
>
> Guy Harris
I don't see how this works unless you unlink the file and then re-creat
it before writing it back. But the original question implied you only had
a descriptor for the file, not a name... so you can't unlink or re-creat
it. And even if you knew the name, other links wouldn't get truncated.
Sounds like it's pretty tough to fake this one ... sigh ...
- Larry Campbell
The Boston Software Works, Inc., 120 Fulton St., Boston MA 02109
UUCP: {decvax, security, linus, mit-eddie}!genrad!enmasse!maynard!campbell
ARPA: decvax!genrad!enmasse!maynard!campbell at DECWRL.ARPA
More information about the Comp.unix.wizards
mailing list