]> sourceware.org Git - systemtap.git/commitdiff
PR16716 partial fix: Fix types in 'syscall.{pread,pwrite,read,write}'.
authorDavid Smith <dsmith@redhat.com>
Tue, 4 Nov 2014 16:24:17 +0000 (10:24 -0600)
committerDavid Smith <dsmith@redhat.com>
Tue, 4 Nov 2014 16:24:17 +0000 (10:24 -0600)
* tapset/linux/syscalls2.stp: Fixed types in syscall.pread,
  syscall.pwrite, syscall.pwrite32, syscall.read, and syscall.write.
* tapset/linux/nd_syscalls2.stp: Ditto.
* testsuite/systemtap.syscall/readwrite.c (main): Added tests and split.
* testsuite/systemtap.syscall/lseek.c: Tests moved from readwrite.c and
  new tests added.
* testsuite/systemtap.syscall/pread.c: Ditto.
* testsuite/systemtap.syscall/pwrite.c: Ditto.

tapset/linux/nd_syscalls2.stp
tapset/linux/syscalls2.stp
testsuite/systemtap.syscall/lseek.c [new file with mode: 0644]
testsuite/systemtap.syscall/pread.c [new file with mode: 0644]
testsuite/systemtap.syscall/pwrite.c [new file with mode: 0644]
testsuite/systemtap.syscall/readwrite.c

index b4f07af80fab9a43572ca94f5832049ffc67ac08..e3244cd5b2cced8591ac442250cf010f6e25a13a 100644 (file)
@@ -495,21 +495,49 @@ probe nd_syscall.prctl.return = kprobe.function("sys_prctl").return ?
 #               size_t count,
 #               loff_t pos)
 #
-probe nd_syscall.pread = kprobe.function("sys_pread64") ?
+probe nd_syscall.pread =
+%( arch == "s390" %?
+       __nd_syscall.pread, __nd_syscall.compat_pread ?
+%:
+       __nd_syscall.pread
+%)
 {
        name = "pread"
        asmlinkage()
-       fd = uint_arg(1)
+       fd = int_arg(1)
        buf_uaddr = pointer_arg(2)
        count = ulong_arg(3)
+       argstr = sprintf("%d, %p, %u, %d", fd, buf_uaddr, count, offset)
+}
+probe __nd_syscall.pread = kprobe.function("sys_pread64")
+{
+%( arch == "s390" %?
+       @__syscall_gate(%{ __NR_pread64 %})
+%)
        offset = longlong_arg(4)
-       argstr = sprintf("%d, %p, %d, %d", fd, buf_uaddr, count, offset)
 }
-probe nd_syscall.pread.return = kprobe.function("sys_pread64").return ?
+%( arch == "s390" %?
+probe __nd_syscall.compat_pread = kprobe.function("sys32_pread64").call ?
+{
+       offset = (u32_arg(4) << 32) + u32_arg(5)
+}
+%)
+probe nd_syscall.pread.return =
+%( arch == "s390" %?
+       __nd_syscall.pread.return, kprobe.function("sys32_pread64").return ?
+%:
+       __nd_syscall.pread.return
+%)
 {
        name = "pread"
        retstr = returnstr(1)
 }
+probe __nd_syscall.pread.return = kprobe.function("sys_pread64").return
+{
+%( arch == "s390" %?
+       @__syscall_gate(%{ __NR_pread64 %})
+%)
+}
 
 # preadv ____________________________________________________
 #
@@ -661,18 +689,24 @@ probe nd_syscall.ptrace.return = kprobe.function("sys_ptrace").return ?
 #
 probe nd_syscall.pwrite = kprobe.function("sys_pwrite64") ?
 {
+%( arch == "s390" %?
+       @__syscall_gate(%{ __NR_pwrite64 %})
+%)
        name = "pwrite"
        asmlinkage()
-       fd = uint_arg(1)
+       fd = int_arg(1)
        buf_uaddr = pointer_arg(2)
        count = ulong_arg(3)
        offset = longlong_arg(4)
-       argstr = sprintf("%d, %s, %d, %d", fd,
-                       user_string_n2_quoted(buf_uaddr, count, syscall_string_trunc),
+       argstr = sprintf("%d, %s, %u, %d", fd,
+                        user_string_n2_quoted(buf_uaddr, count, syscall_string_trunc),
                                count, offset)
 }
 probe nd_syscall.pwrite.return = kprobe.function("sys_pwrite64").return ?
 {
+%( arch == "s390" %?
+       @__syscall_gate(%{ __NR_pwrite64 %})
+%)
        name = "pwrite"
        retstr = returnstr(1)
 }
@@ -682,13 +716,14 @@ probe nd_syscall.pwrite32 = kprobe.function("sys32_pwrite64") ?
 {
        name = "pwrite"
        asmlinkage()
-       fd = uint_arg(1)
+       fd = int_arg(1)
        buf_uaddr = pointer_arg(2)
        count = ulong_arg(3)
        offset = (u32_arg(4) << 32) + u32_arg(5)
-       argstr = sprintf("%d, %s, %d, %d", fd,
-                       user_string_n2_quoted(buf_uaddr, count, syscall_string_trunc),
-                               count, offset)
+       argstr = sprintf("%d, %s, %u, %d", fd,
+                        user_string_n2_quoted(buf_uaddr, count,
+                                              syscall_string_trunc),
+                        count, offset)
 }
 probe nd_syscall.pwrite32.return = kprobe.function("sys32_pwrite64").return ?
 {
@@ -761,20 +796,42 @@ probe nd_syscall.quotactl.return = kprobe.function("sys_quotactl").return ?
 
 # read _______________________________________________________
 # ssize_t sys_read(unsigned int fd, char __user * buf, size_t count)
-probe nd_syscall.read = kprobe.function("sys_read") ?
+probe nd_syscall.read =
+%( arch == "s390" %?
+       __nd_syscall.read, kprobe.function("sys32_read").call ?
+%:
+       __nd_syscall.read
+%)
 {
        name = "read"
        asmlinkage()
-       fd = uint_arg(1)
+       fd = int_arg(1)
        buf_uaddr = pointer_arg(2)
        count = ulong_arg(3)
-       argstr = sprintf("%d, %p, %d", fd, buf_uaddr, count)
+       argstr = sprintf("%d, %p, %u", fd, buf_uaddr, count)
+}
+probe __nd_syscall.read = kprobe.function("sys_read")
+{
+%( arch == "s390" %?
+       @__syscall_gate(%{ __NR_read %})
+%)
 }
-probe nd_syscall.read.return = kprobe.function("sys_read").return ?
+probe nd_syscall.read.return =
+%( arch == "s390" %?
+       __nd_syscall.read.return, kprobe.function("sys32_read").return ?
+%:
+       __nd_syscall.read.return
+%)
 {
        name = "read"
        retstr = returnstr(1)
 }
+probe __nd_syscall.read.return = kprobe.function("sys_read").return
+{
+%( arch == "s390" %?
+       @__syscall_gate(%{ __NR_read %})
+%)
+}
 
 # readahead __________________________________________________
 #
@@ -4613,23 +4670,48 @@ probe nd_syscall.waitpid.return = kprobe.function("sys_wait4").return ?
 #           const char __user * buf,
 #           size_t count)
 #
-probe nd_syscall.write = kprobe.function("sys_write") ?
+# s390x needs special compat handling, since its wrapper function
+# rejects some calls.
+#
+probe nd_syscall.write =
+%( arch == "s390" %?
+       __nd_syscall.write, kprobe.function("sys32_write").call ?
+%:
+       __nd_syscall.write
+%)
 {
        name = "write"
        asmlinkage()
-       fd = uint_arg(1)
+       fd = int_arg(1)
        buf_uaddr = pointer_arg(2)
        count = ulong_arg(3)
-       argstr = sprintf("%d, %s, %d", fd,
-               user_string_n2_quoted(buf_uaddr, count, syscall_string_trunc),
-               count)
-
+       argstr = sprintf("%d, %s, %u", fd,
+                        user_string_n2_quoted(buf_uaddr, count,
+                                              syscall_string_trunc),
+                        count)
 }
-probe nd_syscall.write.return = kprobe.function("sys_write").return ?
+probe __nd_syscall.write = kprobe.function("sys_write")
+{
+%( arch == "s390" %?
+       @__syscall_gate(%{ __NR_write %})
+%)
+}
+probe nd_syscall.write.return =
+%( arch == "s390" %?
+       __nd_syscall.write.return, kprobe.function("sys32_write").return ?
+%:
+       __nd_syscall.write.return
+%)
 {
        name = "write"
        retstr = returnstr(1)
 }
+probe __nd_syscall.write.return = kprobe.function("sys_write").return
+{
+%( arch == "s390" %?
+       @__syscall_gate(%{ __NR_write %})
+%)
+}
 
 # writev _____________________________________________________
 #
index e5fe454a30915e1d7186aad91618e729f4bbb194..df62195d4981c9ebd79dfef1e46063ece06642dc 100644 (file)
@@ -532,20 +532,49 @@ probe syscall.prctl.return = kernel.function("sys_prctl").return
 #               size_t count,
 #               loff_t pos)
 #
-probe syscall.pread = kernel.function("sys_pread64").call
+probe syscall.pread =
+%( arch == "s390" %?
+       __syscall.pread, __syscall.compat_pread ?
+%:
+       __syscall.pread
+%)
 {
        name = "pread"
-       fd = $fd
-       buf_uaddr = $buf
-       count = $count
+       fd = __int32($fd)
+       buf_uaddr = @choose_defined($buf, $ubuf)
+       count = __ulong($count)
+       argstr = sprintf("%d, %p, %u, %d", __int32($fd), buf_uaddr,
+                        __ulong($count), offset)
+}
+probe __syscall.pread = kernel.function("sys_pread64").call
+{
+%( arch == "s390" %?
+       @__syscall_gate(%{ __NR_pread64 %})
+%)
        offset = $pos
-       argstr = sprintf("%d, %p, %d, %d", $fd, $buf, $count, $pos)
 }
-probe syscall.pread.return = kernel.function("sys_pread64").return
+%( arch == "s390" %?
+probe __syscall.compat_pread = kernel.function("sys32_pread64").call ?
+{
+       offset = ($poshi << 32) + $poslo
+}
+%)
+probe syscall.pread.return =
+%( arch == "s390" %?
+       __syscall.pread.return, kernel.function("sys32_pread64").return ?
+%:
+       __syscall.pread.return
+%)
 {
        name = "pread"
        retstr = return_str(1, $return)
 }
+probe __syscall.pread.return = kernel.function("sys_pread64").return
+{
+%( arch == "s390" %?
+       @__syscall_gate(%{ __NR_pread64 %})
+%)
+}
 
 # preadv ____________________________________________________
 #
@@ -694,17 +723,23 @@ probe syscall.ptrace.return = kernel.function("sys_ptrace").return ?
 #
 probe syscall.pwrite = kernel.function("sys_pwrite64").call
 {
+%( arch == "s390" %?
+       @__syscall_gate(%{ __NR_pwrite64 %})
+%)
        name = "pwrite"
-       fd = $fd
+       fd = __int32($fd)
        buf_uaddr = $buf
-       count = $count
+       count = __ulong($count)
        offset = $pos
-       argstr = sprintf("%d, %s, %d, %d", $fd,
+       argstr = sprintf("%d, %s, %u, %d", __int32($fd),
                user_string_n2_quoted($buf, $count, syscall_string_trunc),
-               $count, $pos)
+               __ulong($count), $pos)
 }
 probe syscall.pwrite.return = kernel.function("sys_pwrite64").return
 {
+%( arch == "s390" %?
+       @__syscall_gate(%{ __NR_pwrite64 %})
+%)
        name = "pwrite"
        retstr = return_str(1, $return)
 }
@@ -713,20 +748,14 @@ probe syscall.pwrite.return = kernel.function("sys_pwrite64").return
 probe syscall.pwrite32 = kernel.function("sys32_pwrite64").call ?
 {
        name = "pwrite"
-       fd = $fd
+       fd = __int32($fd)
        count = $count
        offset = ($poshi << 32) + $poslo
-%( arch == "s390" %?
-       buf_uaddr = $ubuf
-       argstr = sprintf("%d, %s, %d, %d", $fd,
-               user_string_n2_quoted($ubuf, $count, syscall_string_trunc),
-               $count, ($poshi << 32) + $poslo)
-%:
-       buf_uaddr = $buf
-       argstr = sprintf("%d, %s, %d, %d", $fd,
-               user_string_n2_quoted($buf, $count, syscall_string_trunc),
-               $count, ($poshi << 32) + $poslo)
-%)
+       buf_uaddr = @choose_defined($buf, $ubuf)
+       argstr = sprintf("%d, %s, %u, %d", __int32($fd),
+                        user_string_n2_quoted(buf_uaddr, $count,
+                                              syscall_string_trunc),
+                        $count, ($poshi << 32) + $poslo)
 }
 probe syscall.pwrite32.return = kernel.function("sys32_pwrite64").return ?
 {
@@ -799,19 +828,41 @@ probe syscall.quotactl.return = kernel.function("sys_quotactl").return ?
 
 # read _______________________________________________________
 # ssize_t sys_read(unsigned int fd, char __user * buf, size_t count)
-probe syscall.read = kernel.function("sys_read").call
+probe syscall.read =
+%( arch == "s390" %?
+       __syscall.read, kernel.function("sys32_read").call ?
+%:
+       __syscall.read
+%)
 {
        name = "read"
-       fd = $fd
+       fd = __int32($fd)
        buf_uaddr = $buf
-       count = $count
-       argstr = sprintf("%d, %p, %d", $fd, $buf, $count)
+       count = __ulong($count)
+       argstr = sprintf("%d, %p, %u", __int32($fd), $buf, __ulong($count))
+}
+probe __syscall.read = kernel.function("sys_read").call
+{
+%( arch == "s390" %?
+       @__syscall_gate(%{ __NR_read %})
+%)
 }
-probe syscall.read.return = kernel.function("sys_read").return
+probe syscall.read.return =
+%( arch == "s390" %?
+       __syscall.read.return, kernel.function("sys32_read").return ?
+%:
+       __syscall.read.return
+%)
 {
        name = "read"
        retstr = return_str(1, $return)
 }
+probe __syscall.read.return = kernel.function("sys_read").return
+{
+%( arch == "s390" %?
+       @__syscall_gate(%{ __NR_read %})
+%)
+}
 
 # readahead __________________________________________________
 #
@@ -4427,21 +4478,43 @@ probe syscall.waitpid.return = kernel.function("sys_wait4").return
 #           const char __user * buf,
 #           size_t count)
 #
-probe syscall.write = kernel.function("sys_write").call
+probe syscall.write =
+%( arch == "s390" %?
+       __syscall.write, kernel.function("sys32_write").call ?
+%:
+       __syscall.write
+%)
 {
        name = "write"
-       fd = $fd
+       fd = __int32($fd)
        buf_uaddr = $buf
-       count = $count
-       argstr = sprintf("%d, %s, %d", $fd,
+       count = __ulong($count)
+       argstr = sprintf("%d, %s, %u", __int32($fd),
                user_string_n2_quoted($buf, $count, syscall_string_trunc),
-               $count)
+               __ulong($count))
+}
+probe __syscall.write = kernel.function("sys_write").call
+{
+%( arch == "s390" %?
+       @__syscall_gate(%{ __NR_write %})
+%)
 }
-probe syscall.write.return = kernel.function("sys_write").return
+probe syscall.write.return =
+%( arch == "s390" %?
+       __syscall.write.return, kernel.function("sys32_write").return ?
+%:
+       __syscall.write.return
+%)
 {
        name = "write"
        retstr = return_str(1, $return)
 }
+probe __syscall.write.return = kernel.function("sys_write").return
+{
+%( arch == "s390" %?
+       @__syscall_gate(%{ __NR_write %})
+%)
+}
 
 # writev _____________________________________________________
 #
diff --git a/testsuite/systemtap.syscall/lseek.c b/testsuite/systemtap.syscall/lseek.c
new file mode 100644 (file)
index 0000000..ff871a3
--- /dev/null
@@ -0,0 +1,80 @@
+/* COVERAGE: lseek llseek */
+#define _BSD_SOURCE
+#define _DEFAULT_SOURCE
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <linux/unistd.h>
+#include <sys/uio.h>
+#include <sys/syscall.h>
+
+#define STRING1 "red"
+#define STRING2 "green"
+#define STRING3 "blue"
+int main()
+{
+  int fd;
+  loff_t res;
+  char buf[64], buf1[32], buf2[32], buf3[32];
+
+  fd = open("foobar1", O_WRONLY|O_CREAT, 0666);
+  //staptest// open ("foobar1", O_WRONLY|O_CREAT[[[[.O_LARGEFILE]]]]?, 0666) = NNNN
+
+  write(fd, "Hello world", 11);
+  //staptest// write (NNNN, "Hello world", 11) = 11
+
+  lseek(fd, 0, SEEK_SET);
+  //staptest// lseek (NNNN, 0, SEEK_SET) = 0
+
+  lseek(fd, 1, SEEK_CUR);
+  //staptest// lseek (NNNN, 1, SEEK_CUR) = 1
+
+  lseek(-1, 0, SEEK_SET);
+  //staptest// lseek (-1, 0, SEEK_SET) = -NNNN (EBADF)
+
+  lseek(fd, -1, SEEK_END);
+  //staptest// lseek (NNNN, -1, SEEK_END) = NNNN
+
+  lseek(fd, 0, -1);
+  //staptest// lseek (NNNN, 0, 0x[f]+) = -NNNN (EINVAL)
+
+#ifdef SYS__llseek
+  syscall(SYS__llseek, fd, 1, 0, &res, SEEK_SET);
+  //staptest// llseek (NNNN, 0x1, 0x0, XXXX, SEEK_SET) = 0
+
+  syscall(SYS__llseek, fd, 0, 0, &res, SEEK_SET);
+  //staptest// llseek (NNNN, 0x0, 0x0, XXXX, SEEK_SET) = 0
+
+  syscall(SYS__llseek, fd, 0, 12, &res, SEEK_CUR);
+  //staptest// llseek (NNNN, 0x0, 0xc, XXXX, SEEK_CUR) = 0
+
+  syscall(SYS__llseek, fd, 8, 1, &res, SEEK_END);
+  //staptest// llseek (NNNN, 0x8, 0x1, XXXX, SEEK_END) = 0
+
+  syscall(SYS__llseek, -1, 1, 0, &res, SEEK_SET);
+  //staptest// llseek (-1, 0x1, 0x0, XXXX, SEEK_SET) = -NNNN (EBADF)
+
+  syscall(SYS__llseek, fd, -1, 0, &res, SEEK_SET);
+  //staptest// llseek (NNNN, 0x[f]+, 0x0, XXXX, SEEK_SET) = -NNNN (EINVAL)
+
+  syscall(SYS__llseek, fd, 0, -1, &res, SEEK_SET);
+  //staptest// llseek (NNNN, 0x0, 0x[f]+, XXXX, SEEK_SET) = NNNN
+
+  syscall(SYS__llseek, fd, 0, 0, (loff_t *)-1, SEEK_SET);
+#ifdef __s390__
+  //staptest// llseek (NNNN, 0x0, 0x0, 0x[7]?[f]+, SEEK_SET) = -NNNN (EFAULT)
+#else
+  //staptest// llseek (NNNN, 0x0, 0x0, 0x[f]+, SEEK_SET) = -NNNN (EFAULT)
+#endif
+
+  syscall(SYS__llseek, fd, 0, 0, &res, -1);
+  //staptest// llseek (NNNN, 0x0, 0x0, XXXX, 0x[f]+) = -NNNN (EINVAL)
+#endif
+
+  close (fd);
+  //staptest// close (NNNN) = 0
+
+  return 0;
+}
diff --git a/testsuite/systemtap.syscall/pread.c b/testsuite/systemtap.syscall/pread.c
new file mode 100644 (file)
index 0000000..cecfc5c
--- /dev/null
@@ -0,0 +1,62 @@
+/* COVERAGE: pread */
+#define _BSD_SOURCE
+#define _DEFAULT_SOURCE
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <linux/unistd.h>
+#include <sys/uio.h>
+#include <sys/syscall.h>
+
+#define STRING1 "red"
+#define STRING2 "green"
+#define STRING3 "blue"
+int main()
+{
+  int fd;
+  loff_t res;
+  char buf[64], buf1[32], buf2[32], buf3[32];
+
+  fd = open("foobar1", O_WRONLY|O_CREAT, 0666);
+  //staptest// open ("foobar1", O_WRONLY|O_CREAT[[[[.O_LARGEFILE]]]]?, 0666) = NNNN
+
+  write(fd, "Hello world abcdefghijklmnopqrstuvwxyz 01234567890123456789", 59);
+  //staptest// write (NNNN, "Hello world abcdefghijklmnopqrstuvwxyz 012345"..., 59) = 59
+
+  close (fd);
+  //staptest// close (NNNN) = 0
+
+  fd = open("foobar1", O_RDONLY);
+  //staptest// open ("foobar1", O_RDONLY[[[[.O_LARGEFILE]]]]?) = NNNN
+
+  pread(fd, buf, 11, 10);
+  //staptest// pread (NNNN, XXXX, 11, 10) = 11
+
+  pread(-1, buf, 11, 10);
+  //staptest// pread (-1, XXXX, 11, 10) = NNNN
+
+  pread(fd, (void *)-1, 11, 10);
+#ifdef __s390__
+  //staptest// pread (NNNN, 0x[7]?[f]+, 11, 10) = NNNN
+#else
+  //staptest// pread (NNNN, 0x[f]+, 11, 10) = NNNN
+#endif
+
+  /* We need to be careful when reading -1 bytes. */
+  pread(-1, NULL, -1, 10);
+#if __WORDSIZE == 64
+  //staptest// pread (-1, 0x0, 18446744073709551615, 10) = -NNNN
+#else
+  //staptest// pread (-1, 0x0, 4294967295, 10) = -NNNN
+#endif
+
+  pread(fd, buf, 11, -1);
+  //staptest// pread (NNNN, XXXX, 11, -1) = NNNN
+
+  close (fd);
+  //staptest// close (NNNN) = 0
+
+  return 0;
+}
diff --git a/testsuite/systemtap.syscall/pwrite.c b/testsuite/systemtap.syscall/pwrite.c
new file mode 100644 (file)
index 0000000..adebdd5
--- /dev/null
@@ -0,0 +1,53 @@
+/* COVERAGE: pwrite */
+#define _BSD_SOURCE
+#define _DEFAULT_SOURCE
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <linux/unistd.h>
+#include <sys/uio.h>
+#include <sys/syscall.h>
+
+#define STRING1 "red"
+#define STRING2 "green"
+#define STRING3 "blue"
+int main()
+{
+  int fd;
+  loff_t res;
+  char buf[64], buf1[32], buf2[32], buf3[32];
+
+  fd = open("foobar1", O_WRONLY|O_CREAT, 0666);
+  //staptest// open ("foobar1", O_WRONLY|O_CREAT[[[[.O_LARGEFILE]]]]?, 0666) = NNNN
+
+  pwrite(fd, "Hello Again", 11, 12);
+  //staptest// pwrite (NNNN, "Hello Again", 11, 12) = 11
+
+  pwrite(-1, "Hello Again", 11, 12);
+  //staptest// pwrite (-1, "Hello Again", 11, 12) = NNNN
+
+  pwrite(fd, (void *)-1, 11, 12);
+#ifdef __s390__
+  //staptest// pwrite (NNNN, [7]?[f]+, 11, 12) = NNNN
+#else
+  //staptest// pwrite (NNNN, [f]+, 11, 12) = NNNN
+#endif
+
+  /* We need to be careful when writing -1 bytes. */
+  pwrite(-1, NULL, -1, 12);
+#if __WORDSIZE == 64
+  //staptest// pwrite (-1, *(null), 18446744073709551615, 12) = NNNN
+#else
+  //staptest// pwrite (-1, *(null), 4294967295, 12) = NNNN
+#endif
+
+  pwrite(fd, "Hello Again", 11, -1);
+  //staptest// pwrite (NNNN, "Hello Again", 11, -1) = NNNN
+
+  close (fd);
+  //staptest// close (NNNN) = 0
+
+  return 0;
+}
index a110f1b9d5ee49a9d224100d5781ad27e360ee61..8e1644c9491172f4424a99ca5bae8b2b135e2a78 100644 (file)
@@ -1,4 +1,4 @@
-/* COVERAGE: read write lseek llseek */
+/* COVERAGE: read write */
 #define _BSD_SOURCE
 #define _DEFAULT_SOURCE
 #include <sys/types.h>
@@ -19,70 +19,37 @@ int main()
   loff_t res;
   char buf[64], buf1[32], buf2[32], buf3[32];
 
-  fd = open("foobar1",O_WRONLY|O_CREAT, 0666);
+  fd = open("foobar1", O_WRONLY|O_CREAT, 0666);
   //staptest// open ("foobar1", O_WRONLY|O_CREAT[[[[.O_LARGEFILE]]]]?, 0666) = NNNN
 
-  write(fd,"Hello world", 11);
+  write(fd, "Hello world", 11);
   //staptest// write (NNNN, "Hello world", 11) = 11
 
-  write(fd,"Hello world abcdefghijklmnopqrstuvwxyz 01234567890123456789", 59);
+  write(fd, "Hello world abcdefghijklmnopqrstuvwxyz 01234567890123456789", 59);
   //staptest// write (NNNN, "Hello world abcdefghijklmnopqrstuvwxyz 012345"..., 59) = 59
 
-  pwrite(fd,"Hello Again",11,12);
-  //staptest// pwrite (NNNN, "Hello Again", 11, 12) = 11
+  write(-1, "Hello world", 11);
+  //staptest// write (-1, "Hello world", 11) = NNNN
 
-  lseek(fd, 0, SEEK_SET);
-  //staptest// lseek (NNNN, 0, SEEK_SET) = 0
-
-  lseek(fd, 1, SEEK_CUR);
-  //staptest// lseek (NNNN, 1, SEEK_CUR) = 1
-
-  lseek(-1, 0, SEEK_SET);
-  //staptest// lseek (-1, 0, SEEK_SET) = -NNNN (EBADF)
-
-  lseek(fd, -1, SEEK_END);
-  //staptest// lseek (NNNN, -1, SEEK_END) = NNNN
-
-  lseek(fd, 0, -1);
-  //staptest// lseek (NNNN, 0, 0x[f]+) = -NNNN (EINVAL)
-
-#ifdef SYS__llseek
-  syscall(SYS__llseek, fd, 1, 0, &res, SEEK_SET);
-  //staptest// llseek (NNNN, 0x1, 0x0, XXXX, SEEK_SET) = 0
-
-  syscall(SYS__llseek, fd, 0, 0, &res, SEEK_SET);
-  //staptest// llseek (NNNN, 0x0, 0x0, XXXX, SEEK_SET) = 0
-
-  syscall(SYS__llseek, fd, 0, 12, &res, SEEK_CUR);
-  //staptest// llseek (NNNN, 0x0, 0xc, XXXX, SEEK_CUR) = 0
-
-  syscall(SYS__llseek, fd, 8, 1, &res, SEEK_END);
-  //staptest// llseek (NNNN, 0x8, 0x1, XXXX, SEEK_END) = 0
-
-  syscall(SYS__llseek, -1, 1, 0, &res, SEEK_SET);
-  //staptest// llseek (-1, 0x1, 0x0, XXXX, SEEK_SET) = -NNNN (EBADF)
-
-  syscall(SYS__llseek, fd, -1, 0, &res, SEEK_SET);
-  //staptest// llseek (NNNN, 0x[f]+, 0x0, XXXX, SEEK_SET) = -NNNN (EINVAL)
-
-  syscall(SYS__llseek, fd, 0, -1, &res, SEEK_SET);
-  //staptest// llseek (NNNN, 0x0, 0x[f]+, XXXX, SEEK_SET) = NNNN
-
-  syscall(SYS__llseek, fd, 0, 0, (loff_t *)-1, SEEK_SET);
+  write(fd, (void *)-1, 11);
 #ifdef __s390__
-  //staptest// llseek (NNNN, 0x0, 0x0, 0x[7]?[f]+, SEEK_SET) = -NNNN (EFAULT)
+  //staptest// write (NNNN, [7]?[f]+, 11) = NNNN
 #else
-  //staptest// llseek (NNNN, 0x0, 0x0, 0x[f]+, SEEK_SET) = -NNNN (EFAULT)
+  //staptest// write (NNNN, [f]+, 11) = NNNN
 #endif
 
-  syscall(SYS__llseek, fd, 0, 0, &res, -1);
-  //staptest// llseek (NNNN, 0x0, 0x0, XXXX, 0x[f]+) = -NNNN (EINVAL)
+  /* We need to be careful when writing -1 bytes. */
+  write(-1, NULL, -1);
+#if __WORDSIZE == 64
+  //staptest// write (-1, *(null), 18446744073709551615) = -NNNN
+#else
+  //staptest// write (-1, *(null), 4294967295) = -NNNN
 #endif
 
   close (fd);
   //staptest// close (NNNN) = 0
 
-  fd = open("foobar1",O_RDONLY);
+  fd = open("foobar1", O_RDONLY);
   //staptest// open ("foobar1", O_RDONLY[[[[.O_LARGEFILE]]]]?) = NNNN
 
   read(fd, buf, 11);
@@ -91,8 +58,23 @@ int main()
   read(fd, buf, 50);
   //staptest// read (NNNN, XXXX, 50) = 50
 
-  pread(fd, buf, 11, 10);
-  //staptest// pread (NNNN, XXXX, 11, 10) = 11
+  read(-1, buf, 50);
+  //staptest// read (-1, XXXX, 50) = NNNN
+
+  read(fd, (void *)-1, 50);
+#ifdef __s390__
+  //staptest// read (NNNN, 0x[7]?[f]+, 50) = NNNN
+#else
+  //staptest// read (NNNN, 0x[f]+, 50) = NNNN
+#endif
+
+  /* We need to be careful when reading -1 bytes. */
+  read(-1, NULL, -1);
+#if __WORDSIZE == 64
+  //staptest// read (-1, 0x0, 18446744073709551615) = -NNNN
+#else
+  //staptest// read (-1, 0x0, 4294967295) = -NNNN
+#endif
 
   close (fd);
   //staptest// close (NNNN) = 0
This page took 0.047012 seconds and 5 git commands to generate.