[OpenAFS-devel] mkstemp in FreeBSD (src/butc/tcudbprocs.c)

David Magda David Magda <dmagda@ee.ryerson.ca>
Fri, 13 Jun 2003 23:05:26 -0400


Hello,

Attached is a unified diff to have the BSDs use mkstemp(3).

mkstemp(3) returns a file descriptor (int) under the BSDs.

I believe it behaves the same way under Linux so I don't know why an
open(2) is used: the first argument to open(2) is a character
pointer, but an integer is being sent to it.

I don't have a working AFS setup (yet) so I can't really test how
well this works, only whether I get compile errors.

FWIW, Solaris 8 (and above?) also have mkstemp(3C) function.

Index: src/butc/tcudbprocs.c
===================================================================
RCS file: /cvs/openafs/src/butc/tcudbprocs.c,v
retrieving revision 1.8
diff -u -r1.8 tcudbprocs.c
--- src/butc/tcudbprocs.c       22 Aug 2002 21:00:57 -0000      1.8
+++ src/butc/tcudbprocs.c       14 Jun 2003 02:48:55 -0000
@@ -1390,8 +1390,10 @@
 
     /* open the text file */
     sprintf(filename, "%s/bu_XXXXXX", gettmpdir());
-#ifdef AFS_LINUX20_ENV
+#if defined (AFS_LINUX20_ENV)
     fid = open(mkstemp(filename), O_RDWR|O_CREAT|O_EXCL, 0600);
+#elif defined (AFS_XBSD_ENV)
+    fid = mkstemp(filename);
 #else
     fid = open(mktemp(filename), O_RDWR|O_CREAT|O_EXCL, 0600);
 #endif


-- 
David Magda <dmagda at ee.ryerson.ca>, http://www.magda.ca/
Because the innovator has for enemies all those who have done well under
the old conditions, and lukewarm defenders in those who may do well 
under the new. -- Niccolo Machiavelli, _The Prince_, Chapter VI