>On Fri, 2009-06-12 at 08:37 +0200, Gerd Hoffmann wrote:
>On 06/12/09 04:53, Subrata Modak wrote:
> > Hi Gerd,
> >
> > Thanks for writing preadv/pwritev syscalls for linux-2.6.30. We would
> > like to include your test code (hosted at:
> > http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commitdiff;h=dac1213842f5caf081804a11d87d2a39a21d6f55)
> >  to be included in our Linux Test Project (http://ltp.sf.net) under GPLv2.
> 
> Fine with me.
> 
> Note that there was an ABI change 
> (http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=601cc11d054ae4b5e9b5babec3d8e4667a2cb9b5),
>  
> so the test program needs adaptions to the final ABI present in 2.6.30.

Ok. Great. Here is the patch which will integrate your test to LTP.

Signed-off-by: Subrata Modak <[email protected]>
Original-author-and-copyright-holder: Gerd Hoffmann <[email protected]>

To: Gerd Hoffmann <[email protected]>
Cc: Arnd Bergmann <[email protected]>
Cc: Al Viro <[email protected]>
Cc: Ralf Baechle <[email protected]>
Cc: ltp-list <[email protected]>
---

--- ltp-full-20090531.orig/testcases/kernel/syscalls/preadv/Makefile    
1970-01-01 05:30:00.000000000 +0530
+++ ltp-full-20090531/testcases/kernel/syscalls/preadv/Makefile 2009-06-12 
18:31:37.000000000 +0530
@@ -0,0 +1,31 @@
+#
+#  Copyright (c) International Business Machines  Corp., 2009
+#
+#  This program is free software;  you can redistribute it and/or modify
+#  it under the terms of the GNU General Public License as published by
+#  the Free Software Foundation; either version 2 of the License, or
+#  (at your option) any later version.
+#
+#  This program is distributed in the hope that it will be useful,
+#  but WITHOUT ANY WARRANTY;  without even the implied warranty of
+#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See
+#  the GNU General Public License for more details.
+#
+#  You should have received a copy of the GNU General Public License
+#  along with this program;  if not, write to the Free Software
+#  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+#
+
+CFLAGS += -I../../../../include -Wall -O2
+LDLIBS += -L../../../../lib -lltp
+
+SRCS    = $(wildcard *.c)
+TARGETS += $(patsubst %.c,%,$(SRCS))
+
+all: $(TARGETS)
+
+install:
+       @set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
+
+clean:
+       rm -f $(TARGETS)
--- ltp-full-20090531.orig/testcases/kernel/syscalls/preadv/preadv01.c  
1970-01-01 05:30:00.000000000 +0530
+++ ltp-full-20090531/testcases/kernel/syscalls/preadv/preadv01.c       
2009-06-12 18:40:26.000000000 +0530
@@ -0,0 +1,113 @@
+/*
+ * Simple test for preadv() and pwritev() syscall introduced in linux-2.6.30
+ *
+ * (c) 2008 Gerd Hoffmann <[email protected]>
+ *
+ * Reference: 
http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commitdiff;h=dac1213842f5caf081804a11d87d2a39a21d6f55
+ * Reference: 
http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=601cc11d054ae4b5e9b5babec3d8e4667a2cb9b5
+ * Reference: 
http://kernelnewbies.org/LinuxChanges#head-0bf8c8dcb325b9a214be39679c3e2bcca995d05b
+ * Reference: http://marc.info/?t=124477542000004&r=1&w=2&n=2
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <errno.h>
+#include <inttypes.h>
+#include <sys/uio.h>
+
+/* ----------------------------------------------------------------- */
+/* syscall windup                                                    */
+
+#include <sys/syscall.h>
+
+#ifndef __NR_preadv
+       #ifdef __i386__
+               #define __NR_preadv  333
+               #define __NR_pwritev 334
+       #endif
+       #ifdef __x86_64__
+               #define __NR_preadv  295
+               #define __NR_pwritev 296
+       #endif
+#endif
+
+char *TCID = "preadv01";     /* test program identifier*/
+
+static ssize_t preadv(int fd, const struct iovec *iov, int iovcnt, off_t 
offset)
+{
+    uint32_t pos_high = (offset >> 32) & 0xffffffff;
+    uint32_t pos_low  =  offset        & 0xffffffff;
+
+    return syscall(__NR_preadv, fd, iov, iovcnt, pos_high, pos_low);
+}
+
+static ssize_t pwritev(int fd, const struct iovec *iov, int iovcnt, off_t 
offset)
+{
+    uint32_t pos_high = (offset >> 32) & 0xffffffff;
+    uint32_t pos_low  =  offset        & 0xffffffff;
+
+    return syscall(__NR_pwritev, fd, iov, iovcnt, pos_high, pos_low);
+}
+
+/* ----------------------------------------------------------------- */
+/* demo/test app                                                     */
+
+static char filename[] = "/tmp/preadv-XXXXXX";
+static char outbuf[11] = "0123456789";
+static char inbuf[11]  = "----------";
+
+static struct iovec ovec[2] = {{
+        .iov_base = outbuf + 5,
+        .iov_len  = 5,
+    },{
+        .iov_base = outbuf + 0,
+        .iov_len  = 5,
+    }};
+
+static struct iovec ivec[3] = {{
+        .iov_base = inbuf + 6,
+        .iov_len  = 2,
+    },{
+        .iov_base = inbuf + 4,
+        .iov_len  = 2,
+    },{
+        .iov_base = inbuf + 2,
+        .iov_len  = 2,
+    }};
+
+void cleanup(void)
+{
+    unlink(filename);
+}
+
+int main(int argc, char **argv)
+{
+    int fd, rc;
+
+    fd = mkstemp(filename);
+    if (-1 == fd) {
+        perror("mkstemp");
+        exit(1);
+    }
+    atexit(cleanup);
+
+    /* write to file: "56789-01234" */
+    rc = pwritev(fd, ovec, 2, 0);
+    if (rc < 0) {
+        perror("pwritev");
+        exit(1);
+    }
+
+    /* read from file: "78-90-12" */
+    rc = preadv(fd, ivec, 3, 2);
+    if (rc < 0) {
+        perror("preadv");
+        exit(1);
+    }
+
+    printf("result  : %s\n", inbuf);
+    printf("expected: %s\n", "--129078--");
+    exit(0);
+}
+
--- ltp-full-20090531.orig/runtest/syscalls     2009-06-12 18:30:08.000000000 
+0530
+++ ltp-full-20090531/runtest/syscalls  2009-06-12 18:41:36.000000000 +0530
@@ -724,6 +724,8 @@ pread02_64 pread02_64
 pread03 pread03
 pread03_64 pread03_64
 
+preadv01 preadv01
+
 profil01 profil01
 
 pselect01 pselect01

---
Regards--
Subrata

> 
> cheers,
>    Gerd
> 

------------------------------------------------------------------------------
Crystal Reports - New Free Runtime and 30 Day Trial
Check out the new simplified licensing option that enables unlimited
royalty-free distribution of the report engine for externally facing 
server and web deployment.
http://p.sf.net/sfu/businessobjects
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list

Reply via email to