2016-05-28 13:29:30 +03:00
/*
* Copyright ( c ) 2012 Mike Frysinger < vapier @ gentoo . org >
2017-05-22 20:14:52 +03:00
* Copyright ( c ) 2012 - 2017 The strace developers .
2016-05-28 13:29:30 +03:00
*
2018-12-10 03:00:00 +03:00
* SPDX - License - Identifier : LGPL - 2.1 - or - later
2016-05-28 13:29:30 +03:00
*/
# include "defs.h"
2017-12-23 05:53:54 +03:00
# ifdef HAVE_STRUCT_UBI_ATTACH_REQ_MAX_BEB_PER1024
2016-05-28 13:29:30 +03:00
2017-12-23 05:53:54 +03:00
# include <linux / ioctl.h>
2016-05-28 13:29:30 +03:00
# include <mtd / ubi-user.h>
2017-12-23 05:53:54 +03:00
# include "xlat / ubi_volume_types.h"
# include "xlat / ubi_volume_props.h"
2016-05-28 13:29:30 +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
ubi_ioctl ( struct tcb * const tcp , const unsigned int code ,
2016-12-26 13:26:03 +03:00
const kernel_ulong_t arg )
2016-05-28 13:29:30 +03:00
{
if ( ! verbose ( tcp ) )
return RVAL_DECODED ;
switch ( code ) {
case UBI_IOCMKVOL :
if ( entering ( tcp ) ) {
struct ubi_mkvol_req mkvol ;
tprints ( " , " ) ;
if ( umove_or_printaddr ( tcp , arg , & mkvol ) )
break ;
tprintf ( " {vol_id=% " PRIi32 " , alignment=% " PRIi32
" , bytes=% " PRIi64 " , vol_type= " , mkvol . vol_id ,
mkvol . alignment , ( int64_t ) mkvol . bytes ) ;
printxval ( ubi_volume_types ,
( uint8_t ) mkvol . vol_type , " UBI_???_VOLUME " ) ;
2017-08-27 01:45:16 +03:00
tprintf ( " , name_len=% " PRIi16 " , name= " ,
mkvol . name_len ) ;
2017-07-24 15:10:54 +03:00
print_quoted_cstring ( mkvol . name ,
2017-08-27 01:45:16 +03:00
CLAMP ( mkvol . name_len , 0 ,
UBI_MAX_VOLUME_NAME ) ) ;
2016-05-28 13:29:30 +03:00
tprints ( " } " ) ;
2017-08-27 01:18:27 +03:00
return 0 ;
2016-05-28 13:29:30 +03:00
}
if ( ! syserror ( tcp ) ) {
tprints ( " => " ) ;
printnum_int ( tcp , arg , " %d " ) ;
}
break ;
case UBI_IOCRSVOL : {
struct ubi_rsvol_req rsvol ;
tprints ( " , " ) ;
if ( umove_or_printaddr ( tcp , arg , & rsvol ) )
break ;
tprintf ( " {vol_id=% " PRIi32 " , bytes=% " PRIi64 " } " ,
rsvol . vol_id , ( int64_t ) rsvol . bytes ) ;
break ;
}
case UBI_IOCRNVOL : {
struct ubi_rnvol_req rnvol ;
int c ;
tprints ( " , " ) ;
if ( umove_or_printaddr ( tcp , arg , & rnvol ) )
break ;
tprintf ( " {count=% " PRIi32 " , ents=[ " , rnvol . count ) ;
for ( c = 0 ; c < CLAMP ( rnvol . count , 0 , UBI_MAX_RNVOL ) ; + + c ) {
if ( c )
tprints ( " , " ) ;
tprintf ( " {vol_id=% " PRIi32 " , name_len=% " PRIi16
" , name= " , rnvol . ents [ c ] . vol_id ,
rnvol . ents [ c ] . name_len ) ;
2017-07-24 15:10:54 +03:00
print_quoted_cstring ( rnvol . ents [ c ] . name ,
2017-08-27 01:45:16 +03:00
CLAMP ( rnvol . ents [ c ] . name_len , 0 ,
UBI_MAX_VOLUME_NAME ) ) ;
2016-05-28 13:29:30 +03:00
tprints ( " } " ) ;
}
tprints ( " ]} " ) ;
break ;
}
case UBI_IOCEBCH : {
struct ubi_leb_change_req leb ;
tprints ( " , " ) ;
if ( umove_or_printaddr ( tcp , arg , & leb ) )
break ;
tprintf ( " {lnum=%d, bytes=%d} " , leb . lnum , leb . bytes ) ;
break ;
}
case UBI_IOCATT :
if ( entering ( tcp ) ) {
struct ubi_attach_req attach ;
tprints ( " , " ) ;
if ( umove_or_printaddr ( tcp , arg , & attach ) )
break ;
tprintf ( " {ubi_num=% " PRIi32 " , mtd_num=% " PRIi32
" , vid_hdr_offset=% " PRIi32
" , max_beb_per1024=% " PRIi16 " } " ,
attach . ubi_num , attach . mtd_num ,
attach . vid_hdr_offset , attach . max_beb_per1024 ) ;
2017-08-27 01:18:27 +03:00
return 0 ;
2016-05-28 13:29:30 +03:00
}
if ( ! syserror ( tcp ) ) {
tprints ( " => " ) ;
printnum_int ( tcp , arg , " %d " ) ;
}
break ;
case UBI_IOCEBMAP : {
struct ubi_map_req map ;
tprints ( " , " ) ;
if ( umove_or_printaddr ( tcp , arg , & map ) )
break ;
tprintf ( " {lnum=% " PRIi32 " , dtype=% " PRIi8 " } " ,
map . lnum , map . dtype ) ;
break ;
}
case UBI_IOCSETVOLPROP : {
struct ubi_set_vol_prop_req prop ;
tprints ( " , " ) ;
if ( umove_or_printaddr ( tcp , arg , & prop ) )
break ;
tprints ( " {property= " ) ;
printxval ( ubi_volume_props , prop . property , " UBI_VOL_PROP_??? " ) ;
tprintf ( " , value=%# " PRIx64 " } " , ( uint64_t ) prop . value ) ;
break ;
}
case UBI_IOCVOLUP :
tprints ( " , " ) ;
printnum_int64 ( tcp , arg , " % " PRIi64 ) ;
break ;
case UBI_IOCDET :
case UBI_IOCEBER :
case UBI_IOCEBISMAP :
case UBI_IOCEBUNMAP :
case UBI_IOCRMVOL :
tprints ( " , " ) ;
printnum_int ( tcp , arg , " %d " ) ;
break ;
2017-12-23 05:53:54 +03:00
# ifdef UBI_IOCVOLCRBLK
2016-05-28 13:29:30 +03:00
case UBI_IOCVOLCRBLK :
2017-12-23 05:53:54 +03:00
# endif
# ifdef UBI_IOCVOLRMBLK
2016-05-28 13:29:30 +03:00
case UBI_IOCVOLRMBLK :
2017-12-23 05:53:54 +03:00
# endif
2016-05-28 13:29:30 +03:00
/* no arguments */
break ;
default :
return RVAL_DECODED ;
}
2017-08-28 03:39:15 +03:00
return RVAL_IOCTL_DECODED ;
2016-05-28 13:29:30 +03:00
}
2017-12-23 05:53:54 +03:00
# endif /* HAVE_STRUCT_UBI_ATTACH_REQ_MAX_BEB_PER1024 */