getcwd() and friends.

Rob McMahon cudcv at warwick.ac.uk
Tue Apr 18 05:44:50 AEST 1989


In article <FLEE.89Apr6112136 at shire.cs.psu.edu> flee at shire.cs.psu.edu (Felix Lee) writes:
>Imagine.  You've unlinked a file right after you opened it, and now you've
>changed your mind.  You really do want to keep the data.  What do you do?
>
>We can help you!  We're FLINK!
>	int flink(int fd, char * path);

I think I've said this before, but I think flink(2) would be really useful in
conjuntion with open("...", O_CREAT|O_WRONLY|O_NOLINK, 0666) (or O_TEMP or
something), which would create a file which had no directory entry.

This would really clean up the creation of temporary files for things like
file transfer programs, which then wouldn't have to try and think up temporary
names, and wouldn't be in any danger of leaving garbage around in case they
died or the system crashed.  Programs that wanted temporary files which would
automatically disappear on exit could use this instead of open/unlink.

The `...' would have to be the destination of the intended flink, so that the
file could be created on the right filesystem.  Maybe the name of a directory
could be allowed in this case for temporary files which were never going to be
flinked.  It would be best if flink acted like rename, atomically replacing an
old filename if it existed.  Or maybe this should be frename, since this
conflicts with the existing `link' ?  What do people think ?  Would this be a
useful addition ?

Rob
-- 
UUCP:   ...!mcvax!ukc!warwick!cudcv	PHONE:  +44 203 523037
JANET:  cudcv at uk.ac.warwick             ARPA:   cudcv at warwick.ac.uk
Rob McMahon, Computing Services, Warwick University, Coventry CV4 7AL, England



More information about the Comp.unix.wizards mailing list