* tests/fadvise.h: New file.
* tests/fadvise64.c: Likewise.
* tests/fadvise64_64.c: Likewise.
* tests/fadvise64.test: New test.
* tests/fadvise64_64.test: Likewise.
* tests/.gitignore: Add fadvise64 and fadvise64_64.
* tests/Makefile.am (check_PROGRAMS): Likewise.
(DECODER_TESTS): Add fadvise64.test, fadvise64_64.test.
(EXTRA_DIST): Add fadvise.h.
execveat
execveat-v
faccessat
+fadvise64
+fadvise64_64
fallocate
fanotify_mark
fchdir
execveat \
execveat-v \
faccessat \
+ fadvise64 \
+ fadvise64_64 \
fallocate \
fanotify_mark \
fchdir \
execveat-v.test \
execveat.test \
faccessat.test \
+ fadvise64.test \
+ fadvise64_64.test \
fallocate.test \
fanotify_mark.test \
fchdir.test \
caps.awk \
count-f.expected \
eventfd.expected \
+ fadvise.h \
filter-unavailable.expected \
fstatat.c \
fstatx.c \
--- /dev/null
+/*
+ * Common definitions for fadvise64 and fadvise64_64 tests.
+ *
+ * Copyright (c) 2016 Eugene Syromiatnikov <evgsyr@gmail.com>
+ * Copyright (c) 2016 Dmitry V. Levin <ldv@altlinux.org>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef STRACE_TESTS_FADVISE_H
+#define STRACE_TESTS_FADVISE_H
+
+# include <limits.h>
+# include <stdio.h>
+# include <unistd.h>
+
+# include "xlat.h"
+# include "xlat/advise.h"
+
+# if WORDS_BIGENDIAN
+# define LL_PAIR(HI, LO) (HI), (LO)
+# else
+# define LL_PAIR(HI, LO) (LO), (HI)
+# endif
+# define LL_VAL_TO_PAIR(llval) LL_PAIR((long) ((llval) >> 32), (long) (llval))
+
+static void do_fadvise(long fd, long long offset, long long llen, long advice);
+
+int
+main(void)
+{
+ static const long bogus_fd = (long) 0xfeedf00dbeeffaceULL;
+ static const long long bogus_offset = 0xbadc0dedda7a1057ULL;
+ static const long long bogus_len = 0xbadfaceca7b0d1e5ULL;
+ static const long bogus_advice = (long) 0xf00dfeeddeadca75ULL;
+
+ do_fadvise(bogus_fd, bogus_offset, bogus_len, bogus_advice);
+
+ puts("+++ exited with 0 +++");
+ return 0;
+}
+
+#endif /* !STRACE_TESTS_FADVISE_H */
--- /dev/null
+/*
+ * Check decoding of fadvise64 syscall.
+ *
+ * Copyright (c) 2016 Eugene Syromiatnikov <evgsyr@gmail.com>
+ * Copyright (c) 2016 Dmitry V. Levin <ldv@altlinux.org>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "tests.h"
+
+#include <asm/unistd.h>
+
+#ifdef __NR_fadvise64
+
+# include "fadvise.h"
+
+static void
+do_fadvise(long fd, long long offset, long long llen, long advice)
+{
+ long ret;
+ const char *errstr;
+
+# if (LONG_MAX > INT_MAX) \
+ || (defined __x86_64__ && defined __ILP32__) \
+ || defined LINUX_MIPSN32
+ ret = syscall(__NR_fadvise64, fd, offset, llen, advice);
+ errstr = sprintrc(ret);
+ printf("fadvise64(%d, %lld, %llu, ", (int) fd, offset, llen);
+# elif defined LINUX_MIPSO32
+ ret = syscall(__NR_fadvise64, fd, 0,
+ LL_VAL_TO_PAIR(offset), LL_VAL_TO_PAIR(llen), advice);
+ errstr = sprintrc(ret);
+ printf("fadvise64(%d, %lld, %lld, ", (int) fd, offset, llen);
+# else /* LONG_MAX == INT_MAX && !X32 && !LINUX_MIPSN32 */
+ long len = (long) llen;
+# if defined POWERPC
+ ret = syscall(__NR_fadvise64, fd, 0,
+ LL_VAL_TO_PAIR(offset), len, advice);
+# else
+ ret = syscall(__NR_fadvise64, fd,
+ LL_VAL_TO_PAIR(offset), len, advice);
+# endif
+ errstr = sprintrc(ret);
+ printf("fadvise64(%d, %lld, %lu, ", (int) fd, offset, len);
+# endif /* LONG_MAX == INT_MAX && !X32 && !LINUX_MIPSN32 */
+ printxval(advise, (unsigned) advice, "POSIX_FADV_???");
+ printf(") = %s\n", errstr);
+}
+
+#else
+
+SKIP_MAIN_UNDEFINED("__NR_fadvise64");
+
+#endif
--- /dev/null
+#!/bin/sh
+
+# Check decoding of fadvise64 syscall.
+
+. "${srcdir=.}/init.sh"
+
+run_prog > /dev/null
+run_strace -e $NAME $args > "$EXP"
+check_prog grep
+grep -v "^$NAME([0123]," < "$LOG" > "$OUT"
+match_diff "$OUT" "$EXP"
+rm -f "$EXP" "$OUT"
--- /dev/null
+/*
+ * Check decoding of fadvise64_64 syscall.
+ *
+ * Copyright (c) 2016 Eugene Syromiatnikov <evgsyr@gmail.com>
+ * Copyright (c) 2016 Dmitry V. Levin <ldv@altlinux.org>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "tests.h"
+
+#include <asm/unistd.h>
+
+#ifdef __arm__
+# ifdef __NR_arm_fadvise64_64
+# undef __NR_fadvise64_64
+# define __NR_fadvise64_64 __NR_arm_fadvise64_64
+# endif /* __NR_arm_fadvise64_64 */
+#endif /* __arm__ */
+
+#ifdef __NR_fadvise64_64
+
+# include "fadvise.h"
+
+static void
+do_fadvise(long fd, long long offset, long long llen, long advice)
+{
+ long ret;
+ const char *errstr;
+
+# if (LONG_MAX > INT_MAX) \
+ || (defined __x86_64__ && defined __ILP32__) \
+ || defined LINUX_MIPSN32
+ ret = syscall(__NR_fadvise64_64, fd, offset, llen, advice);
+# elif defined __ARM_EABI__ || defined POWERPC || defined XTENSA
+ ret = syscall(__NR_fadvise64_64, fd, advice,
+ LL_VAL_TO_PAIR(offset), LL_VAL_TO_PAIR(llen));
+# else
+ ret = syscall(__NR_fadvise64_64, fd,
+ LL_VAL_TO_PAIR(offset), LL_VAL_TO_PAIR(llen), advice);
+# endif
+ errstr = sprintrc(ret);
+
+ printf("fadvise64_64(%d, %lld, %lld, ", (int) fd, offset, llen);
+ printxval(advise, (unsigned) advice, "POSIX_FADV_???");
+ printf(") = %s\n", errstr);
+}
+
+#else
+
+SKIP_MAIN_UNDEFINED("__NR_fadvise64_64");
+
+#endif
--- /dev/null
+#!/bin/sh
+
+# Check decoding of fadvise64_64 syscall.
+
+. "${srcdir=.}/fadvise64.test"