]> sourceware.org Git - systemtap.git/commitdiff
PR16207 partial fix: Fix the access [nd_]syscall.exp tests on rawhide.
authorDavid Smith <dsmith@redhat.com>
Fri, 22 Nov 2013 22:41:54 +0000 (16:41 -0600)
committerDavid Smith <dsmith@redhat.com>
Fri, 22 Nov 2013 22:41:54 +0000 (16:41 -0600)
* tapset/linux/syscalls.stpm: Add @__syscall_compat_gate() macro.
* tapset/linux/syscalls.stp: Add @__syscall_compat_gate() macro call to
  syscall.faccessat and syscall.faccess.return.
* tapset/linux/nd_syscalls.stp: Add @__syscall_compat_gate() macro call to
  nd_syscall.faccessat and nd_syscall.faccess.return.
* testsuite/systemtap.syscall/access.c: Updated testcase to handle
  access() no longer being a wrapper around faccessat().
* runtime/linux/compat_unistd.h: New file.
* tapset/linux/aux_syscalls.stp: Include compat_unistd.h.

runtime/linux/compat_unistd.h [new file with mode: 0644]
tapset/linux/aux_syscalls.stp
tapset/linux/nd_syscalls.stp
tapset/linux/syscalls.stp
tapset/linux/syscalls.stpm
testsuite/systemtap.syscall/access.c

diff --git a/runtime/linux/compat_unistd.h b/runtime/linux/compat_unistd.h
new file mode 100644 (file)
index 0000000..a7ce1ed
--- /dev/null
@@ -0,0 +1,35 @@
+/* -*- linux-c -*- 
+ * Syscall compatibility defines.
+ * Copyright (C) 2013 Red Hat Inc.
+ *
+ * This file is part of systemtap, and is free software.  You can
+ * redistribute it and/or modify it under the terms of the GNU General
+ * Public License (GPL); either version 2, or (at your option) any
+ * later version.
+ */
+
+#ifndef _COMPAT_UNISTD_H_
+#define _COMPAT_UNISTD_H_
+
+#if defined(__x86_64__)
+
+// On older kernels (like RHEL5), we have to define our own 32-bit
+// syscall numbers.
+#ifndef __NR_ia32_faccessat
+#define __NR_ia32_faccessat 307
+#endif
+
+#define __NR_compat_faccessat          __NR_ia32_faccessat
+
+#endif /* __x86_64__ */
+
+#if defined(__powerpc64__) || defined (__s390x__)
+
+// On the ppc64 and s390x, the 32-bit syscalls use the same number
+// as the 64-bit syscalls.
+
+#define __NR_compat_faccessat          __NR_faccessat
+
+#endif /* __powerpc64__ || __s390x__ */
+
+#endif /* _COMPAT_UNISTD_H_ */
index 79250121aa401025caae0e063465df84a0b665ee..2141a06951a801b36db33d8dd8ceb7ec56021d8a 100644 (file)
@@ -2,6 +2,7 @@
 %{
 // Be sure we have the __NR_* defines.
 #include <asm/unistd.h>
+#include "linux/compat_unistd.h"
 %}
 
 function _stp_syscall_nr:long ()
index d89240fb3204d662ebc176b724065f438e0785c6..4d39ec7ab0b9b9df832d02bd986a9de7ac99a13d 100644 (file)
@@ -1129,6 +1129,8 @@ probe nd_syscall.exit_group = kprobe.function("sys_exit_group").call ?
 # long sys_faccessat(int dfd, const char __user *filename, int mode)
 probe nd_syscall.faccessat = kprobe.function("sys_faccessat") ?
 {
+       @__syscall_compat_gate(%{ __NR_faccessat %},
+                              %{ __NR_compat_faccessat %})
        name = "faccessat"
        // dirfd = $dfd
        // dirfd_str = _dfd_str($dfd)
@@ -1146,6 +1148,8 @@ probe nd_syscall.faccessat = kprobe.function("sys_faccessat") ?
 }
 probe nd_syscall.faccessat.return = kprobe.function("sys_faccessat").return ?
 {
+       @__syscall_compat_gate(%{ __NR_faccessat %},
+                              %{ __NR_compat_faccessat %})
        name = "faccessat"
        retstr = returnstr(1)
 }
index f53cf88a8fcd30c78253b5eb7348677718ad9e89..7f1358bb53b9f694f34f14a2750c4a109dad76e3 100644 (file)
@@ -857,6 +857,8 @@ probe syscall.exit_group = kernel.function("sys_exit_group").call
 # long sys_faccessat(int dfd, const char __user *filename, int mode)
 probe syscall.faccessat = kernel.function("sys_faccessat").call ?
 {
+       @__syscall_compat_gate(%{ __NR_faccessat %},
+                              %{ __NR_compat_faccessat %})
        name = "faccessat"
        dirfd = $dfd
        dirfd_str = _dfd_str($dfd)
@@ -867,6 +869,8 @@ probe syscall.faccessat = kernel.function("sys_faccessat").call ?
 }
 probe syscall.faccessat.return = kernel.function("sys_faccessat").return ?
 {
+       @__syscall_compat_gate(%{ __NR_faccessat %},
+                              %{ __NR_compat_faccessat %})
        name = "faccessat"
        retstr = return_str(1, $return)
 }
index 652a4e36499490b25b5201bd3aa023107a230b6b..bbd90f22c9f3efb23f780eecf56d41d82a7ca87b 100644 (file)
 
        if (_stp_syscall_nr() != @syscall_nr) next
 %)
+
+@define __syscall_compat_gate(syscall_nr, compat_syscall_nr)
+%(
+    %( CONFIG_COMPAT == "y" %?
+       __nr = _stp_syscall_nr()
+       if (%{ _stp_is_compat_task() %}) {
+               if (__nr != @compat_syscall_nr)
+                       next
+       }
+       else if (__nr != @syscall_nr)
+               next
+    %:
+       if (_stp_syscall_nr() != @syscall_nr) next
+    %)
+%)
index 450660156af25088a350571da515aaa3151b166d..1d73f5e245a64f06bea6b9eb9cb21786c558fc3f 100644 (file)
@@ -1,10 +1,21 @@
-/* COVERAGE: access */
+/* COVERAGE: access faccessat */
+#define _GNU_SOURCE
 #include <stdio.h>
 #include <unistd.h>
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <fcntl.h>
 
+// To test for glibc support for faccessat():
+//
+// Since glibc 2.10:
+//     _XOPEN_SOURCE >= 700 || _POSIX_C_SOURCE >= 200809L
+// Before glibc 2.10:
+//     _ATFILE_SOURCE
+
+#define GLIBC_SUPPORT \
+  (_XOPEN_SOURCE >= 700 || _POSIX_C_SOURCE >= 200809L \
+   || defined(_ATFILE_SOURCE))
 
 int main()
 {
@@ -13,28 +24,52 @@ int main()
   fd1 = creat("foobar1",S_IREAD|S_IWRITE);
 
   access("foobar1", F_OK);
-  //staptest// access ("foobar1", F_OK)
-  //staptest//   faccessat (AT_FDCWD, "foobar1", F_OK) = 0
+  //staptest// access ("foobar1", F_OK) = 0
+
+#if GLIBC_SUPPORT
+  faccessat(AT_FDCWD, "foobar1", F_OK, 0);
+  //staptest// faccessat (AT_FDCWD, "foobar1", F_OK) = 0
+#endif
 
   access("foobar1", R_OK);
-  //staptest// access ("foobar1", R_OK)
-  //staptest//  faccessat (AT_FDCWD, "foobar1", R_OK) = 0
+  //staptest// access ("foobar1", R_OK) = 0
+
+#if GLIBC_SUPPORT
+  faccessat(AT_FDCWD, "foobar1", R_OK, 0);
+  //staptest// faccessat (AT_FDCWD, "foobar1", R_OK) = 0
+#endif
 
   access("foobar1", W_OK);
-  //staptest// access ("foobar1", W_OK)
-  //staptest//   faccessat (AT_FDCWD, "foobar1", W_OK) = 0
+  //staptest// access ("foobar1", W_OK) = 0
+
+#if GLIBC_SUPPORT
+  faccessat(AT_FDCWD, "foobar1", W_OK, 0);
+  //staptest// faccessat (AT_FDCWD, "foobar1", W_OK) = 0
+#endif
 
   access("foobar1", X_OK);
-  //staptest// access ("foobar1", X_OK)
-  //staptest//   faccessat (AT_FDCWD, "foobar1", X_OK) = -NNNN (EACCES)
+  //staptest// access ("foobar1", X_OK) = -NNNN (EACCES)
+
+#if GLIBC_SUPPORT
+  faccessat(AT_FDCWD, "foobar1", X_OK, 0);
+  //staptest// faccessat (AT_FDCWD, "foobar1", X_OK) = -NNNN (EACCES)
+#endif
 
   access("foobar1", R_OK|W_OK);
-  //staptest// access ("foobar1", W_OK |R_OK)
-  //staptest//   faccessat (AT_FDCWD, "foobar1", W_OK |R_OK) = 0
+  //staptest// access ("foobar1", W_OK |R_OK) = 0
+
+#if GLIBC_SUPPORT
+  faccessat(AT_FDCWD, "foobar1", R_OK|W_OK, 0);
+  //staptest// faccessat (AT_FDCWD, "foobar1", W_OK |R_OK) = 0
+#endif
 
   access("foobar1", R_OK|W_OK|X_OK);
-  //staptest// access ("foobar1", X_OK |W_OK |R_OK)
-  //staptest//   faccessat (AT_FDCWD, "foobar1", X_OK |W_OK |R_OK) = -NNNN (EACCES)
+  //staptest// access ("foobar1", X_OK |W_OK |R_OK) = -NNNN (EACCES)
+
+#if GLIBC_SUPPORT
+  faccessat(AT_FDCWD, "foobar1", R_OK|W_OK|X_OK, 0);
+  //staptest// faccessat (AT_FDCWD, "foobar1", X_OK |W_OK |R_OK) = -NNNN (EACCES)
+#endif
 
   return 0;
 }
This page took 0.049709 seconds and 5 git commands to generate.