]> sourceware.org Git - systemtap.git/commitdiff
PR16716 partial fix: Fix types for the flock syscall
authorMartin Cermak <mcermak@redhat.com>
Thu, 25 Sep 2014 07:24:36 +0000 (09:24 +0200)
committerMartin Cermak <mcermak@redhat.com>
Thu, 25 Sep 2014 07:25:45 +0000 (09:25 +0200)
* tapset/linux/syscalls.stp: Fix types
* testsuite/systemtap.syscall/flock.c: New testcase

tapset/linux/syscalls.stp
testsuite/systemtap.syscall/flock.c [new file with mode: 0644]

index bcc7f60654be8a7eb194a4c367820e2c0456fb67..e9069b3dc700a9e03e577863336e90097a9c5e4e 100644 (file)
@@ -1330,7 +1330,7 @@ probe syscall.flistxattr.return = kernel.function("sys_flistxattr").return
 probe syscall.flock = kernel.function("sys_flock").call
 {
        name = "flock"
-       fd = $fd
+       fd = __int32($fd)
        operation = $cmd
        argstr = sprintf("%d, %s", fd, _flock_cmd_str(operation))
 }
diff --git a/testsuite/systemtap.syscall/flock.c b/testsuite/systemtap.syscall/flock.c
new file mode 100644 (file)
index 0000000..75bb832
--- /dev/null
@@ -0,0 +1,48 @@
+/* COVERAGE: flock */
+#include <stdio.h>
+#include <sys/file.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+
+int fd;
+char filename[100];
+
+
+int main() {
+    sprintf(filename, "flock-tst.%d", getpid());
+    fd = creat(filename, 0644);
+    if (fd < 0) {
+        printf("ERROR");
+        return 1;
+    }
+
+    // --- test normal operation ---
+
+    flock(fd, LOCK_SH);
+    //staptest// flock (NNNN, LOCK_SH) = 0
+
+    flock(fd, LOCK_UN);
+    //staptest// flock (NNNN, LOCK_UN) = 0
+
+    flock(fd, LOCK_EX);
+    //staptest// flock (NNNN, LOCK_EX) = 0
+
+    flock(fd, LOCK_UN);
+    //staptest// flock (NNNN, LOCK_UN) = 0
+
+    // --- now try nasty things ---
+
+    flock(-1, LOCK_SH);
+    //staptest// flock (-1, LOCK_SH) = NNNN (EBADF)
+
+    flock(fd, -1);
+    //staptest// flock (NNNN, LOCK_NB|LOCK_UN|LOCK_EX|LOCK_SH) = 0
+
+    // The above should do LOCK_SH in fact.
+    // So let's go ahead and call LOCK_UN at the end:
+    flock(fd, LOCK_UN);
+
+    close(fd);
+    unlink(filename);
+}
This page took 0.032883 seconds and 5 git commands to generate.