[Cbe-oss-dev] [PATCH 2/3] Add assist calls for various file/sync functions
Patrick Mansfield
patmans at us.ibm.com
Sat Jun 9 02:51:36 EST 2007
Add assist calls for the following functions:
void sync(void)
int fsync(int fd)
int fdatasync(int fd)
int dup2(int oldfd, int newfd)
int lockf(int fd, int cmd, off_t len)
int truncate(const char *path, off_t length)
Signed-off-by: Patrick Mansfield <patmans at us.ibm.com>
Index: quilt-libspe2/spebase/default_posix1_handler.c
===================================================================
--- quilt-libspe2.orig/spebase/default_posix1_handler.c
+++ quilt-libspe2/spebase/default_posix1_handler.c
@@ -134,6 +134,12 @@ enum {
SPE_POSIX1_LINK,
SPE_POSIX1_SYMLINK,
SPE_POSIX1_READLINK,
+ SPE_POSIX1_SYNC,
+ SPE_POSIX1_FSYNC,
+ SPE_POSIX1_FDATASYNC,
+ SPE_POSIX1_DUP2,
+ SPE_POSIX1_LOCKF,
+ SPE_POSIX1_TRUNCATE,
SPE_POSIX1_LAST_OPCODE,
};
#define SPE_POSIX1_NR_OPCODES \
@@ -1574,6 +1580,139 @@ int default_posix1_handler_readlink(char
return 0;
}
+/**
+ * default_posix1_handler_sync
+ * @ls: base pointer to local store area.
+ * @opdata: POSIX.1 call opcode & data.
+ *
+ * Implement:
+ * void sync(void)
+ */
+int default_posix1_handler_sync(char *ls, unsigned long opdata)
+{
+ DEBUG_PRINTF("%s\n", __func__);
+ sync();
+ return 0;
+}
+
+/**
+ * default_posix1_handler_fsync
+ * @ls: base pointer to local store area.
+ * @opdata: POSIX.1 call opcode & data.
+ *
+ * Implement:
+ * int fsync(int fd)
+ */
+int default_posix1_handler_fsync(char *ls, unsigned long opdata)
+{
+ DECL_1_ARGS();
+ DECL_RET();
+ int fd;
+ int rc;
+
+ DEBUG_PRINTF("%s\n", __func__);
+ fd = arg0->slot[0];
+ rc = fsync(fd);
+ PUT_LS_RC(rc, 0, 0, errno);
+ return 0;
+}
+
+/**
+ * default_posix1_handler_fdatasync
+ * @ls: base pointer to local store area.
+ * @opdata: POSIX.1 call opcode & data.
+ *
+ * Implement:
+ * int fdatasync(int fd)
+ */
+int default_posix1_handler_fdatasync(char *ls, unsigned long opdata)
+{
+ DECL_1_ARGS();
+ DECL_RET();
+ int fd;
+ int rc;
+
+ DEBUG_PRINTF("%s\n", __func__);
+ fd = arg0->slot[0];
+ rc = fdatasync(fd);
+ PUT_LS_RC(rc, 0, 0, errno);
+ return 0;
+}
+
+/**
+ * default_posix1_handler_dup2
+ * @ls: base pointer to local store area.
+ * @opdata: POSIX.1 call opcode & data.
+ *
+ * Implement:
+ * int dup2(int oldfd, int newfd)
+ */
+int default_posix1_handler_dup2(char *ls, unsigned long opdata)
+{
+ DECL_2_ARGS();
+ DECL_RET();
+ int oldfd;
+ int newfd;
+ int rc;
+
+ DEBUG_PRINTF("%s\n", __func__);
+ oldfd = arg0->slot[0];
+ newfd = arg1->slot[0];
+ rc = dup2(oldfd, newfd);
+ PUT_LS_RC(rc, 0, 0, errno);
+ return 0;
+}
+
+/**
+ * default_posix1_handler_lockf
+ * @ls: base pointer to local store area.
+ * @opdata: POSIX.1 call opcode & data.
+ *
+ * Implement:
+ * int lockf(int fd, int cmd, off_t len)
+ */
+int default_posix1_handler_lockf(char *ls, unsigned long opdata)
+{
+ DECL_3_ARGS();
+ DECL_RET();
+ int fd;
+ int cmd;
+ off_t len;
+ int rc;
+
+ DEBUG_PRINTF("%s\n", __func__);
+ fd = arg0->slot[0];
+ cmd = arg1->slot[0];
+ len = (off_t) arg2->slot[0];
+ rc = lockf(fd, cmd, len);
+ PUT_LS_RC(rc, 0, 0, errno);
+ return 0;
+}
+
+/**
+ * default_posix1_handler_truncate
+ * @ls: base pointer to local store area.
+ * @opdata: POSIX.1 call opcode & data.
+ *
+ * Implement:
+ * int truncate(const char *path, off_t length)
+ */
+int default_posix1_handler_truncate(char *ls, unsigned long opdata)
+{
+ DECL_2_ARGS();
+ DECL_RET();
+ char *path;
+ off_t length;
+ int rc;
+
+ DEBUG_PRINTF("%s\n", __func__);
+ path = GET_LS_PTR(arg0->slot[0]);
+ length = arg1->slot[0];
+ rc = truncate(path, length);
+ 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,
@@ -1622,6 +1761,12 @@ int (*default_posix1_funcs[SPE_POSIX1_NR
[SPE_POSIX1_LINK] = default_posix1_handler_link,
[SPE_POSIX1_SYMLINK] = default_posix1_handler_symlink,
[SPE_POSIX1_READLINK] = default_posix1_handler_readlink,
+ [SPE_POSIX1_SYNC] = default_posix1_handler_sync,
+ [SPE_POSIX1_FSYNC] = default_posix1_handler_fsync,
+ [SPE_POSIX1_FDATASYNC] = default_posix1_handler_fdatasync,
+ [SPE_POSIX1_DUP2] = default_posix1_handler_dup2,
+ [SPE_POSIX1_LOCKF] = default_posix1_handler_lockf,
+ [SPE_POSIX1_TRUNCATE] = default_posix1_handler_truncate,
};
/**
Index: quilt-libspe2/spebase/default_posix1_handler.h
===================================================================
--- quilt-libspe2.orig/spebase/default_posix1_handler.h
+++ quilt-libspe2/spebase/default_posix1_handler.h
@@ -69,5 +69,11 @@ extern int default_posix1_handler_getcwd
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);
+extern int default_posix1_handler_sync(char *ls, unsigned long args);
+extern int default_posix1_handler_fsync(char *ls, unsigned long args);
+extern int default_posix1_handler_fdatasync(char *ls, unsigned long args);
+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);
#endif /* __DEFAULT_POSIX1_HANDLER_H__ */
More information about the cbe-oss-dev
mailing list