2012-04-18 06:19:31 +04:00
/*
* Copyright ( c ) 2012 The Chromium OS Authors .
* Written by Mike Frysinger < vapier @ gentoo . org > .
*
* Redistribution and use in source and binary forms , with or without
* modification , are permitted provided that the following conditions
* are met :
* 1. Redistributions of source code must retain the above copyright
* notice , this list of conditions and the following disclaimer .
* 2. Redistributions in binary form must reproduce the above copyright
* notice , this list of conditions and the following disclaimer in the
* documentation and / or other materials provided with the distribution .
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission .
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ` ` AS IS ' ' AND ANY EXPRESS OR
* IMPLIED WARRANTIES , INCLUDING , BUT NOT LIMITED TO , THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED .
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT , INDIRECT ,
* INCIDENTAL , SPECIAL , EXEMPLARY , OR CONSEQUENTIAL DAMAGES ( INCLUDING , BUT
* NOT LIMITED TO , PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES ; LOSS OF USE ,
* DATA , OR PROFITS ; OR BUSINESS INTERRUPTION ) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY , WHETHER IN CONTRACT , STRICT LIABILITY , OR TORT
* ( INCLUDING NEGLIGENCE OR OTHERWISE ) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE , EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE .
*/
# include "defs.h"
2015-07-04 17:40:02 +03:00
# include <linux/ioctl.h>
2012-04-18 06:19:31 +04:00
# include <linux/loop.h>
2014-04-26 03:30:54 +04:00
# include "xlat/loop_flags_options.h"
# include "xlat/loop_crypt_type_options.h"
2012-04-18 06:19:31 +04:00
2015-07-04 17:40:02 +03:00
static void
2016-12-26 13:26:03 +03:00
decode_loop_info ( struct tcb * const tcp , const kernel_ulong_t addr )
2012-04-18 06:19:31 +04:00
{
struct loop_info info ;
2015-07-04 17:40:02 +03:00
tprints ( " , " ) ;
if ( umove_or_printaddr ( tcp , addr , & info ) )
return ;
2012-04-18 06:19:31 +04:00
2016-05-30 01:28:28 +03:00
tprintf ( " {lo_number=%d " , info . lo_number ) ;
2012-04-18 06:19:31 +04:00
2015-07-04 17:40:02 +03:00
if ( ! abbrev ( tcp ) ) {
2016-12-26 19:36:37 +03:00
tprints ( " , lo_device= " ) ;
print_dev_t ( info . lo_device ) ;
tprintf ( " , lo_inode=%lu " , info . lo_inode ) ;
tprints ( " , lo_rdevice= " ) ;
print_dev_t ( info . lo_rdevice ) ;
2015-07-04 17:40:02 +03:00
}
2012-04-18 06:19:31 +04:00
2016-05-30 01:28:28 +03:00
tprintf ( " , lo_offset=%#x " , info . lo_offset ) ;
2012-04-18 06:19:31 +04:00
2015-07-04 17:40:02 +03:00
if ( ! abbrev ( tcp ) | | info . lo_encrypt_type ! = LO_CRYPT_NONE ) {
2016-05-30 01:28:28 +03:00
tprints ( " , lo_encrypt_type= " ) ;
2015-07-04 17:40:02 +03:00
printxval ( loop_crypt_type_options , info . lo_encrypt_type ,
" LO_CRYPT_??? " ) ;
2016-05-30 01:28:28 +03:00
tprintf ( " , lo_encrypt_key_size=%d " , info . lo_encrypt_key_size ) ;
2015-07-04 17:40:02 +03:00
}
2012-04-18 06:19:31 +04:00
2016-05-30 01:28:28 +03:00
tprints ( " , lo_flags= " ) ;
2015-07-04 17:40:02 +03:00
printflags ( loop_flags_options , info . lo_flags , " LO_FLAGS_??? " ) ;
2012-04-18 06:19:31 +04:00
2016-05-30 01:28:28 +03:00
tprints ( " , lo_name= " ) ;
2015-07-04 17:40:02 +03:00
print_quoted_string ( info . lo_name , LO_NAME_SIZE ,
QUOTE_0_TERMINATED ) ;
2012-04-18 06:19:31 +04:00
2015-07-04 17:40:02 +03:00
if ( ! abbrev ( tcp ) | | info . lo_encrypt_type ! = LO_CRYPT_NONE ) {
2016-05-30 01:28:28 +03:00
tprints ( " , lo_encrypt_key= " ) ;
2015-07-04 17:40:02 +03:00
print_quoted_string ( ( void * ) info . lo_encrypt_key ,
LO_KEY_SIZE , 0 ) ;
}
2012-04-18 06:19:31 +04:00
2015-07-04 17:40:02 +03:00
if ( ! abbrev ( tcp ) )
2016-05-30 01:34:30 +03:00
tprintf ( " , lo_init=[%#lx, %#lx] "
" , reserved=[%#x, %#x, %#x, %#x]} " ,
2015-07-04 17:40:02 +03:00
info . lo_init [ 0 ] , info . lo_init [ 1 ] ,
info . reserved [ 0 ] , info . reserved [ 1 ] ,
info . reserved [ 2 ] , info . reserved [ 3 ] ) ;
else
tprints ( " , ...} " ) ;
}
2012-04-18 06:19:31 +04:00
2015-07-04 17:40:02 +03:00
static void
2016-12-26 13:26:03 +03:00
decode_loop_info64 ( struct tcb * const tcp , const kernel_ulong_t addr )
2015-07-04 17:40:02 +03:00
{
struct loop_info64 info64 ;
2012-04-18 06:19:31 +04:00
2015-07-04 17:40:02 +03:00
tprints ( " , " ) ;
if ( umove_or_printaddr ( tcp , addr , & info64 ) )
return ;
if ( ! abbrev ( tcp ) ) {
2016-12-26 19:36:37 +03:00
tprints ( " {lo_device= " ) ;
print_dev_t ( info64 . lo_device ) ;
tprintf ( " , lo_inode=% " PRIu64 , ( uint64_t ) info64 . lo_inode ) ;
tprints ( " , lo_rdevice= " ) ;
print_dev_t ( info64 . lo_rdevice ) ;
tprintf ( " , lo_offset=%# " PRIx64 " , lo_sizelimit=% " PRIu64
" , lo_number=% " PRIu32 ,
2015-07-04 17:40:02 +03:00
( uint64_t ) info64 . lo_offset ,
( uint64_t ) info64 . lo_sizelimit ,
( uint32_t ) info64 . lo_number ) ;
} else {
2016-05-30 01:28:28 +03:00
tprintf ( " {lo_offset=%# " PRIx64 " , lo_number=% " PRIu32 ,
2015-07-04 17:40:02 +03:00
( uint64_t ) info64 . lo_offset ,
( uint32_t ) info64 . lo_number ) ;
}
2012-04-18 06:19:31 +04:00
2015-07-04 17:40:02 +03:00
if ( ! abbrev ( tcp ) | | info64 . lo_encrypt_type ! = LO_CRYPT_NONE ) {
2016-05-30 01:28:28 +03:00
tprints ( " , lo_encrypt_type= " ) ;
2015-07-04 17:40:02 +03:00
printxval ( loop_crypt_type_options , info64 . lo_encrypt_type ,
" LO_CRYPT_??? " ) ;
2016-05-30 01:28:28 +03:00
tprintf ( " , lo_encrypt_key_size=% " PRIu32 ,
2015-07-04 17:40:02 +03:00
info64 . lo_encrypt_key_size ) ;
}
2012-04-18 06:19:31 +04:00
2016-05-30 01:28:28 +03:00
tprints ( " , lo_flags= " ) ;
2015-07-04 17:40:02 +03:00
printflags ( loop_flags_options , info64 . lo_flags , " LO_FLAGS_??? " ) ;
2016-05-30 01:28:28 +03:00
tprints ( " , lo_file_name= " ) ;
2015-07-04 17:40:02 +03:00
print_quoted_string ( ( void * ) info64 . lo_file_name ,
LO_NAME_SIZE , QUOTE_0_TERMINATED ) ;
2012-04-18 06:19:31 +04:00
2015-07-04 17:40:02 +03:00
if ( ! abbrev ( tcp ) | | info64 . lo_encrypt_type ! = LO_CRYPT_NONE ) {
2016-05-30 01:28:28 +03:00
tprints ( " , lo_crypt_name= " ) ;
2015-07-04 17:40:02 +03:00
print_quoted_string ( ( void * ) info64 . lo_crypt_name ,
2015-01-26 04:17:08 +03:00
LO_NAME_SIZE , QUOTE_0_TERMINATED ) ;
2016-05-30 01:28:28 +03:00
tprints ( " , lo_encrypt_key= " ) ;
2015-07-04 17:40:02 +03:00
print_quoted_string ( ( void * ) info64 . lo_encrypt_key ,
LO_KEY_SIZE , 0 ) ;
}
2012-04-18 06:19:31 +04:00
2015-07-04 17:40:02 +03:00
if ( ! abbrev ( tcp ) )
2016-05-30 01:34:30 +03:00
tprintf ( " , lo_init=[%# " PRIx64 " , %# " PRIx64 " ]} " ,
2015-07-04 17:40:02 +03:00
( uint64_t ) info64 . lo_init [ 0 ] ,
( uint64_t ) info64 . lo_init [ 1 ] ) ;
else
tprints ( " , ...} " ) ;
}
2012-04-18 06:19:31 +04:00
2015-07-04 17:40:02 +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
loop_ioctl ( struct tcb * const tcp , const unsigned int code ,
2016-12-26 13:26:03 +03:00
const kernel_ulong_t arg )
2015-07-04 17:40:02 +03:00
{
if ( ! verbose ( tcp ) )
return RVAL_DECODED ;
2012-04-18 06:19:31 +04:00
2015-07-04 17:40:02 +03:00
switch ( code ) {
case LOOP_GET_STATUS :
if ( entering ( tcp ) )
return 0 ;
2016-05-30 01:15:53 +03:00
/* fall through */
case LOOP_SET_STATUS :
2015-07-04 17:40:02 +03:00
decode_loop_info ( tcp , arg ) ;
break ;
case LOOP_GET_STATUS64 :
if ( entering ( tcp ) )
return 0 ;
2016-05-30 01:15:53 +03:00
/* fall through */
case LOOP_SET_STATUS64 :
2015-07-04 17:40:02 +03:00
decode_loop_info64 ( tcp , arg ) ;
break ;
2012-04-18 06:19:31 +04:00
case LOOP_CLR_FD :
2012-05-02 14:21:49 +04:00
# ifdef LOOP_SET_CAPACITY
2012-04-18 06:19:31 +04:00
case LOOP_SET_CAPACITY :
2012-05-02 14:21:49 +04:00
# endif
2012-04-18 06:19:31 +04:00
# ifdef LOOP_CTL_GET_FREE
/* newer loop-control stuff */
case LOOP_CTL_GET_FREE :
# endif
/* Takes no arguments */
2015-07-04 17:40:02 +03:00
break ;
2012-04-18 06:19:31 +04:00
case LOOP_SET_FD :
case LOOP_CHANGE_FD :
2015-07-04 17:40:02 +03:00
tprints ( " , " ) ;
printfd ( tcp , arg ) ;
break ;
2012-04-18 06:19:31 +04:00
# ifdef LOOP_CTL_ADD
/* newer loop-control stuff */
case LOOP_CTL_ADD :
case LOOP_CTL_REMOVE :
2015-07-04 17:40:02 +03:00
tprintf ( " , %d " , ( int ) arg ) ;
break ;
2012-04-18 06:19:31 +04:00
# endif
2016-05-30 01:58:56 +03:00
# ifdef LOOP_SET_DIRECT_IO
case LOOP_SET_DIRECT_IO :
2016-12-26 13:16:35 +03:00
tprintf ( " , % " PRI_klu , arg ) ;
2016-05-30 01:58:56 +03:00
break ;
# endif
2012-04-18 06:19:31 +04:00
default :
2015-07-04 17:40:02 +03:00
return RVAL_DECODED ;
2012-04-18 06:19:31 +04:00
}
2015-07-04 17:40:02 +03:00
return RVAL_DECODED | 1 ;
2012-04-18 06:19:31 +04:00
}