[Cbe-oss-dev] [PATCH 1/3] Add assist calls for some link functions

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


Add assist calls for the following functions:

	int link(const char *oldpath, const char *newpath)
	ssize_t readlink(const char *path, char *buf, size_t bufsiz)
	int symlink(const char *oldpath, const char *newpath)

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

Index: libspe2/spebase/default_posix1_handler.c
===================================================================
--- libspe2.orig/spebase/default_posix1_handler.c
+++ libspe2/spebase/default_posix1_handler.c
@@ -131,6 +131,9 @@ enum {
 	SPE_POSIX1_FCHOWN,
 	SPE_POSIX1_LCHOWN,
 	SPE_POSIX1_GETCWD,
+	SPE_POSIX1_LINK,
+	SPE_POSIX1_SYMLINK,
+	SPE_POSIX1_READLINK,
 	SPE_POSIX1_LAST_OPCODE,
 };
 #define SPE_POSIX1_NR_OPCODES	\
@@ -1497,6 +1500,80 @@ int default_posix1_handler_getcwd(char *
     return 0;
 }
 
+/**
+ * default_posix1_handler_link
+ * @ls: base pointer to local store area.
+ * @opdata: POSIX.1 call opcode & data.
+ *
+ * Implement:
+ *     int link(const char *oldpath, const char *newpath)
+ */
+int default_posix1_handler_link(char *ls, unsigned long opdata)
+{
+    DECL_2_ARGS();
+    DECL_RET();
+    char *oldpath;
+    char *newpath;
+    int rc;
+
+    DEBUG_PRINTF("%s\n", __func__);
+    oldpath = GET_LS_PTR(arg0->slot[0]);
+    newpath = GET_LS_PTR(arg1->slot[0]);
+    rc = link(oldpath, newpath);
+    PUT_LS_RC(rc, 0, 0, errno);
+    return 0;
+}
+
+/**
+ * default_posix1_handler_symlink
+ * @ls: base pointer to local store area.
+ * @opdata: POSIX.1 call opcode & data.
+ *
+ * Implement:
+ *     int symlink(const char *oldpath, const char *newpath)
+ */
+int default_posix1_handler_symlink(char *ls, unsigned long opdata)
+{
+    DECL_2_ARGS();
+    DECL_RET();
+    char *oldpath;
+    char *newpath;
+    int rc;
+
+    DEBUG_PRINTF("%s\n", __func__);
+    oldpath = GET_LS_PTR(arg0->slot[0]);
+    newpath = GET_LS_PTR(arg1->slot[0]);
+    rc = symlink(oldpath, newpath);
+    PUT_LS_RC(rc, 0, 0, errno);
+    return 0;
+}
+
+/**
+ * default_posix1_handler_readlink
+ * @ls: base pointer to local store area.
+ * @opdata: POSIX.1 call opcode & data.
+ *
+ * Implement:
+ *     ssize_t readlink(const char *path, char *buf, size_t bufsiz)
+ */
+int default_posix1_handler_readlink(char *ls, unsigned long opdata)
+{
+    DECL_3_ARGS();
+    DECL_RET();
+    char *path;
+    char *buf;
+    size_t bufsiz;
+    int rc;
+
+    DEBUG_PRINTF("%s\n", __func__);
+    path = GET_LS_PTR(arg0->slot[0]);
+    buf = GET_LS_PTR(arg1->slot[0]);
+    bufsiz = arg2->slot[0];
+    rc = readlink(path, buf, bufsiz);
+    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,
@@ -1542,6 +1619,9 @@ int (*default_posix1_funcs[SPE_POSIX1_NR
 	[SPE_POSIX1_FCHOWN]		= default_posix1_handler_fchown,
 	[SPE_POSIX1_LCHOWN]		= default_posix1_handler_lchown,
 	[SPE_POSIX1_GETCWD]             = default_posix1_handler_getcwd,
+	[SPE_POSIX1_LINK]		= default_posix1_handler_link,
+	[SPE_POSIX1_SYMLINK]		= default_posix1_handler_symlink,
+	[SPE_POSIX1_READLINK]		= default_posix1_handler_readlink,
 };
 
 /**
Index: libspe2/spebase/default_posix1_handler.h
===================================================================
--- libspe2.orig/spebase/default_posix1_handler.h
+++ libspe2/spebase/default_posix1_handler.h
@@ -66,5 +66,8 @@ extern int default_posix1_handler_chown(
 extern int default_posix1_handler_fchown(char *ls, unsigned long args);
 extern int default_posix1_handler_lchown(char *ls, unsigned long args);
 extern int default_posix1_handler_getcwd(char *ls, unsigned long args);
+extern int default_posix1_handler_link(char *ls, unsigned long args);
+extern int default_posix1_handler_symlink(char *ls, unsigned long args);
+extern int default_posix1_handler_readlink(char *ls, unsigned long args);
 
 #endif /* __DEFAULT_POSIX1_HANDLER_H__ */



More information about the cbe-oss-dev mailing list