/tmp versus temporary file types

Anw%maths.nottingham.ac.uk at UCL-CS.ARPA Anw%maths.nottingham.ac.uk at UCL-CS.ARPA
Thu Oct 24 05:28:42 AEST 1985


boyd at basser.oz (Boyd Roberts) writes:
> In article <1622 at gatech.CSNET> arnold at gatech.CSNET (Arnold Robbins) writes:
> >Why not do something like
> >
> >	fd = open ("/dev/temp", O_RDWR);
> >	/* O_CREAT implied by the use of /dev/temp */
> >
> > [...]
>Yes, that's the way.  Re-define the semantics of the system calls because
>you want dodgy feature X.  The UNIX file-system is clean and straight forward.
>So too are the system calls.  But, oh no, instead of using the interfaces
>provided it's time to mash them into five zillion different flavours, with
>no gain in functionality.  [...]

	Ouch!  But the system calls are not all THAT clean and s-f.  Why does
the ownership & mode of "fred" after 'creat ("fred", 0644);' depend on whether
"fred" existed before?  Why is "fred" opened for writing as well?  Why, in
standard V7 at least, can I not shorten a file, or open one by an existing
descriptor?  There is scope for making several of the system calls more
orthogonal and more primitive, were it not for the dead hand of tradition.

	There IS a minor lack of functionality which would be cured by some
form of anonymous or temporary file, and which is exemplified by the common
and not entirely satisfactory sequence

		s = mktemp ("/tmp/eXXXXXX");
		close (creat (s, 0600));
		fd = open (s, 2);
		unlink (s);

	Here's my 2p-worth.  Why not use an explicitly null file name to
indicate an anonymous file (with no links) in the implied directory?  Thus,

		fd = open ("/tmp/", 2);

(simply) would be equivalent to the above.  'open ("", 2)' would do it in
the current directory instead.  (At least, how often has anyone used null
file names in anger?  Hands up anyone who is not slightly surprised by the
behaviour of "mv junk ''", or of "date > ''".)	  No doubt some guru will
suggest a clean way round the obvious problem with "/" (but the name of the
root directory is already anomalous, and a counterexample to the c&sf-ness
of the file system).

	-- Andy Walker, Maths Dept, Nottingham Univ
		anw at UK.AC.Nott.Maths



More information about the Comp.unix.wizards mailing list