Bugtraq mailing list archives

Re: Race conditions, mkstemp


From: casper () fwi uva nl (Casper Dik)
Date: Sun, 11 Dec 1994 14:07:02 +0100



      here is the source for mkstemp from csrg.  note the filesystem 
must support exclusive file locking atomic to the open() for this to be 
helpful.  as is written in the mkstemp() man page.

      why wasnt O_TRUNC included.  that would hammer both soft and hard links


Because it serves no useful purpose.  A file created with O_EXCL|O_CREAT
will have 0 lenght.  If the file needs to be truncated (O_TRUNC) it
already exists, but i that case the open w/ O_CREATE|O_EXCL would fail.

O_CREATE|O_TRUNC|O_EXCL makes no sense.

Casper



Current thread: