[PATCH v2 4/6] Use finfo structure to arbitrate overwrapped IOCTL command assignments between TTY and SND
Dmitry V. Levin
ldv at altlinux.org
Sat Mar 12 15:44:00 UTC 2022
On Sat, Mar 12, 2022 at 03:02:07AM +0900, Masatake YAMATO wrote:
[...]
> +extern int
> +term_ioctl_decode_command_number(int code,
> + struct tcb *tcp, struct finfo *finfo)
> +{
> + /* See Documentation/admin-guide/devices.txt of
> + * Linux kernel source tree about the number 3, 4, 5, 136 ~ 143.
> + */
> + if (finfo
> + && finfo->type == finfo_dev_chr
> + && ((136 <= finfo->dev.major && finfo->dev.major <= 143)
> + || (3 <= finfo->dev.major && finfo->dev.major <= 5))) {
> + switch (code) {
> + case TCSETSF:
> + tprints("TCSETSF");
> + return IOCTL_NUMBER_STOP_LOOKUP;
> + case TCSETSW:
> + tprints("TCSETSW");
> + return IOCTL_NUMBER_STOP_LOOKUP;
> + case TCSETS:
> + tprints("TCSETS");
> + return IOCTL_NUMBER_STOP_LOOKUP;
> + case TCSETA:
> + tprints("TCSETA");
> + return IOCTL_NUMBER_STOP_LOOKUP;
> + case TCSETAW:
> + tprints("TCSETAW");
> + return IOCTL_NUMBER_STOP_LOOKUP;
> + case TCSETAF:
> + tprints("TCSETAF");
> + return IOCTL_NUMBER_STOP_LOOKUP;
> + }
> + }
> + return 0;
> +}
Looks like this introduces regression in strace -X support.
For example, before this change we had
$ strace -Xverbose -eioctl stty sane
ioctl(0, 0x5401 /* TCGETS */, {0xf /* B38400 */ opost isig icanon echo ...}) = 0
ioctl(0, 0x5403 /* SNDCTL_TMR_STOP or TCSETSW */, {0xf /* B38400 */ opost isig icanon echo ...}) = 0
ioctl(0, 0x5401 /* TCGETS */, {0xf /* B38400 */ opost isig icanon echo ...}) = 0
Also, the switch statement itself looks like an open-coding of printxval.
--
ldv
More information about the Strace-devel
mailing list