Commit Graph

4138 Commits

Author SHA1 Message Date
ea516df85e btrfs.c: fix build on systems without BTRFS_IOC_FILE_EXTENT_SAME
* btrfs.c (btrfs_ioctl): Skip BTRFS_IOC_FILE_EXTENT_SAME case
if this constant is not defined.
* tests/btrfs.c (btrfs_test_extent_same_ioctl): Skip this part
of the test if BTRFS_IOC_FILE_EXTENT_SAME is not defined.
2016-05-24 14:52:27 +00:00
3f36611e98 tests/btrfs.c: fix printing struct btrfs_ioctl_clone_range_args
* tests/btrfs.c (btrfs_test_clone_ioctls): Print __u64 members
of struct btrfs_ioctl_clone_range_args using PRI__u64 format.
2016-05-24 14:52:27 +00:00
57888fa5f9 tests/btrfs.c: tweak magic constants to make the test more reliable
* tests/btrfs.c (btrfs_test_sync_ioctls): Change u64val
to 0xdeadbeefbadc0ded.
(btrfs_test_subvol_ioctls): Likewise.  Change bad_pointer
to make their lower 32-bit parts closer to -1U.
2016-05-24 14:52:27 +00:00
6ce6d3be10 btrfs.c: print file descriptors using printfd
* btrfs.c (btrfs_ioctl): Print struct btrfs_ioctl_send_args.send_fd,
struct btrfs_ioctl_vol_args.fd, and struct btrfs_ioctl_vol_args_v2.fd
using printfd.
* tests/btrfs.c (btrfs_print_vol_args_v2, btrfs_test_subvol_ioctls,
btrfs_test_device_ioctls, btrfs_test_clone_ioctls,
btrfs_test_send_ioctl): Update.
2016-05-24 14:52:27 +00:00
9298c66dc0 tests/btrfs.c: do not print errno in case of fs type mismatch
* tests/btrfs.c (main): Use error_msg_and_fail instead of
perror_msg_and_fail when the fs type of the given directory
is not BTRFS_SUPER_MAGIC.
2016-05-24 14:52:27 +00:00
2447de4ca1 tests/btrfs.c: fix indentation
* tests/btrfs.c: Fix indentation of preprocessor directives
and function prototypes.
2016-05-24 14:52:27 +00:00
28a5f66e2e tests/btrfs.c: sort included headers
* tests/btrfs.c: Sort included headers.
2016-05-24 14:52:27 +00:00
45fcc0c853 tests/btrfs.c: do not use alloca
* tests/btrfs.c: Don't include <alloca.h>.
(btrfs_test_subvol_ioctls): Allocate
struct btrfs_ioctl_vol_args_v2.qgroup_inherit using tail_alloc.
2016-05-24 14:52:27 +00:00
2212918aa2 tests/btrfs.c: fix build on systems without <linux/btrfs.h> or <linux/fiemap.h>
* tests/btrfs.c: Include "tests.h" first.
Skip the test if [!HAVE_LINUX_BTRFS_H].  Skip parts of the test
that use struct fiemap if [!HAVE_LINUX_FIEMAP_H].
2016-05-24 14:52:27 +00:00
Jeff Mahoney
3586679f7a tests: add testing for btrfs ioctls
* tests/btrfs.c: New file.
* tests/btrfs.test: New test.
* tests/btrfs-v.test: Likewise.
* tests/.gitignore: Add btrfs.
* tests/Makefile.am (check_PROGRAMS): Likewise.
(DECODER_TESTS): Add btrfs.test and btrfs-v.test.
2016-05-24 14:52:27 +00:00
aab00c2023 tests/file_ioctl.c: use tail_alloc
* tests/file_ioctl.c (main): Allocate struct fiemap using tail_alloc.
2016-05-24 14:52:27 +00:00
3b730d4a0f tests/file_ioctl.c: fix build on systems without <linux/fiemap.h>
* tests/file_ioctl.c: Include "tests.h" first.
Skip the test if [!HAVE_LINUX_FIEMAP_H].
2016-05-24 14:52:27 +00:00
Jeff Mahoney
c05c24cc51 tests: add testing for FS_IOC_FIEMAP
This is limited to FIEMAP.  FICLONE* and FIDEDUPERANGE originated in
btrfs and will be tested there.

* tests/file_ioctl.c: New file.
* tests/file_ioctl.test: New test.
* tests/.gitignore: Add file_ioctl.
* tests/Makefile.am (check_PROGRAMS): Likewise.
(DECODER_TESTS): Add file_ioctl.test.
2016-05-24 14:52:27 +00:00
fb0c6095f3 Mpersify btrfs.c
* btrfs.c: Mpersify 3 arch-specific structures
and corresponding ioctl numbers.
(btrfs_ioctl): Mpersify.
* defs.h (btrfs_ioctl): Remove.
2016-05-24 14:52:27 +00:00
d57cc26bf0 btrfs.c: use print_array
* btrfs.c (print_btrfs_data_container_logical_ino,
print_btrfs_data_container_ino_path, print_uint64,
print_btrfs_ioctl_search_header, print_objectid_callback,
print_btrfs_ioctl_space_info): New functions.
(btrfs_print_logical_ino_container, btrfs_print_ino_path_container):
Rewrite printers of struct btrfs_data_container.val array
using print_array.
(btrfs_print_qgroup_inherit): Rewrite printer of
struct btrfs_qgroup_inherit.qgroups array using print_array.
(btrfs_print_tree_search): Rewrite printer of
struct btrfs_ioctl_search_header array using print_array.
(btrfs_ioctl): Rewrite printer of
struct btrfs_ioctl_send_args.clone_sources and
struct btrfs_ioctl_space_args.spaces using print_array.
2016-05-24 14:52:27 +00:00
82b9e34e7c btrfs.c: simplify BTRFS_IOC_GET_FSLABEL parser
* btrfs.c (btrfs_ioctl): Share code of parser of BTRFS_IOC_SET_FSLABEL
with parser of BTRFS_IOC_GET_FSLABEL only on BTRFS_IOC_GET_FSLABEL's
entering.
2016-05-24 14:52:27 +00:00
d67b2173a1 btrfs.c: fix BTRFS_IOC_TREE_SEARCH_V2 output
* btrfs.c (btrfs_ioctl): Fix BTRFS_IOC_TREE_SEARCH_V2 output
in case of EOVERFLOW and failed umove.
2016-05-24 14:52:27 +00:00
6638a5d132 btrfs.c: cleanup use of tcp->auxstr
* btrfs.c (btrfs_ioctl): Reset tcp->auxstr only if it is set.
2016-05-24 14:52:27 +00:00
92b90621cc btrfs.c: cleanup struct btrfs_ioctl_get_dev_stats.nr_items check
* btrfs.c (btrfs_ioctl): Cleanup check of iterator of
btrfs_ioctl_get_dev_stats.values array.
2016-05-24 14:52:27 +00:00
0cd7ea0552 btrfs.c: do not use BTRFS_SUBVOL_NAME_MAX
* btrfs.c [BTRFS_SUBVOL_NAME_MAX]: Remove.
(btrfs_ioctl): Use sizeof(struct btrfs_ioctl_vol_args_v2.name)
instead of BTRFS_SUBVOL_NAME_MAX + 1.
2016-05-24 14:52:27 +00:00
b85d09f316 btrfs.c: mark some function arguments as const
* btrfs.c (btrfs_print_balance_args, btrfs_print_features,
btrfs_print_qgroup_limit, btrfs_print_data_container_header,
btrfs_print_logical_ino_container, btrfs_print_ino_path_container,
btrfs_print_qgroup_inherit): Mark some function arguments as const.
2016-05-24 14:52:27 +00:00
90ffbc79b0 btrfs.c: use umove instead of umoven
* btrfs.c: Use umove instead of umoven and umove_or_printaddr
instead of umoven_or_printaddr.
2016-05-24 14:52:27 +00:00
3ce2dfcebb btrfs.c: remove unused variable
* btrfs.c (btrfs_ioctl): Remove "ret" variable.
2016-05-24 14:52:27 +00:00
95577cf9d3 btrfs.c: use printxval/printxval64 instead of printxvals
* btrfs.c (btrfs_ioctl): Do not call printxvals directly,
use printxval/printxval64 wrappers that do the right thing.
2016-05-24 14:52:27 +00:00
2be39ec201 btrfs.c: fix indentation
* btrfs.c: Fix indentation of preprocessor directives and print formats.
2016-05-24 14:52:27 +00:00
aa7787f85b xlat/btrfs_dev_stats_values.in: cleanup
* xlat/btrfs_dev_stats_values.in: Remove HAVE_DECL_* defines,
use #unconditional instead.
2016-05-24 14:52:27 +00:00
d2bd683202 file_ioctl.c: use print_array
* file_ioctl.c (file_ioctl): Rewrite printers of
struct file_dedupe_range_info and struct fiemap_extent arrays
using print_array.
2016-05-24 14:52:27 +00:00
0b13d9c294 file_ioctl.c: fix indentation
* file_ioctl.c: Fix indentation of preprocessor directives
and print formats.
2016-05-24 14:52:27 +00:00
1d2201c95c file_ioctl.c: include <linux/ioctl.h> instead of <sys/ioctl.h>
Being a wrapper around <linux/ioctl.h>, <sys/ioctl.h> brings
no benefits for this parser.

* file_ioctl.c: Include <linux/ioctl.h> instead of <sys/ioctl.h>.
2016-05-24 14:52:27 +00:00
c5253077d8 file_ioctl.c: fix build on systems without <linux/fiemap.h>
* configure.ac (AC_CHECK_HEADERS): Add linux/fiemap.h.
* file_ioctl.c: Do not include <linux/fiemap.h> and xlat/fiemap_*.h
if [!HAVE_LINUX_FIEMAP_H].
(file_ioctl): Do not parse FS_IOC_FIEMAP if [!HAVE_LINUX_FIEMAP_H].
2016-05-24 14:52:27 +00:00
25f3758510 ioctl.c: fix build
* ioctl.c (ioctl_decode): Move definition of "ret" variable
to [ALPHA || POWERPC] case.
[ALPHA || POWERPC]: Fix syntax error.
2016-05-24 14:52:27 +00:00
Jeff Mahoney
398fe0493e ioctl: add decoding for FS_IOC_FIEMAP
* file_ioctl.c: Include <linux/fiemap.h>, "xlat/fiemap_flags.h",
and "xlat/fiemap_extent_flags.h".
(file_ioctl): Handle FS_IOC_FIEMAP.
* ioctl.c (ioctl_decode): Use file_ioctl for decoding 'f' code ioctls.
2016-05-24 14:52:27 +00:00
306a2612a5 Add xlat/fiemap_flags.in and xlat/fiemap_extent_flags.in
* xlat/fiemap_flags.in: New file.
* xlat/fiemap_extent_flags.in: Likewise.
2016-05-24 14:52:27 +00:00
Jeff Mahoney
8cc6962216 ioctl: add decoding support for btrfs ioctls
* btrfs.c: New file.
* file_ioctl.c: Likewise.
* Makefile.am (strace_SOURCES): Add them.
* configure.ac (AC_CHECK_HEADERS): Add linux/btrfs.h.
(AC_CHECK_MEMBERS): Add struct btrfs_ioctl_feature_flags.compat_flags,
struct btrfs_ioctl_fs_info_args.nodesize,
struct btrfs_ioctl_defrag_range_args.start,
and struct btrfs_ioctl_search_args_v2.buf_size.
(AC_CHECK_DECLS): Add BTRFS_COMPRESS_* enums.
* defs.h (btrfs_ioctl, file_ioctl): New prototypes.
* ioctl.c (ioctl_decode) [HAVE_LINUX_BTRFS_H]: Use btrfs_ioctl.
* xlat/btrfs_balance_args.in: New file.
* xlat/btrfs_balance_ctl_cmds.in: Likewise.
* xlat/btrfs_balance_flags.in: Likewise.
* xlat/btrfs_balance_state.in: Likewise.
* xlat/btrfs_compress_types.in: Likewise.
* xlat/btrfs_defrag_flags.in: Likewise.
* xlat/btrfs_dev_replace_cmds.in: Likewise.
* xlat/btrfs_dev_replace_results.in: Likewise.
* xlat/btrfs_dev_replace_state.in: Likewise.
* xlat/btrfs_dev_stats_flags.in: Likewise.
* xlat/btrfs_dev_stats_values.in: Likewise.
* xlat/btrfs_features_compat.in: Likewise.
* xlat/btrfs_features_compat_ro.in: Likewise.
* xlat/btrfs_features_incompat.in: Likewise.
* xlat/btrfs_key_types.in: Likewise.
* xlat/btrfs_qgroup_ctl_cmds.in: Likewise.
* xlat/btrfs_qgroup_inherit_flags.in: Likewise.
* xlat/btrfs_qgroup_limit_flags.in: Likewise.
* xlat/btrfs_qgroup_status_flags.in: Likewise.
* xlat/btrfs_scrub_flags.in: Likewise.
* xlat/btrfs_send_flags.in: Likewise.
* xlat/btrfs_snap_flags_v2.in: Likewise.
* xlat/btrfs_space_info_flags.in: Likewise.
* xlat/btrfs_tree_objectids.in: Likewise.
2016-05-24 14:52:27 +00:00
Gleb Fotengauer-Malinovskiy
c4d4d3c3a6 x32: update ioctl entries from linux 4.6
* linux/x32/ioctls_inc0.h: Update from linux v4.6 using ioctls_gen.sh.
2016-05-24 14:50:43 +00:00
9b49af1871 tests/attach-f-p.c: sleep a bit more to let the tracer catch up
On noticeably lagging systems, the parent process may invoke its chdir
call before the tracer gets notified about completion of its last child
process.  Add extra sleep in the parent process to win the race.

* tests/attach-f-p.c (main): Change timerid into a static array.
Arm a timer in the parent process and wait for it.
2016-05-24 12:14:33 +00:00
475d2b5da6 tests/attach-p-cmd-cmd.c: fix potential errno clobbering
* tests/attach-p-cmd-cmd.c (main): Call getpid before chdir.
2016-05-23 16:39:23 +00:00
4ea65fb549 tests/net-yy-netlink.c: robustify against libc specific issues
* tests/net-yy-netlink.c (main): Use getsockname instead of recvmsg
as the latter has notible implementation differences that make
the test unreliable.
2016-05-23 10:26:46 +00:00
29df0351a9 tests/net-yy-netlink.c: robustify against os specific issues
* tests/net-yy-netlink.c (main): Pass a pointer to a real struct msghdr
as NULL doesn't work well on some systems.
2016-05-23 10:26:46 +00:00
1e9dabee66 tests/net-yy-{inet,netlink}.test: cleanup
* tests/net-yy-inet.test: Do not pass arguments to net-yy-inet
as the latter does not accept them.
* tests/net-yy-netlink.test: Do not pass arguments to net-yy-netlink
as the latter does not accept them.
2016-05-23 10:14:39 +00:00
Jeff Mahoney
f21a2f4119 tests: define PRI__[dux]64 macros to print __s64 and __u64 values
Rather than cast every __u64 or __s64 before printing,
define printing helpers for those types directly.

This complements commit 1f3482beda.

* tests/tests.h (PRI__d64, PRI__u64, PRI__x64): New macros.
2016-05-22 22:54:23 +00:00
62a35fa572 tests: remove manual creation of memory mapping holes
We used to call tail_alloc(1) to create memory mapping holes around
regular tail_alloc allocations.  This is no longer needed since regular
tail_alloc allocations create additional memory mapping holes.

* tests/clock_adjtime.c (main): Remove creation of memory mapping holes
using tail_alloc(1).
* tests/futimesat.c (main): Likewise.
* tests/get_mempolicy.c (print_nodes, main): Likewise.
* tests/getgroups.c (main): Likewise.
* tests/getresugid.c (main): Likewise.
* tests/ioctl_uffdio.c (main): Likewise.
* tests/ioctl_v4l2.c (main): Likewise.
* tests/move_pages.c (main): Likewise.
* tests/net-icmp_filter.c (main): Likewise.
* tests/ptrace.c (test_peeksiginfo, main): Likewise.
* tests/pwritev.c (main): Likewise.
* tests/set_mempolicy.c (print_nodes): Likewise.
* tests/setgroups.c (main): Likewise.
* tests/umovestr3.c (main): Likewise.
* tests/utimes.c (main): Likewise.
* tests/xattr.c (main): Likewise.
2016-05-22 22:29:33 +00:00
0f303f99c6 tests: make tail_alloc create additional memory mapping holes
* tests/tail_alloc.c (tail_alloc): Create additional memory mapping
holes before and after the allocated memory.
2016-05-22 22:21:48 +00:00
a8fce09e34 mpers: add support of conditionally compiled printers
We used to declare and define all printers marked with
MPERS_PRINTER_DECL, including ifdef'ed ones.  That approach left us
no way to conditionally compile mpersified printers, which was not
a problem until btrfs ioctls appeared on the horizon.

With this change, those mpersified printers that are not going
to be compiled are also won't be declared and won't be added to
struct_printers.

This is implemented by filtering all source files containing
MPERS_PRINTER_DECL markers through CPP.  As a nice side effect, this
also lifts an ugly requirement of writing all MPERS_PRINTER_DECL
declarations in a single line.

* README-mpers: Update description of MPERS_PRINTER_DECL syntax.
* defs.h [IN_MPERS_BOOTSTRAP] (MPERS_PRINTER_DECL): Turn into
a recursive variadic macro.
[!IN_MPERS_BOOTSTRAP] (MPERS_PRINTER_DECL): Turn into a variadic macro.
All callers changed.
* Makefile.am (mpers_preproc_files, mpers_printer_decl_pattern):
New variables.
(CLEANFILES): Add $(mpers_preproc_files).
(%.c.mpers.i): New rule.
(printers.h, %_printer_decls.h, %_printer_defs.h): Use
mpers_preproc_files instead of srcdir_mpers_source_files,
use mpers_printer_decl_pattern.
* .gitignore: Add /*.mpers.i.
2016-05-21 22:53:06 +00:00
4bf7ab7005 Remove redundant declaration of v4l2_ioctl
There is no need to declare mpers printers in defs.h because
they are already declared in printers.h or native_printer_decls.h.

This complements commit 1e56814f77.

* defs.h (v4l2_ioctl): Remove.
2016-05-20 22:47:39 +00:00
7b6979701b Fix one more code pattern that might break gcc strict aliasing rules
* socketutils.c (receive_responses): Turn static buffer into a union
to avoid breaking of gcc strict aliasing rules.
* tests/netlink_inet_diag.c (check_responses): Likewise.
* tests/netlink_netlink_diag.c (check_responses): Likewise.
* tests/netlink_unix_diag.c (check_responses): Likewise.
2016-05-21 09:33:12 +00:00
Fabien Siron
28e955d747 tests: add check for netlink protocol decoding with -yy option
* tests/netlink_netlink_diag.c: New file.
* tests/net-yy-netlink.c: New file.
* tests/net-yy-netlink.test: New test.
* tests/.gitignore: Add net-yy-netlink and netlink_netlink_diag
* tests/Makefile.am (check_PROGRAMS): Likewise.
(TESTS): Add net-yy-netlink.test.
2016-05-21 09:32:52 +00:00
Fabien Siron
814c0d575d Add netlink domain sockets support to socketutils
* linux/netlink_diag.h: New file.
* Makefile.am (EXTRA_DIST): Add it.
* socketutils.c: Include it and "xlat/netlink_protocols.h".
(netlink_send_query, netlink_parse_response, netlink_print): New
functions.
(print_sockaddr_by_inode): Hook up netlink_print.
2016-05-18 22:02:48 +00:00
ff2b853e7f tests/pread64-pwrite64.c: robustify against os specific issues
Do not assume that pwrite64 syscall fails when only part of the
specified memory buffer is accessible.  With some kernels, one
accessible byte at the end of page is enough for pwrite64 syscall
to return 1.

* tests/pread64-pwrite64.c (main): Tweak the test that can lead
to a partial write.
2016-05-18 09:26:01 +00:00
a8e820586e tests/read-write.c: robustify against os specific issues
Do not assume that write syscall fails when only part of the specified
memory buffer is accessible.  With some kernels, one accessible byte
at the end of page is enough for write syscall to return 1.

* tests/read-write.c (main): Tweak the test that can lead to a partial
write.
2016-05-18 09:26:01 +00:00