Index: uspace/lib/posix/stdio.c
===================================================================
--- uspace/lib/posix/stdio.c	(revision ffff74620bfc3a0efc3483d79b1ee8255d8f2672)
+++ uspace/lib/posix/stdio.c	(revision 11544f431436ab8a1d0816ded447ddee663a5ded)
@@ -44,6 +44,8 @@
 #include "assert.h"
 #include "errno.h"
+#include "stdlib.h"
 #include "string.h"
 #include "sys/types.h"
+#include "unistd.h"
 
 #include "libc/io/printf_core.h"
@@ -734,12 +736,111 @@
 
 /**
- * 
- * @param s
- * @return
+ * Get a unique temporary file name (obsolete).
+ *
+ * @param s Buffer for the file name. Must be at least L_tmpnam bytes long.
+ * @return The value of s on success, NULL on failure.
  */
 char *posix_tmpnam(char *s)
 {
-	// TODO: low priority, just a compile-time dependency of binutils
-	not_implemented();
+	assert(L_tmpnam >= posix_strlen("/tmp/tnXXXXXX"));
+	
+	static char buffer[L_tmpnam + 1];
+	if (s == NULL) {
+		s = buffer;
+	}
+	
+	posix_strcpy(s, "/tmp/tnXXXXXX");
+	posix_mktemp(s);
+	
+	if (*s == '\0') {
+		/* Errno set by mktemp(). */
+		return NULL;
+	}
+	
+	return s;
+}
+
+/**
+ * Get an unique temporary file name with additional constraints (obsolete).
+ *
+ * @param dir Path to directory, where the file should be created.
+ * @param pfx Optional prefix up to 5 characters long.
+ * @return Newly allocated unique path for temporary file. NULL on failure.
+ */
+char *posix_tempnam(const char *dir, const char *pfx)
+{
+	/* Sequence number of the filename. */
+	static int seq = 0;
+	
+	size_t dir_len = posix_strlen(dir);
+	if (dir[dir_len - 1] == '/') {
+		dir_len--;
+	}
+	
+	size_t pfx_len = posix_strlen(pfx);
+	if (pfx_len > 5) {
+		pfx_len = 5;
+	}
+	
+	char *result = malloc(dir_len + /* slash*/ 1 +
+	    pfx_len + /* three-digit seq */ 3 + /* .tmp */ 4 + /* nul */ 1);
+	
+	if (result == NULL) {
+		errno = ENOMEM;
+		return NULL;
+	}
+	
+	char *res_ptr = result;
+	posix_strncpy(res_ptr, dir, dir_len);
+	res_ptr += dir_len;
+	posix_strncpy(res_ptr, pfx, pfx_len);
+	res_ptr += pfx_len;
+	
+	for (; seq < 1000; ++seq) {
+		snprintf(res_ptr, 8, "%03d.tmp", seq);
+		
+		int orig_errno = errno;
+		errno = 0;
+		/* Check if the file exists. */
+		if (posix_access(result, F_OK) == -1) {
+			if (errno == ENOENT) {
+				errno = orig_errno;
+				break;
+			} else {
+				/* errno set by access() */
+				return NULL;
+			}
+		}
+	}
+	
+	if (seq == 1000) {
+		free(result);
+		errno = EINVAL;
+		return NULL;
+	}
+	
+	return result;
+}
+
+/**
+ * Create and open an unique temporary file.
+ * The file is automatically removed when the stream is closed.
+ *
+ * @param dir Path to directory, where the file should be created.
+ * @param pfx Optional prefix up to 5 characters long.
+ * @return Newly allocated unique path for temporary file. NULL on failure.
+ */
+FILE *posix_tmpfile(void)
+{
+	char filename[] = "/tmp/tfXXXXXX";
+	int fd = posix_mkstemp(filename);
+	if (fd == -1) {
+		/* errno set by mkstemp(). */
+		return NULL;
+	}
+	
+	/* Unlink the created file, so that it's removed on close(). */
+	posix_unlink(filename);
+	return fdopen(fd, "w+");
 }
 
Index: uspace/lib/posix/stdio.h
===================================================================
--- uspace/lib/posix/stdio.h	(revision ffff74620bfc3a0efc3483d79b1ee8255d8f2672)
+++ uspace/lib/posix/stdio.h	(revision 11544f431436ab8a1d0816ded447ddee663a5ded)
@@ -123,4 +123,6 @@
 #define L_tmpnam PATH_MAX
 extern char *posix_tmpnam(char *s);
+extern char *posix_tempnam(const char *dir, const char *pfx);
+extern FILE *posix_tmpfile(void);
 
 #ifndef LIBPOSIX_INTERNAL
@@ -176,4 +178,6 @@
 
 	#define tmpnam posix_tmpnam
+	#define tempnam posix_tempnam
+	#define tmpfile posix_tmpfile
 #endif
 
Index: uspace/lib/posix/stdlib.c
===================================================================
--- uspace/lib/posix/stdlib.c	(revision ffff74620bfc3a0efc3483d79b1ee8255d8f2672)
+++ uspace/lib/posix/stdlib.c	(revision 11544f431436ab8a1d0816ded447ddee663a5ded)
@@ -40,5 +40,9 @@
 
 #include "errno.h"
+#include "fcntl.h"
 #include "limits.h"
+#include "string.h"
+#include "sys/stat.h"
+#include "unistd.h"
 
 #include "libc/sort.h"
@@ -385,12 +389,83 @@
 
 /**
- * 
- * @param tmpl
- * @return
+ * Creates and opens an unique temporary file from template.
+ *
+ * @param tmpl Template. Last six characters must be XXXXXX.
+ * @return The opened file descriptor or -1 on error.
+ */
+int posix_mkstemp(char *tmpl)
+{
+	int fd = -1;
+	
+	char *tptr = tmpl + posix_strlen(tmpl) - 6;
+	
+	while (fd < 0) {
+		if (*posix_mktemp(tmpl) == '\0') {
+			/* Errno set by mktemp(). */
+			return -1;
+		}
+		
+		fd = open(tmpl, O_RDWR | O_CREAT | O_EXCL, S_IRUSR | S_IWUSR);
+		
+		if (fd == -1) {
+			/* Restore template to it's original state. */
+			snprintf(tptr, 7, "XXXXXX");
+		}
+	}
+	
+	return fd;
+}
+
+/**
+ * Creates an unique temporary file name from template.
+ *
+ * @param tmpl Template. Last six characters must be XXXXXX.
+ * @return The value of tmpl. The template is modified in place.
+ *    If no temporary file name can be created, template is
+ *    reduced to an empty string.
  */
 char *posix_mktemp(char *tmpl)
 {
-	// TODO: low priority, just a compile-time dependency of binutils
-	not_implemented();
+	int tmpl_len = posix_strlen(tmpl);
+	if (tmpl_len < 6) {
+		errno = EINVAL;
+		*tmpl = '\0';
+		return tmpl;
+	}
+	
+	char *tptr = tmpl + tmpl_len - 6;
+	if (posix_strcmp(tptr, "XXXXXX") != 0) {
+		errno = EINVAL;
+		*tmpl = '\0';
+		return tmpl;
+	}
+	
+	static int seq = 0;
+	
+	for (; seq < 1000000; ++seq) {
+		snprintf(tptr, 7, "%06d", seq);
+		
+		int orig_errno = errno;
+		errno = 0;
+		/* Check if the file exists. */
+		if (posix_access(tmpl, F_OK) == -1) {
+			if (errno == ENOENT) {
+				errno = orig_errno;
+				break;
+			} else {
+				/* errno set by access() */
+				*tmpl = '\0';
+				return tmpl;
+			}
+		}
+	}
+	
+	if (seq == 10000000) {
+		errno = EEXIST;
+		*tmpl = '\0';
+		return tmpl;
+	}
+	
+	return tmpl;
 }
 
Index: uspace/lib/posix/stdlib.h
===================================================================
--- uspace/lib/posix/stdlib.h	(revision ffff74620bfc3a0efc3483d79b1ee8255d8f2672)
+++ uspace/lib/posix/stdlib.h	(revision 11544f431436ab8a1d0816ded447ddee663a5ded)
@@ -113,4 +113,7 @@
 extern void posix_free(void *ptr);
 
+/* Temporary files */
+extern int posix_mkstemp(char *tmpl);
+
 /* Legacy Declarations */
 extern char *posix_mktemp(char *tmpl);
@@ -158,4 +161,6 @@
 	#define free posix_free
 
+	#define mkstemp posix_mkstemp
+
 	#define mktemp posix_mktemp
 	#define getloadavg bsd_getloadavg
