Hi Stephen,<br><br><div class="gmail_quote">On Tue, Apr 7, 2009 at 8:49 AM, Stephen Rothwell <span dir="ltr">&lt;<a href="mailto:sfr@canb.auug.org.au">sfr@canb.auug.org.au</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<br>
Signed-off-by: Stephen Rothwell &lt;<a href="mailto:sfr@canb.auug.org.au">sfr@canb.auug.org.au</a>&gt;<br>
---<br>
 arch/powerpc/include/asm/systbl.h |    2 ++<br>
 arch/powerpc/include/asm/unistd.h |    4 +++-<br>
 2 files changed, 5 insertions(+), 1 deletions(-)<br>
<br>
Tested on pseries_defconfig (verified using strace{,64} and inspecting<br>
the files).  Test program (modified from the original because the API and<br>
ABI changed and I added a test with larger offsets):<br>
<br>
#if 0<br>
set -x<br>
gcc -Wall -O2 -m32 -o preadv $0<br>
gcc -Wall -O2 -m32 -D_FILE_OFFSET_BITS=64 -DLARGE_TEST -o preadv32 $0<br>
gcc -Wall -O2 -m64 -DLARGE_TEST -o preadv64 $0<br>
./preadv<br>
./preadv32<br>
./preadv64<br>
exit 0<br>
#endif<br>
/*<br>
 * preadv demo / test<br>
 *<br>
 * (c) 2008 Gerd Hoffmann &lt;<a href="mailto:kraxel@redhat.com">kraxel@redhat.com</a>&gt;<br>
 * Modified for new ABI and large offset test by Stephen Rothwell<br>
 *<br>
 * build with &quot;sh $thisfile&quot;<br>
 */<br>
<br>
#include &lt;stdio.h&gt;<br>
#include &lt;stdlib.h&gt;<br>
#include &lt;unistd.h&gt;<br>
#include &lt;errno.h&gt;<br>
#include &lt;inttypes.h&gt;<br>
#include &lt;sys/uio.h&gt;<br>
<br>
/* ----------------------------------------------------------------- */<br>
/* syscall windup                                                    */<br>
<br>
#include &lt;sys/syscall.h&gt;<br>
#if 1<br>
/* WARNING: Be sure you know what you are doing if you enable this.<br>
 * linux syscall code isn&#39;t upstream yet, syscall numbers are subject<br>
 * to change */<br>
# ifndef __NR_preadv<br>
#  ifdef __i386__<br>
#   define __NR_preadv  333<br>
#   define __NR_pwritev 334<br>
#  endif<br>
#  ifdef __x86_64__<br>
#   define __NR_preadv  295<br>
#   define __NR_pwritev 296<br>
#  endif<br>
#  ifdef __powerpc__<br>
#   define __NR_preadv  319<br>
#   define __NR_pwritev 320<br>
#  endif<br>
# endif<br>
#endif<br>
#ifndef __NR_preadv<br>
# error preadv/pwritev syscall numbers are unknown<br>
#endif<br>
<br>
#define HALF_BITS (sizeof(unsigned long)*4)<br>
<br>
static ssize_t preadv(int fd, const struct iovec *iov, int iovcnt,<br>
                      off_t offset)<br>
{<br>
        return syscall(__NR_preadv, fd, iov, iovcnt,<br>
                       (unsigned long)offset,<br>
                       (unsigned long)((offset &gt;&gt; HALF_BITS) &gt;&gt; HALF_BITS));<br>
}<br>
<br>
static ssize_t pwritev(int fd, const struct iovec *iov, int iovcnt,<br>
                       off_t offset)<br>
{<br>
        return syscall(__NR_pwritev, fd, iov, iovcnt,<br>
                       (unsigned long)offset,<br>
                       (unsigned long)((offset &gt;&gt; HALF_BITS) &gt;&gt; HALF_BITS));<br>
}<br>
<br>
/* ----------------------------------------------------------------- */<br>
/* demo/test app                                                     */<br>
<br>
static char filename[] = &quot;/tmp/preadv-XXXXXX&quot;;<br>
static char outbuf[11] = &quot;0123456789&quot;;<br>
static char inbuf[11]  = &quot;----------&quot;;<br>
<br>
static struct iovec ovec[2] = {{<br>
                .iov_base = outbuf + 5,<br>
                .iov_len  = 5,<br>
        },{<br>
                .iov_base = outbuf + 0,<br>
                .iov_len  = 5,<br>
        }};<br>
<br>
static struct iovec ivec[3] = {{<br>
                .iov_base = inbuf + 6,<br>
                .iov_len  = 2,<br>
        },{<br>
                .iov_base = inbuf + 4,<br>
                .iov_len  = 2,<br>
        },{<br>
                .iov_base = inbuf + 2,<br>
                .iov_len  = 2,<br>
        }};<br>
<br>
void cleanup(void)<br>
{<br>
        unlink(filename);<br>
}<br>
<br>
int main(int argc, char **argv)<br>
{<br>
        int fd, rc;<br>
<br>
        fd = mkstemp(filename);<br>
        if (-1 == fd) {<br>
                perror(&quot;mkstemp&quot;);<br>
                exit(1);<br>
        }<br>
        atexit(cleanup);<br>
<br>
        /* write to file: &quot;56789-01234&quot; */<br>
        rc = pwritev(fd, ovec, 2, 0);<br>
        if (rc &lt; 0) {<br>
                perror(&quot;pwritev&quot;);<br>
                exit(1);<br>
        }<br>
<br>
        /* read from file: &quot;78-90-12&quot; */<br>
        rc = preadv(fd, ivec, 3, 2);<br>
        if (rc &lt; 0) {<br>
                perror(&quot;preadv&quot;);<br>
                exit(1);<br>
        }<br>
<br>
        printf(&quot;result  : %s\n&quot;, inbuf);<br>
        printf(&quot;expected: %s\n&quot;, &quot;--129078--&quot;);<br>
<br>
#ifdef LARGE_TEST<br>
<br>
        /* write to file: &quot;56789-01234&quot; */<br>
        rc = pwritev(fd, ovec, 2, 0x300000000ULL);<br>
        if (rc &lt; 0) {<br>
                perror(&quot;pwritev&quot;);<br>
                exit(1);<br>
        }<br>
<br>
        /* read from file: &quot;78-90-12&quot; */<br>
        rc = preadv(fd, ivec, 3, 0x300000000ULL + 2);<br>
        if (rc &lt; 0) {<br>
                perror(&quot;preadv&quot;);<br>
                exit(1);<br>
        }<br>
<br>
        printf(&quot;result  : %s\n&quot;, inbuf);<br>
        printf(&quot;expected: %s\n&quot;, &quot;--129078--&quot;);<br>
<br>
#endif<br>
<br>
        exit(0);<br>
}<br>
</blockquote><div><br>How about contributing the above test to LTP(<a href="http://ltp.sourceforge.net/">http://ltp.sourceforge.net/</a>) under GPL ? If you agree, i would soon send you a Patch integrating the same to LTP.<br>
<br>Regards--<br>Subrata<br><br></div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><br>
<br>
diff --git a/arch/powerpc/include/asm/systbl.h b/arch/powerpc/include/asm/systbl.h<br>
index fe16649..3fb6d9e 100644<br>
--- a/arch/powerpc/include/asm/systbl.h<br>
+++ b/arch/powerpc/include/asm/systbl.h<br>
@@ -322,3 +322,5 @@ SYSCALL_SPU(epoll_create1)<br>
 SYSCALL_SPU(dup3)<br>
 SYSCALL_SPU(pipe2)<br>
 SYSCALL(inotify_init1)<br>
+COMPAT_SYS_SPU(preadv)<br>
+COMPAT_SYS_SPU(pwritev)<br>
diff --git a/arch/powerpc/include/asm/unistd.h b/arch/powerpc/include/asm/unistd.h<br>
index e07d0c7..7e03ebe 100644<br>
--- a/arch/powerpc/include/asm/unistd.h<br>
+++ b/arch/powerpc/include/asm/unistd.h<br>
@@ -341,10 +341,12 @@<br>
 #define __NR_dup3              316<br>
 #define __NR_pipe2             317<br>
 #define __NR_inotify_init1     318<br>
+#define __NR_preadv            319<br>
+#define __NR_pwritev           320<br>
<br>
 #ifdef __KERNEL__<br>
<br>
-#define __NR_syscalls          319<br>
+#define __NR_syscalls          321<br>
<br>
 #define __NR__exit __NR_exit<br>
 #define NR_syscalls    __NR_syscalls<br>
--<br>
1.6.2.1<br>
<br>
--<br>
Cheers,<br>
Stephen Rothwell                    <a href="mailto:sfr@canb.auug.org.au">sfr@canb.auug.org.au</a><br>
<a href="http://www.canb.auug.org.au/%7Esfr/" target="_blank">http://www.canb.auug.org.au/~sfr/</a><br>
<font color="#888888">--<br>
To unsubscribe from this list: send the line &quot;unsubscribe linux-kernel&quot; in<br>
the body of a message to <a href="mailto:majordomo@vger.kernel.org">majordomo@vger.kernel.org</a><br>
More majordomo info at  <a href="http://vger.kernel.org/majordomo-info.html" target="_blank">http://vger.kernel.org/majordomo-info.html</a><br>
Please read the FAQ at  <a href="http://www.tux.org/lkml/" target="_blank">http://www.tux.org/lkml/</a><br>
</font></blockquote></div><br><br clear="all"><br>-- <br>Regards &amp; Thanks--<br>Subrata<br>