summaryrefslogtreecommitdiff
path: root/nuttx
diff options
context:
space:
mode:
authorGregory Nutt <gnutt@nuttx.org>2014-11-05 10:43:17 -0600
committerGregory Nutt <gnutt@nuttx.org>2014-11-05 10:43:17 -0600
commite76eef31375dcbea0e05b971b646f14893041046 (patch)
tree600f246391112b193dd8c2148ceeb3280e26af45 /nuttx
parent242d5e18ce594dab9ed6777fd7cde7e9dae4c99f (diff)
downloadpx4-nuttx-e76eef31375dcbea0e05b971b646f14893041046.tar.gz
px4-nuttx-e76eef31375dcbea0e05b971b646f14893041046.tar.bz2
px4-nuttx-e76eef31375dcbea0e05b971b646f14893041046.zip
Add tmpnam() and tempnam()
Diffstat (limited to 'nuttx')
-rw-r--r--nuttx/Documentation/NuttxUserGuide.html45
-rw-r--r--nuttx/fs/Kconfig10
-rw-r--r--nuttx/include/stdio.h22
-rw-r--r--nuttx/libc/Kconfig21
-rw-r--r--nuttx/libc/stdio/Make.defs4
5 files changed, 77 insertions, 25 deletions
diff --git a/nuttx/Documentation/NuttxUserGuide.html b/nuttx/Documentation/NuttxUserGuide.html
index fc51da592..44445e8ce 100644
--- a/nuttx/Documentation/NuttxUserGuide.html
+++ b/nuttx/Documentation/NuttxUserGuide.html
@@ -13,7 +13,7 @@
<h1><big><font color="#3c34ec"><i>NuttX Operating System<p>User's Manual</i></font></big></h1>
<p><small>by</small></p>
<p>Gregory Nutt<p>
- <p>Last Updated: October 4, 2014</p>
+ <p>Last Updated: November 5, 2014</p>
</td>
</tr>
</table>
@@ -7629,11 +7629,12 @@ interface of the same name.
<li><a href="#directoryoperations">2.10.3 Directory Operations</a></li>
<li><a href="#dirunistdops">2.10.4 UNIX Standard Operations</a></li>
<li><a href="#standardio">2.10.5 Standard I/O</a></li>
- <li><a href="#aio">2.10.6 Asynchronous I/O</a></li>
- <li><a href="#stdstrings">2.10.7 Standard String Operations</a></li>
- <li><a href="#PipesNFifos">2.10.8 Pipes and FIFOs</a></li>
- <li><a href="#fatsupport">2.10.9 FAT File System Support</a></li>
- <li><a href="#mmapxip">2.10.10 <code>mmap()</code> and eXecute In Place (XIP)</a></li>
+ <li><a href="#standardlib">2.10.6 Standard Library</a></li>
+ <li><a href="#aio">2.10.7 Asynchronous I/O</a></li>
+ <li><a href="#stdstrings">2.10.8 Standard String Operations</a></li>
+ <li><a href="#PipesNFifos">2.10.9 Pipes and FIFOs</a></li>
+ <li><a href="#fatsupport">2.10.10 FAT File System Support</a></li>
+ <li><a href="#mmapxip">2.10.11 <code>mmap()</code> and eXecute In Place (XIP)</a></li>
</ul>
<h3><a name="FileSystemOverview">2.10.1 NuttX File System Overview</a></h3>
@@ -7953,6 +7954,8 @@ int dprintf(int fd, FAR const char *fmt, ...);
int vdprintf(int fd, FAR const char *fmt, va_list ap);
int statfs(FAR const char *path, FAR struct statfs *buf);
+FAR char *tmpnam(FAR char *s);
+FAR char *tempnam(FAR const char *dir, FAR const char *pfx);
#include &lt;sys/stat.h&gt;
@@ -7967,7 +7970,19 @@ int statfs(const char *path, struct statfs *buf);
int fstatfs(int fd, struct statfs *buf);
</pre></ul>
-<h3><a name="aio">2.10.6 Asynchronous I/O</a></h3>
+<h3><a name="standardlib">2.10.6 Standard Library</a></h3>
+<p>
+ <code>stdlib.h</code> generally addresses other operating system interfaces.
+ However, the following may also be considered as file system interfaces:
+</p>
+<ul><pre>
+#include &lt;stdlib.h&gt;
+
+int mktemp(FAR char *template);
+int mkstemp(FAR char *template);
+</pre></ul>
+
+<h3><a name="aio">2.10.7 Asynchronous I/O</a></h3>
<ul><pre>
#include &lt;aio.h&gt;
@@ -7983,7 +7998,7 @@ int lio_listio(int mode, FAR struct aiocb *const list[], int nent,
FAR struct sigevent *sig);
</pre></ul>
-<h3><a name="stdstrings">2.10.7 Standard String Operations</a></h3>
+<h3><a name="stdstrings">2.10.8 Standard String Operations</a></h3>
<ul><pre>
#include &lt;string.h&gt;
@@ -8017,9 +8032,9 @@ void *memmove(void *dest, const void *src, size_t count);
# define bzero(s,n) (void)memset(s,0,n)
</pre></ul>
-<h3><a name="PipesNFifos">2.10.8 Pipes and FIFOs</a></h3>
+<h3><a name="PipesNFifos">2.10.9 Pipes and FIFOs</a></h3>
-<h3>2.10.8.1 <a name="pipe"><code>pipe</code></a></h3>
+<h3>2.10.9.1 <a name="pipe"><code>pipe</code></a></h3>
<p>
<b>Function Prototype:</b>
</p>
@@ -8053,7 +8068,7 @@ int pipe(int fd[2]);
</ul>
</p>
-<h3>2.10.8.2 <a name="mkfifo"><code>mkfifo</code></a></h3>
+<h3>2.10.9.2 <a name="mkfifo"><code>mkfifo</code></a></h3>
<p>
<b>Function Prototype:</b>
</p>
@@ -8100,8 +8115,8 @@ int mkfifo(FAR const char *pathname, mode_t mode);
</ul>
</p>
-<h3><a name="fatsupport">2.10.9 FAT File System Support</a></h3>
-<h3>2.10.9.1 <a name="mkfatfs"><code>mkfatfs</code></a></h3>
+<h3><a name="fatsupport">2.10.10 FAT File System Support</a></h3>
+<h3>2.10.10.1 <a name="mkfatfs"><code>mkfatfs</code></a></h3>
<p>
<b>Function Prototype:</b>
</p>
@@ -8178,7 +8193,7 @@ struct fat_format_s
</ul>
</p>
-<h3><a name="mmapxip">2.10.10 <code>mmap()</code> and eXecute In Place (XIP)</a></h3>
+<h3><a name="mmapxip">2.10.11 <code>mmap()</code> and eXecute In Place (XIP)</a></h3>
<p>
NuttX operates in a flat open address space and is focused on MCUs that do
support Memory Management Units (MMUs). Therefore, NuttX generally does not
@@ -8307,7 +8322,7 @@ struct fat_format_s
</li>
</ol>
-<h3><a name="mmap">2.10.10.1 <code>mmap</code></a></h3>
+<h3><a name="mmap">2.10.11.1 <code>mmap</code></a></h3>
<p>
<b>Function Prototype:</b>
</p>
diff --git a/nuttx/fs/Kconfig b/nuttx/fs/Kconfig
index 92828d9ac..8de3f51b0 100644
--- a/nuttx/fs/Kconfig
+++ b/nuttx/fs/Kconfig
@@ -61,16 +61,6 @@ source fs/smartfs/Kconfig
source fs/binfs/Kconfig
source fs/procfs/Kconfig
-config LIBC_TMPDIR
- string "Temporary file directory"
- default "/tmp"
- depends on FS_WRITABLE
- ---help---
- If a write-able file system is selected, this string will be
- provided to specify the full path to a directory where temporary
- files can be created. This would be a good application of RAM disk:
- To provide temporary storage for application data.
-
comment "System Logging"
config SYSLOG
diff --git a/nuttx/include/stdio.h b/nuttx/include/stdio.h
index bc0164aa4..cb1636679 100644
--- a/nuttx/include/stdio.h
+++ b/nuttx/include/stdio.h
@@ -78,6 +78,26 @@
#define getchar() fgetc(stdin)
#define rewind(s) ((void)fseek((s),0,SEEK_SET))
+/* Path to the directory where temporary files can be created */
+
+#ifndef CONFIG_LIBC_TMPDIR
+# define CONFIG_LIBC_TMPDIR "/tmp"
+#endif
+
+#define P_tmpdir CONFIG_LIBC_TMPDIR
+
+/* Maximum size of character array to hold tmpnam() output. */
+
+#ifndef CONFIG_LIBC_MAX_TMPFILE
+# define CONFIG_LIBC_MAX_TMPFILE 32
+#endif
+
+#define L_tmpnam CONFIG_LIBC_MAX_TMPFILE
+
+/* the maximum number of unique temporary file names that can be generated */
+
+#define TMP_MAX 56800235584ull
+
/****************************************************************************
* Public Type Definitions
****************************************************************************/
@@ -161,6 +181,8 @@ int vdprintf(int fd, FAR const char *fmt, va_list ap);
/* Operations on paths */
int statfs(FAR const char *path, FAR struct statfs *buf);
+FAR char *tmpnam(FAR char *s);
+FAR char *tempnam(FAR const char *dir, FAR const char *pfx);
#undef EXTERN
#if defined(__cplusplus)
diff --git a/nuttx/libc/Kconfig b/nuttx/libc/Kconfig
index 8f9569bde..138793aad 100644
--- a/nuttx/libc/Kconfig
+++ b/nuttx/libc/Kconfig
@@ -192,6 +192,27 @@ config LIBC_PERROR_STDOUT
be defined, however, to provide perror() output that is serialized with
other stdout messages.
+config LIBC_TMPDIR
+ string "Temporary file directory"
+ default "/tmp"
+ depends on FS_WRITABLE
+ ---help---
+ If a write-able file system is selected, this string will be
+ provided to specify the full path to a directory where temporary
+ files can be created. This would be a good application of RAM disk:
+ To provide temporary storage for application data.
+
+config LIBC_MAX_TMPFILE
+ int "Maximum size of a temporary file path"
+ default 32
+ depends on FS_WRITABLE
+ ---help---
+ If a write-able file system is selected, then temporary file may be
+ supported at the path provided by LIBC_TMPDIR. The tmpnam() interface
+ keeps a static copy of this last filename produced; this value is the
+ maximum size of that last filename. This size is the size of the full
+ file path.
+
config ARCH_LOWPUTC
bool "Low-level console output"
default "y"
diff --git a/nuttx/libc/stdio/Make.defs b/nuttx/libc/stdio/Make.defs
index 284c725c4..66914b30f 100644
--- a/nuttx/libc/stdio/Make.defs
+++ b/nuttx/libc/stdio/Make.defs
@@ -66,6 +66,10 @@ CSRCS += lib_stdoutstream.c lib_stdsistream.c lib_stdsostream.c lib_perror.c
CSRCS += lib_feof.c lib_ferror.c lib_clearerr.c
endif
+
+ifeq ($(CONFIG_FS_WRITABLE),y)
+CSRCS += lib_tempnam.c lib_tmpnam.c
+endif
endif
# Other support that depends on specific, configured features.