2005-01-03 06:40:20 +00:00
|
|
|
.TH OPENTEMP 3
|
|
|
|
.SH NAME
|
2008-07-10 15:10:10 +00:00
|
|
|
opentemp \- create and open a uniquely-named file
|
2005-01-03 06:40:20 +00:00
|
|
|
.SH SYNOPSIS
|
|
|
|
.B #include <u.h>
|
|
|
|
.br
|
|
|
|
.B #include <libc.h>
|
|
|
|
.PP
|
|
|
|
.B
|
2008-07-10 15:10:10 +00:00
|
|
|
int opentemp(char *template, int mode)
|
2005-01-03 06:40:20 +00:00
|
|
|
.SH DESCRIPTION
|
|
|
|
.I Opentemp
|
|
|
|
replaces
|
|
|
|
.I template
|
|
|
|
by a unique file name, and returns the
|
|
|
|
address of the template.
|
|
|
|
The template should look like a file name with eleven trailing
|
|
|
|
.LR X s.
|
|
|
|
The
|
|
|
|
.LR X s
|
|
|
|
are replaced by a letter followed by the current process id.
|
|
|
|
Letters from
|
|
|
|
.L a
|
|
|
|
to
|
|
|
|
.L z
|
|
|
|
are tried until the name of a file that does not yet exist
|
|
|
|
(see
|
2020-08-16 00:07:38 +00:00
|
|
|
.MR access (2) )
|
2005-01-03 06:40:20 +00:00
|
|
|
is generated.
|
|
|
|
.I Opentemp
|
2008-07-10 15:10:10 +00:00
|
|
|
then opens the file for the given
|
|
|
|
.I mode
|
2005-01-03 06:40:20 +00:00
|
|
|
and returns the file descriptor.
|
2008-07-10 15:10:10 +00:00
|
|
|
Most calls should use a mode
|
|
|
|
of
|
|
|
|
.BR ORDWR|ORCLOSE .
|
2005-01-03 06:40:20 +00:00
|
|
|
.PP
|
|
|
|
If no such name can be generated,
|
|
|
|
.I opentemp
|
|
|
|
returns \-1.
|
|
|
|
.PP
|
|
|
|
.I Opentemp
|
|
|
|
avoids races.
|
|
|
|
Two simultaneous calls to
|
|
|
|
.I opentemp
|
|
|
|
will never return the same name.
|
|
|
|
.SH SOURCE
|
2005-01-11 17:37:33 +00:00
|
|
|
.B \*9/src/lib9/opentemp.c
|
2005-01-03 06:40:20 +00:00
|
|
|
.SH "SEE ALSO
|
|
|
|
.I create
|
|
|
|
in
|
2020-08-16 00:07:38 +00:00
|
|
|
.MR open (3)
|