[Cbe-oss-dev] [PATCH 3/3] Add assist calls for mkstemp and mktemp

Patrick Mansfield patmans at us.ibm.com
Sat Jun 9 02:52:32 EST 2007


Add assist calls for:

	int mkstemp(char *template)
	char *mktemp(char *template)

Signed-off-by: Patrick Mansfield <patmans at us.ibm.com>

Index: quilt-libspe2/spebase/default_posix1_handler.h
===================================================================
--- quilt-libspe2.orig/spebase/default_posix1_handler.h
+++ quilt-libspe2/spebase/default_posix1_handler.h
@@ -75,5 +75,7 @@ extern int default_posix1_handler_fdatas
 extern int default_posix1_handler_dup2(char *ls, unsigned long args);
 extern int default_posix1_handler_lockf(char *ls, unsigned long args);
 extern int default_posix1_handler_truncate(char *ls, unsigned long args);
+extern int default_posix1_handler_mkstemp(char *ls, unsigned long args);
+extern int default_posix1_handler_mktemp(char *ls, unsigned long args);
 
 #endif /* __DEFAULT_POSIX1_HANDLER_H__ */
Index: quilt-libspe2/spebase/default_posix1_handler.c
===================================================================
--- quilt-libspe2.orig/spebase/default_posix1_handler.c
+++ quilt-libspe2/spebase/default_posix1_handler.c
@@ -140,6 +140,8 @@ enum {
 	SPE_POSIX1_DUP2,
 	SPE_POSIX1_LOCKF,
 	SPE_POSIX1_TRUNCATE,
+	SPE_POSIX1_MKSTEMP,
+	SPE_POSIX1_MKTEMP,
 	SPE_POSIX1_LAST_OPCODE,
 };
 #define SPE_POSIX1_NR_OPCODES	\
@@ -1713,6 +1715,56 @@ int default_posix1_handler_truncate(char
     return 0;
 }
 
+/**
+ * default_posix1_handler_mkstemp
+ * @ls: base pointer to local store area.
+ * @opdata: POSIX.1 call opcode & data.
+ *
+ * Implement:
+ *      int mkstemp(char *template)
+ */
+int default_posix1_handler_mkstemp(char *ls, unsigned long opdata)
+{
+    DECL_1_ARGS();
+    DECL_RET();
+    char *template;
+    int rc;
+
+    DEBUG_PRINTF("%s\n", __func__);
+    template = GET_LS_PTR(arg0->slot[0]);
+    rc = mkstemp(template);
+    PUT_LS_RC(rc, 0, 0, errno);
+    return 0;
+}
+
+/**
+ * default_posix1_handler_mktemp
+ * @ls: base pointer to local store area.
+ * @opdata: POSIX.1 call opcode & data.
+ *
+ * Implement:
+ *      char *mktemp(char *template)
+ */
+int default_posix1_handler_mktemp(char *ls, unsigned long opdata)
+{
+    DECL_1_ARGS();
+    DECL_RET();
+    char *template;
+    int rc;
+
+    DEBUG_PRINTF("%s\n", __func__);
+    template = GET_LS_PTR(arg0->slot[0]);
+    mktemp(template);
+    /*
+     * Note that POSIX says (and glibc implements) that mktemp always
+     * returns the address of template, but the linux man page incorrectly
+     * says (or said) NULL is returned on error.
+     */
+    rc = arg0->slot[0];
+    PUT_LS_RC(rc, 0, 0, errno);
+    return 0;
+}
+
 int (*default_posix1_funcs[SPE_POSIX1_NR_OPCODES]) (char *, unsigned long) = {
 	[SPE_POSIX1_UNUSED]		= NULL,
 	[SPE_POSIX1_ADJTIMEX]		= default_posix1_handler_adjtimex,
@@ -1767,6 +1819,8 @@ int (*default_posix1_funcs[SPE_POSIX1_NR
 	[SPE_POSIX1_DUP2]		= default_posix1_handler_dup2,
 	[SPE_POSIX1_LOCKF]		= default_posix1_handler_lockf,
 	[SPE_POSIX1_TRUNCATE]		= default_posix1_handler_truncate,
+	[SPE_POSIX1_MKSTEMP]		= default_posix1_handler_mkstemp,
+	[SPE_POSIX1_MKTEMP]		= default_posix1_handler_mktemp,
 };
 
 /**



More information about the cbe-oss-dev mailing list