From: Jeff Mahoney <je...@suse.com> * tests/file_ioctl.c: New file. * tests/file_ioctl.test: New file. * tests/Makefile.am: Add it.
This is limited to FIEMAP. FICLONE* and FIDEDUPERANGE originated in btrfs and will be tested there. --- tests/Makefile.am | 2 ++ tests/file_ioctl.c | 32 ++++++++++++++++++++++++++++++++ tests/file_ioctl.test | 5 +++++ tests/tests.h | 19 +++++++++++++++++++ 4 files changed, 58 insertions(+) create mode 100644 tests/file_ioctl.c create mode 100755 tests/file_ioctl.test diff --git a/tests/Makefile.am b/tests/Makefile.am index 64c1879..77ca08f 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -107,6 +107,7 @@ check_PROGRAMS = \ fcntl64 \ fdatasync \ file_handle \ + file_ioctl \ filter-unavailable \ flock \ fork-f \ @@ -396,6 +397,7 @@ DECODER_TESTS = \ fcntl64.test \ fdatasync.test \ file_handle.test \ + file_ioctl.test \ flock.test \ fstat.test \ fstat64.test \ diff --git a/tests/file_ioctl.c b/tests/file_ioctl.c new file mode 100644 index 0000000..be064db --- /dev/null +++ b/tests/file_ioctl.c @@ -0,0 +1,32 @@ +#include <stdio.h> +#include <linux/fiemap.h> +#include <linux/fs.h> +#include "tests.h" +#include "xlat.h" + +#include "xlat/fiemap_flags.h" + +static void +test_fiemap(void) +{ + struct fiemap args = {}; + printf("ioctl(-1, FS_IOC_FIEMAP, {fm_start=%" PRI__u64 + ", fm_length=%" PRI__u64", fm_flags=", + args.fm_start, args.fm_length); + printflags(fiemap_flags, args.fm_flags, "FIEMAP_FLAG_???"); + printf(", fm_extent_count=%u})", args.fm_extent_count); + ioctl(-1, FS_IOC_FIEMAP, &args); + printf(" = -1 EBADF (%m)\n"); +} + +/* clone and dedupe ioctls are in btrfs.c since they originated there */ + +int +main(int argc, char *argv[]) +{ + test_fiemap(); + + puts("+++ exited with 0 +++"); + + return 0; +} diff --git a/tests/file_ioctl.test b/tests/file_ioctl.test new file mode 100755 index 0000000..2121b5b --- /dev/null +++ b/tests/file_ioctl.test @@ -0,0 +1,5 @@ +#!/bin/sh + +# Check basic btrfs ioctl decoding. + +. "${srcdir=.}/ioctl.test" diff --git a/tests/tests.h b/tests/tests.h index 9909222..fdac6b4 100644 --- a/tests/tests.h +++ b/tests/tests.h @@ -107,4 +107,23 @@ int printxval(const struct xlat *, const unsigned long long, const char *); # define SKIP_MAIN_UNDEFINED(arg) \ int main(void) { error_msg_and_skip("undefined: %s", arg); } +/* + * The kernel used to define 64-bit types on 64-bit systems on a per-arch + * basis. Some architectures would use unsigned long and others would use + * unsigned long long. These types were exported as part of the + * kernel-userspace ABI and now must be maintained forever. This matches + * what the kernel exports for each architecture so we don't need to cast + * every printing of __u64 or __s64 to stdint types. + */ +#if SIZEOF_LONG == 4 +# define PRI__64 "ll" +#elif defined ALPHA || defined IA64 || defined MIPS || defined POWERPC +# define PRI__64 "l" +#else +# define PRI__64 "ll" +#endif + +#define PRI__d64 PRI__64"d" +#define PRI__u64 PRI__64"u" +#define PRI__x64 PRI__64"x" #endif -- 1.8.5.6 ------------------------------------------------------------------------------ Mobile security can be enabling, not merely restricting. Employees who bring their own devices (BYOD) to work are irked by the imposition of MDM restrictions. Mobile Device Manager Plus allows you to control only the apps on BYO-devices by containerizing them, leaving personal data untouched! https://ad.doubleclick.net/ddm/clk/304595813;131938128;j _______________________________________________ Strace-devel mailing list Strace-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/strace-devel