2015-12-17 20:56:48 +03:00
/*
* Copyright ( c ) 2014 Stefan Sørensen < stefan . sorensen @ spectralink . com >
* Copyright ( c ) 2014 - 2015 Dmitry V . Levin < ldv @ altlinux . org >
2018-04-05 04:40:00 +03:00
* Copyright ( c ) 2014 - 2018 The strace developers .
2015-12-17 20:56:48 +03:00
* All rights reserved .
*
2018-12-10 03:00:00 +03:00
* SPDX - License - Identifier : LGPL - 2.1 - or - later
2015-12-17 20:56:48 +03:00
*/
2014-01-31 15:01:01 +04:00
# include "defs.h"
2017-12-23 05:37:33 +03:00
# ifdef HAVE_STRUCT_PTP_SYS_OFFSET
# include <linux / ioctl.h>
# include <linux / ptp_clock.h>
2018-03-10 09:21:59 +03:00
# include "print_fields.h"
2017-12-23 05:37:33 +03:00
# include "xlat / ptp_flags_options.h"
2014-01-31 15:01:01 +04:00
ioctl: assume that all ioctl commands have unsigned int type
In linux, ioctl command number has a 32-bit unsigned integer type:
fs/ioctl.c:SYSCALL_DEFINE3(ioctl, unsigned int, fd, unsigned int, cmd, unsigned long, arg)
If the kernel completely ignores other bits on 64-bit architectures,
why should strace care?
Let's follow the kernel and treat it as unsigned int.
* defs.h (struct_ioctlent): Change "code" type to "unsigned int".
(ioctl_decode, ioctl_lookup, block_ioctl, loop_ioctl, mtd_ioctl,
ubi_ioctl, ptp_ioctl, scsi_ioctl, sock_ioctl, term_ioctl, rtc_ioctl,
v4l2_ioctl): Likewise.
* ioctl.c (ioctl_decode, ioctl_lookup, compare, ioctl_next_match):
Likewise.
* block.c (block_ioctl): Likewise.
* loop.c (loop_ioctl): Likewise.
* mtd.c (mtd_ioctl, ubi_ioctl): Likewise.
* ptp.c (ptp_ioctl): Likewise.
* scsi.c (scsi_ioctl): Likewise.
* sock.c (sock_ioctl): Likewise.
* term.c (term_ioctl): Likewise.
* time.c (rtc_ioctl): Likewise.
* v4l2.c (v4l2_ioctl): Likewise.
* ioctlsort.c (struct ioctlent, compare, main): Likewise.
2015-01-19 21:44:21 +03:00
int
Change type of ioctl 3rd argument from long to kernel_ureg_t
* defs.h (DECL_IOCTL): Change arg type from long to kernel_ureg_t.
* dm.c (dm_known_ioctl, dm_ioctl): Likewise.
* file_ioctl.c (file_ioctl): Likewise.
* fs_x_ioctl.c (fs_x_ioctl): Likewise.
* ioctl.c (ioctl_decode): Likewise.
* loop.c (decode_loop_info, decode_loop_info64): Change addr type
from long to kernel_ureg_t.
(loop_ioctl): Change arg type from long to kernel_ureg_t.
* ptp.c (ptp_ioctl): Likewise.
* scsi.c (print_sg_io_v3_req, print_sg_io_v3_res, print_sg_io_v4_req,
print_sg_io_v4_res, scsi_ioctl): Likewise.
* sock.c (print_ifreq, sock_ioctl): Likewise.
(decode_ifconf): Change addr type from long to kernel_ureg_t.
* term.c (decode_termios, decode_termio, decode_winsize, decode_ttysize,
decode_modem_flags): Likewise.
(term_ioctl): Change arg type from long to kernel_ureg_t.
* ubi.c (ubi_ioctl): Likewise.
* userfaultfd.c (uffdio_ioctl): Likewise.
2016-12-21 06:03:09 +03:00
ptp_ioctl ( struct tcb * const tcp , const unsigned int code ,
2016-12-26 13:26:03 +03:00
const kernel_ulong_t arg )
2014-01-31 15:01:01 +04:00
{
if ( ! verbose ( tcp ) )
2015-07-07 12:47:18 +03:00
return RVAL_DECODED ;
2014-01-31 15:01:01 +04:00
switch ( code ) {
2015-07-07 12:47:18 +03:00
case PTP_EXTTS_REQUEST : {
struct ptp_extts_request extts ;
2014-01-31 15:01:01 +04:00
2015-07-07 12:47:18 +03:00
tprints ( " , " ) ;
if ( umove_or_printaddr ( tcp , arg , & extts ) )
break ;
2014-01-31 15:01:01 +04:00
2018-03-10 09:21:59 +03:00
PRINT_FIELD_D ( " { " , extts , index ) ;
PRINT_FIELD_FLAGS ( " , " , extts , flags , ptp_flags_options , " PTP_??? " ) ;
2015-07-07 12:47:18 +03:00
tprints ( " } " ) ;
break ;
}
2014-01-31 15:01:01 +04:00
2015-07-07 12:47:18 +03:00
case PTP_PEROUT_REQUEST : {
struct ptp_perout_request perout ;
2014-01-31 15:01:01 +04:00
2015-07-07 12:47:18 +03:00
tprints ( " , " ) ;
if ( umove_or_printaddr ( tcp , arg , & perout ) )
break ;
2014-01-31 15:01:01 +04:00
2018-03-10 09:21:59 +03:00
PRINT_FIELD_D ( " {start={ " , perout . start , sec ) ;
PRINT_FIELD_U ( " , " , perout . start , nsec ) ;
PRINT_FIELD_D ( " }, period={ " , perout . period , sec ) ;
PRINT_FIELD_U ( " , " , perout . period , nsec ) ;
PRINT_FIELD_D ( " }, " , perout , index ) ;
PRINT_FIELD_FLAGS ( " , " , perout , flags , ptp_flags_options , " PTP_??? " ) ;
2015-07-07 12:47:18 +03:00
tprints ( " } " ) ;
break ;
}
2014-01-31 15:01:01 +04:00
2015-07-07 12:47:18 +03:00
case PTP_ENABLE_PPS :
2016-12-26 13:16:35 +03:00
tprintf ( " , % " PRI_kld , arg ) ;
2015-07-07 12:47:18 +03:00
break ;
2014-01-31 15:01:01 +04:00
2015-07-07 12:47:18 +03:00
case PTP_SYS_OFFSET : {
struct ptp_sys_offset sysoff ;
if ( entering ( tcp ) ) {
tprints ( " , " ) ;
if ( umove_or_printaddr ( tcp , arg , & sysoff ) )
break ;
2014-01-31 15:01:01 +04:00
2018-03-10 09:21:59 +03:00
PRINT_FIELD_U ( " { " , sysoff , n_samples ) ;
2017-08-27 01:18:27 +03:00
return 0 ;
2015-07-07 12:47:18 +03:00
} else {
unsigned int n_samples , i ;
2014-01-31 15:01:01 +04:00
2015-07-07 12:47:18 +03:00
if ( syserror ( tcp ) ) {
tprints ( " } " ) ;
break ;
}
2014-01-31 15:01:01 +04:00
2015-07-07 12:47:18 +03:00
tprints ( " , " ) ;
if ( umove ( tcp , arg , & sysoff ) < 0 ) {
tprints ( " ???} " ) ;
break ;
}
2014-01-31 15:01:01 +04:00
2015-07-07 12:47:18 +03:00
tprints ( " ts=[ " ) ;
n_samples = sysoff . n_samples > PTP_MAX_SAMPLES ?
PTP_MAX_SAMPLES : sysoff . n_samples ;
for ( i = 0 ; i < 2 * n_samples + 1 ; + + i ) {
if ( i > 0 )
tprints ( " , " ) ;
2018-03-10 09:21:59 +03:00
PRINT_FIELD_D ( " { " , sysoff . ts [ i ] , sec ) ;
PRINT_FIELD_U ( " , " , sysoff . ts [ i ] , nsec ) ;
tprints ( " } " ) ;
2014-01-31 15:01:01 +04:00
}
if ( sysoff . n_samples > PTP_MAX_SAMPLES )
2015-07-07 12:47:18 +03:00
tprints ( " , ... " ) ;
tprints ( " ]} " ) ;
break ;
2014-01-31 15:01:01 +04:00
}
2015-07-07 12:47:18 +03:00
}
case PTP_CLOCK_GETCAPS : {
struct ptp_clock_caps caps ;
2014-01-31 15:01:01 +04:00
2015-07-07 12:47:18 +03:00
if ( entering ( tcp ) )
2014-01-31 15:01:01 +04:00
return 0 ;
2015-07-07 12:47:18 +03:00
tprints ( " , " ) ;
if ( umove_or_printaddr ( tcp , arg , & caps ) )
break ;
2018-03-10 09:21:59 +03:00
PRINT_FIELD_D ( " { " , caps , max_adj ) ;
PRINT_FIELD_D ( " , " , caps , n_alarm ) ;
PRINT_FIELD_D ( " , " , caps , n_ext_ts ) ;
PRINT_FIELD_D ( " , " , caps , n_per_out ) ;
PRINT_FIELD_D ( " , " , caps , pps ) ;
tprints ( " } " ) ;
2015-07-07 12:47:18 +03:00
break ;
2014-01-31 15:01:01 +04:00
}
2015-07-07 12:47:18 +03:00
default :
return RVAL_DECODED ;
}
2017-08-28 03:39:15 +03:00
return RVAL_IOCTL_DECODED ;
2014-01-31 15:01:01 +04:00
}
2017-12-23 05:37:33 +03:00
# endif /* HAVE_STRUCT_PTP_SYS_OFFSET */