- the sceKernel[Send/TrySend/Receive]MsgPipe(...) functions return SCE_KERNEL_ERROR_ILLEGAL_SIZE if the given number of bytes param (size_t len) is greater than the initial size of MsgPipe. in our case the initial size is 'PIPE_BUF' which is declared as 512 bytes in syslimits.h - this is the normal value i guess -.
- MsgPipe functions should try to write at least PIPE_BUF bytes, and should return the number of bytes that has been read/written if there is no fd, or sys error. the patch below guarantiess this for '__psp_pipe_read(...), __psp_pipe_write(...), __psp_pipe_nonblocking_write(...)' functions. there is no need to do same in _psp_pipe_nonblocking_read(...) becouse __psp_pipe_peekmsgsize() handles for us.
the patch;
Code: Select all
Index: newlib-1.15.0-PSP.patch
===================================================================
--- newlib-1.15.0-PSP.patch (revision 2236)
+++ newlib-1.15.0-PSP.patch (working copy)
@@ -7420,7 +7420,7 @@
diff -burN orig.newlib-1.15.0/newlib/libc/sys/psp/pipe.c newlib-1.15.0/newlib/libc/sys/psp/pipe.c
--- orig.newlib-1.15.0/newlib/libc/sys/psp/pipe.c 1969-12-31 20:00:00.000000000 -0400
+++ newlib-1.15.0/newlib/libc/sys/psp/pipe.c 2007-05-29 15:02:51.000000000 -0300
-@@ -0,0 +1,285 @@
+@@ -0,0 +1,307 @@
+/*
+ * PSP Software Development Kit - http://www.pspdev.org
+ * -----------------------------------------------------------------------
@@ -7572,7 +7572,7 @@
+ *
+ * @return 0 on success, < 0 on error
+ */
-+ ret = sceKernelTryReceiveMsgPipe(sceuid, buf, len, 0, 0);
++ ret = sceKernelTryReceiveMsgPipe(sceuid, buf, len, 0, 0);
+
+ if (ret == 0) {/* Success - Data */
+ return len;
@@ -7601,8 +7601,8 @@
+
+#if 0
+ /* we should block until there is some data (or maybe for enough data),
-+ * peeking the msg size should be only for nonblocking reads
-+ */
++ * peeking the msg size should be only for nonblocking reads
++ */
+ size = __psp_pipe_peekmsgsize(fd);
+ if (size > 0) {
+ if (size < len) {
@@ -7614,6 +7614,13 @@
+ return -1;
+ }
+#endif
++ /* if len is greater than PIPE_BUF then, MsgPipe functions returns
++ * SCE_KERNEL_ERROR_ILLEGAL_SIZE, but it should read at least
++ * PIPE_BUF bytes, and return the number of bytes read.
++ */
++ if (len > PIPE_BUF) {
++ len = PIPE_BUF;
++ }
+
+ /**
+ * Receive a message from a pipe
@@ -7650,6 +7657,14 @@
+
+ sceuid = __psp_descriptormap[fd]->sce_descriptor;
+
++ /* if len is greater than PIPE_BUF then, MsgPipe functions returns
++ * SCE_KERNEL_ERROR_ILLEGAL_SIZE, but it should write at least
++ * PIPE_BUF bytes, and return the number of bytes written.
++ */
++ if (len > PIPE_BUF) {
++ len = PIPE_BUF;
++ }
++
+ /**
+ * Send a message to a pipe
+ *
@@ -7664,7 +7679,6 @@
+ */
+ cbuf = (char *)buf;
+ ret = sceKernelSendMsgPipe(sceuid, cbuf, len, 0, NULL, NULL);
-+
+ if (ret == 0) {/* Success - Data */
+ return len;
+ }
@@ -7686,6 +7700,14 @@
+
+ sceuid = __psp_descriptormap[fd]->sce_descriptor;
+
++ /* if len is greater than PIPE_BUF then, MsgPipe functions returns
++ * SCE_KERNEL_ERROR_ILLEGAL_SIZE, but it should write at least
++ * PIPE_BUF bytes, and return the number of bytes written.
++ */
++ if (len > PIPE_BUF) {
++ len = PIPE_BUF;
++ }
++
+ cbuf = (char *)buf;
+ ret = sceKernelTrySendMsgPipe(sceuid, cbuf, len, 0, 0);
+
@@ -7709,7 +7731,7 @@
diff -burN orig.newlib-1.15.0/newlib/libc/sys/psp/pipe.c.orig newlib-1.15.0/newlib/libc/sys/psp/pipe.c.orig
--- orig.newlib-1.15.0/newlib/libc/sys/psp/pipe.c.orig 1969-12-31 20:00:00.000000000 -0400
+++ newlib-1.15.0/newlib/libc/sys/psp/pipe.c.orig 2007-05-29 15:00:50.000000000 -0300
-@@ -0,0 +1,280 @@
+@@ -0,0 +1,301 @@
+/*
+ * PSP Software Development Kit - http://www.pspdev.org
+ * -----------------------------------------------------------------------
@@ -7861,7 +7883,7 @@
+ *
+ * @return 0 on success, < 0 on error
+ */
-+ ret = sceKernelTryReceiveMsgPipe(sceuid, buf, len, 0, 0);
++ ret = sceKernelTryReceiveMsgPipe(sceuid, buf, len, 0, 0);
+
+ if (ret == 0) {/* Success - Data */
+ return len;
@@ -7890,8 +7912,8 @@
+
+#if 0
+ /* we should block until there is some data (or maybe for enough data),
-+ * peeking the msg size should be only for nonblocking reads
-+ */
++ * peeking the msg size should be only for nonblocking reads
++ */
+ size = __psp_pipe_peekmsgsize(fd);
+ if (size > 0) {
+ if (size < len) {
@@ -7903,6 +7925,13 @@
+ return -1;
+ }
+#endif
++ /* if len is greater than PIPE_BUF then, MsgPipe functions returns
++ * SCE_KERNEL_ERROR_ILLEGAL_SIZE, but it should read at least
++ * PIPE_BUF bytes, and return the number of bytes read.
++ */
++ if (len > PIPE_BUF) {
++ len = PIPE_BUF;
++ }
+
+ /**
+ * Receive a message from a pipe
@@ -7939,6 +7968,14 @@
+
+ sceuid = __psp_descriptormap[fd]->sce_descriptor;
+
++ /* if len is greater than PIPE_BUF then, MsgPipe functions returns
++ * SCE_KERNEL_ERROR_ILLEGAL_SIZE, but it should write at least
++ * PIPE_BUF bytes, and return the number of bytes written.
++ */
++ if (len > PIPE_BUF) {
++ len = PIPE_BUF;
++ }
++
+ /**
+ * Send a message to a pipe
+ *
@@ -7953,7 +7990,6 @@
+ */
+ cbuf = (char *)buf;
+ ret = sceKernelSendMsgPipe(sceuid, cbuf, len, 0, NULL, NULL);
-+
+ if (ret == 0) {/* Success - Data */
+ return len;
+ }
@@ -7975,6 +8011,14 @@
+
+ sceuid = __psp_descriptormap[fd]->sce_descriptor;
+
++ /* if len is greater than PIPE_BUF then, MsgPipe functions returns
++ * SCE_KERNEL_ERROR_ILLEGAL_SIZE, but it should write at least
++ * PIPE_BUF bytes, and return the number of bytes written.
++ */
++ if (len > PIPE_BUF) {
++ len = PIPE_BUF;
++ }
++
+ cbuf = (char *)buf;
+ ret = sceKernelTrySendMsgPipe(sceuid, cbuf, len, 0, 0);
+
@@ -7989,7 +8033,6 @@
+ return __psp_set_errno(ret);
+ }
+}
-+
diff -burN orig.newlib-1.15.0/newlib/libc/sys/psp/pspcwd.c newlib-1.15.0/newlib/libc/sys/psp/pspcwd.c
--- orig.newlib-1.15.0/newlib/libc/sys/psp/pspcwd.c 1969-12-31 20:00:00.000000000 -0400
+++ newlib-1.15.0/newlib/libc/sys/psp/pspcwd.c 2007-05-29 15:00:50.000000000 -0300
anhanguera.
ps: sorry for sending posts like spam.