diff options
author | Masatake YAMATO <yamato@redhat.com> | 2021-11-22 17:51:54 +0900 |
---|---|---|
committer | Dmitry V. Levin <ldv@strace.io> | 2023-02-20 08:00:00 +0000 |
commit | 2268bd05318f7170ecc2da60271eeb8f63d214dc (patch) | |
tree | 8b2a1fa2c4d8178815cb7f303eabd3e19d9bd43b /src/defs.h | |
parent | 765bee80024a6a33ca7724884ab0aaad8e2ddc06 (diff) | |
download | strace-2268bd05318f7170ecc2da60271eeb8f63d214dc.tar.gz |
ioctl: use finfo as hints for resolving overlapping ioctl commands
Such an overlapping can be observed, e.g. when running vi under strace:
ioctl(0, SNDCTL_TMR_START or TCSETS, {B38400 ...
After this change, when the file descriptor corresponds to a terminal
device, strace would be able to resolve the collision between ioctl
commands from different subsystems:
ioctl(0, TCSETS, {B38400 ...
* src/defs.h (term_ioctl_decode_command_number): New function
declaration.
* src/ioctl.c (ioctl_decode_command_number): Add a new argument
for passing finfo that can be used as hints for decoding ioctl commands.
Handle the code `T'.
(SYS_FUNC(ioctl)): Pass finfo as hints to ioctl_decode_command_number.
* src/term.c: Include "xlat/term_cmds_overlapping.h".
(term_ioctl_decode_command_number): Decode the command in
this earlier stage if the corresponding file descriptor corresponds
to a terminal device.
* src/xlat/term_cmds_overlapping.in: New file listing overlapping
tty ioctl commands.
* tests/ioctl_termios.c (main): Extend cmds[] in checks[].
(main::checks::cmds): Add new member "pass_invalid_fd".
Omit " or ..." substring in case of TCSETS, TCSETSW, and TCSETSF for
a valid tty descriptor.
Add test commands for invalid descriptors.
Signed-off-by: Masatake YAMATO <yamato@redhat.com>
Signed-off-by: Dmitry V. Levin <ldv@strace.io>
Diffstat (limited to 'src/defs.h')
-rw-r--r-- | src/defs.h | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/src/defs.h b/src/defs.h index 3a2bdcfae..e74948529 100644 --- a/src/defs.h +++ b/src/defs.h @@ -674,6 +674,11 @@ struct finfo { extern struct finfo * get_finfo_for_dev(const char *path, struct finfo *finfo); +extern int +term_ioctl_decode_command_number(struct tcb *tcp, + const struct finfo *finfo, + unsigned int code); + /** * @return 0 on success, -1 on error. */ |