[Cbe-oss-dev] [PATCH 2/3] libspe2: add various chdir/chown/mknod assist calls

Patrick Mansfield patmans at us.ibm.com
Tue Jun 5 02:27:38 EST 2007


Add assist calls for the following functions:

	int chdir(const char *path)
	int fchdir(int fd)
	int mkdir(const char *pathname, mode_t mode)
	int mknod(const char *pathname, mode_t mode, dev_t dev)
	int rmdir(const char *pathname)

	int chmod(const char *path, mode_t mode)
	int fchmod(int fildes, mode_t mode)

	int chown(const char *path, uid_t owner, gid_t group)
	int fchown(int fd, uid_t owner, gid_t group)
	int lchown(const char *path, uid_t owner, gid_t group)

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
@@ -120,6 +120,16 @@ enum {
 	SPE_POSIX1_DUP,
 	SPE_POSIX1_TIME,
 	SPE_POSIX1_NANOSLEEP,
+	SPE_POSIX1_CHDIR,
+	SPE_POSIX1_FCHDIR,
+	SPE_POSIX1_MKDIR,
+	SPE_POSIX1_MKNOD,
+	SPE_POSIX1_RMDIR,
+	SPE_POSIX1_CHMOD,
+	SPE_POSIX1_FCHMOD,
+	SPE_POSIX1_CHOWN,
+	SPE_POSIX1_FCHOWN,
+	SPE_POSIX1_LCHOWN,
 	SPE_POSIX1_LAST_OPCODE,
 };
 #define SPE_POSIX1_NR_OPCODES	\
@@ -1205,6 +1215,249 @@ int default_posix1_handler_nanosleep(cha
     return 0;
 }
 
+/**
+ * default_posix1_handler_chdir
+ * @ls: base pointer to local store area.
+ * @opdata: POSIX.1 call opcode & data.
+ *
+ * Implement:
+ *     int chdir(const char *path)
+ */
+
+int default_posix1_handler_chdir(char *ls, unsigned long opdata)
+{
+    DECL_1_ARGS();
+    DECL_RET();
+    char *path;
+    int rc;
+
+    DEBUG_PRINTF("%s\n", __func__);
+    path = GET_LS_PTR(arg0->slot[0]);
+    rc = chdir(path);
+    PUT_LS_RC(rc, 0, 0, errno);
+    return 0;
+}
+
+/**
+ * default_posix1_handler_fchdir
+ * @ls: base pointer to local store area.
+ * @opdata: POSIX.1 call opcode & data.
+ *
+ * Implement:
+ *     int fchdir(int fd)
+ */
+int default_posix1_handler_fchdir(char *ls, unsigned long opdata)
+{
+    DECL_1_ARGS();
+    DECL_RET();
+    int fd;
+    int rc;
+
+    DEBUG_PRINTF("%s\n", __func__);
+    fd = arg0->slot[0];
+    rc = fchdir(fd);
+    PUT_LS_RC(rc, 0, 0, errno);
+    return 0;
+}
+
+/**
+ * default_posix1_handler_mkdir
+ * @ls: base pointer to local store area.
+ * @opdata: POSIX.1 call opcode & data.
+ *
+ * Implement:
+ *     int mkdir(const char *pathname, mode_t mode)
+ */
+int default_posix1_handler_mkdir(char *ls, unsigned long opdata)
+{
+    DECL_2_ARGS();
+    DECL_RET();
+    char *pathname;
+    mode_t mode;
+    int rc;
+
+    DEBUG_PRINTF("%s\n", __func__);
+    pathname = GET_LS_PTR(arg0->slot[0]);
+    mode = arg1->slot[0];
+    rc = mkdir(pathname, mode);
+    PUT_LS_RC(rc, 0, 0, errno);
+    return 0;
+}
+
+/**
+ * default_posix1_handler_mknod
+ * @ls: base pointer to local store area.
+ * @opdata: POSIX.1 call opcode & data.
+ *
+ * Implement:
+ *     int mknod(const char *pathname, mode_t mode, dev_t dev)
+ */
+int default_posix1_handler_mknod(char *ls, unsigned long opdata)
+{
+    DECL_3_ARGS();
+    DECL_RET();
+    char *pathname;
+    mode_t mode;
+    dev_t dev;
+    int rc;
+
+    DEBUG_PRINTF("%s\n", __func__);
+    pathname = GET_LS_PTR(arg0->slot[0]);
+    mode = arg1->slot[0];
+    dev = arg2->slot[0];
+    rc = mknod(pathname, mode, dev);
+    PUT_LS_RC(rc, 0, 0, errno);
+    return 0;
+}
+
+/**
+ * default_posix1_handler_rmdir
+ * @ls: base pointer to local store area.
+ * @opdata: POSIX.1 call opcode & data.
+ *
+ * Implement:
+ *     int rmdir(const char *pathname)
+ */
+int default_posix1_handler_rmdir(char *ls, unsigned long opdata)
+{
+    DECL_1_ARGS();
+    DECL_RET();
+    char *pathname;
+    int rc;
+
+    DEBUG_PRINTF("%s\n", __func__);
+    pathname = GET_LS_PTR(arg0->slot[0]);
+    rc = rmdir(pathname);
+    PUT_LS_RC(rc, 0, 0, errno);
+    return 0;
+}
+
+/**
+ * default_posix1_handler_chmod
+ * @ls: base pointer to local store area.
+ * @opdata: POSIX.1 call opcode & data.
+ *
+ * Implement:
+ *     int chmod(const char *path, mode_t mode)
+ */
+int default_posix1_handler_chmod(char *ls, unsigned long opdata)
+{
+    DECL_2_ARGS();
+    DECL_RET();
+    char *path;
+    mode_t mode;
+    int rc;
+
+    DEBUG_PRINTF("%s\n", __func__);
+    path = GET_LS_PTR(arg0->slot[0]);
+    mode = arg1->slot[0];
+    rc = chmod(path, mode);
+    PUT_LS_RC(rc, 0, 0, errno);
+    return 0;
+}
+
+/**
+ * default_posix1_handler_fchmod
+ * @ls: base pointer to local store area.
+ * @opdata: POSIX.1 call opcode & data.
+ *
+ * Implement:
+ *     int fchmod(int fildes, mode_t mode)
+ */
+int default_posix1_handler_fchmod(char *ls, unsigned long opdata)
+{
+    DECL_2_ARGS();
+    DECL_RET();
+    int filedes;
+    mode_t mode;
+    int rc;
+
+    DEBUG_PRINTF("%s\n", __func__);
+    filedes = arg0->slot[0];
+    mode = arg1->slot[0];
+    rc = fchmod(filedes, mode);
+    PUT_LS_RC(rc, 0, 0, errno);
+    return 0;
+}
+
+/**
+ * default_posix1_handler_chown
+ * @ls: base pointer to local store area.
+ * @opdata: POSIX.1 call opcode & data.
+ *
+ * Implement:
+ *     int chown(const char *path, uid_t owner, gid_t group)
+ */
+int default_posix1_handler_chown(char *ls, unsigned long opdata)
+{
+    DECL_3_ARGS();
+    DECL_RET();
+    char *path;
+    uid_t owner;
+    gid_t group;
+    int rc;
+
+    DEBUG_PRINTF("%s\n", __func__);
+    path = GET_LS_PTR(arg0->slot[0]);
+    owner = arg1->slot[0];
+    group = arg2->slot[0];
+    rc = chown(path, owner, group);
+    PUT_LS_RC(rc, 0, 0, errno);
+    return 0;
+}
+
+/**
+ * default_posix1_handler_fchown
+ * @ls: base pointer to local store area.
+ * @opdata: POSIX.1 call opcode & data.
+ *
+ * Implement:
+ *     int fchown(int fd, uid_t owner, gid_t group)
+ */
+int default_posix1_handler_fchown(char *ls, unsigned long opdata)
+{
+    DECL_3_ARGS();
+    DECL_RET();
+    int fd;
+    uid_t owner;
+    gid_t group;
+    int rc;
+
+    DEBUG_PRINTF("%s\n", __func__);
+    fd = arg0->slot[0];
+    owner = arg1->slot[0];
+    group = arg2->slot[0];
+    rc = fchown(fd, owner, group);
+    PUT_LS_RC(rc, 0, 0, errno);
+    return 0;
+}
+
+/**
+ * default_posix1_handler_lchown
+ * @ls: base pointer to local store area.
+ * @opdata: POSIX.1 call opcode & data.
+ *
+ * Implement:
+ *     int lchown(const char *path, uid_t owner, gid_t group)
+ */
+int default_posix1_handler_lchown(char *ls, unsigned long opdata)
+{
+    DECL_3_ARGS();
+    DECL_RET();
+    char *path;
+    uid_t owner;
+    gid_t group;
+    int rc;
+
+    DEBUG_PRINTF("%s\n", __func__);
+    path = GET_LS_PTR(arg0->slot[0]);
+    owner = arg1->slot[0];
+    group = arg2->slot[0];
+    rc = lchown(path, owner, group);
+    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,
@@ -1239,6 +1492,16 @@ int (*default_posix1_funcs[SPE_POSIX1_NR
 	[SPE_POSIX1_DUP]		= default_posix1_handler_dup,
 	[SPE_POSIX1_TIME]		= default_posix1_handler_time,
 	[SPE_POSIX1_NANOSLEEP]		= default_posix1_handler_nanosleep,
+	[SPE_POSIX1_CHDIR]		= default_posix1_handler_chdir,
+	[SPE_POSIX1_FCHDIR]		= default_posix1_handler_fchdir,
+	[SPE_POSIX1_MKDIR]		= default_posix1_handler_mkdir,
+	[SPE_POSIX1_MKNOD]		= default_posix1_handler_mknod,
+	[SPE_POSIX1_RMDIR]		= default_posix1_handler_rmdir,
+	[SPE_POSIX1_CHMOD]		= default_posix1_handler_chmod,
+	[SPE_POSIX1_FCHMOD]		= default_posix1_handler_fchmod,
+	[SPE_POSIX1_CHOWN]		= default_posix1_handler_chown,
+	[SPE_POSIX1_FCHOWN]		= default_posix1_handler_fchown,
+	[SPE_POSIX1_LCHOWN]		= default_posix1_handler_lchown,
 };
 
 /**
Index: libspe2/spebase/default_posix1_handler.h
===================================================================
--- libspe2.orig/spebase/default_posix1_handler.h
+++ libspe2/spebase/default_posix1_handler.h
@@ -54,6 +54,16 @@ extern int default_posix1_handler_ftrunc
 extern int default_posix1_handler_access(char *ls, unsigned long args);
 extern int default_posix1_handler_dup(char *ls, unsigned long args);
 extern int default_posix1_handler_time(char *ls, unsigned long args);
-extern int default_posix1_handler_nanosleep(char *ls, unsigned long opdata);
+extern int default_posix1_handler_nanosleep(char *ls, unsigned long args);
+extern int default_posix1_handler_chdir(char *ls, unsigned long args);
+extern int default_posix1_handler_fchdir(char *ls, unsigned long args);
+extern int default_posix1_handler_mkdir(char *ls, unsigned long args);
+extern int default_posix1_handler_mknod(char *ls, unsigned long args);
+extern int default_posix1_handler_rmdir(char *ls, unsigned long args);
+extern int default_posix1_handler_chmod(char *ls, unsigned long args);
+extern int default_posix1_handler_fchmod(char *ls, unsigned long args);
+extern int default_posix1_handler_chown(char *ls, unsigned long args);
+extern int default_posix1_handler_fchown(char *ls, unsigned long args);
+extern int default_posix1_handler_lchown(char *ls, unsigned long args);
 
 #endif /* __DEFAULT_POSIX1_HANDLER_H__ */



More information about the cbe-oss-dev mailing list