/tmp and /usr/tmp

Paul Scherf paulsc at tekecs.UUCP
Thu Mar 22 03:58:08 AEST 1984


I am not very good at mind reading, so I can't tell you why /tmp and /usr/tmp
were first created, but there are (used to be) systems where everything didn't
fit on one device (disk, filesystem, partition, whatever) and all the users'
files did fit on one device (disk, filesystem, partition, whatever). On such
systems /usr/tmp would be on the same device as all user files, but /tmp would
not.

The mv command can avoid copying a file if the target location is on the same
device. This way the window of vulnerability to system crashes could be made
much smaller for programs that need an "atomic" file update (i.e. you want
either the old version or the new version of a file, but not part of each or
neither, so you can restart after a crash by rerunning the updating program).

The schema is:
	Do a bunch of stuff to create the new version of the file
	in /usr/tmp/new$USER and take your time.
	...
	mv /usr/tmp/new$USER file

Unfortunately many systems are too big to put all the users' files on the same
device, so some users are in /a, some in /b, ..., but no one decided to put in
/a/tmp, /b/tmp, ... directories. You can still do the mv trick by making the
newversion file in the same directory as the old file, but if the system (or
the updating program) crashes in the middle of the update you have this ugly
garbage file left over.

UNIX users must always put exactly what they want in the file the first time :-)
Paul Scherf, Tektronix, Wilsonville, Oregon, USA
paulsc at tekecs.UUCP



More information about the Comp.unix mailing list