2015-12-17 20:56:48 +03:00
/*
* Copyright ( c ) 2002 - 2005 Roland McGrath < roland @ redhat . com >
* Copyright ( c ) 2004 Ulrich Drepper < drepper @ redhat . com >
2018-12-25 02:46:43 +03:00
* Copyright ( c ) 2005 - 2018 Dmitry V . Levin < ldv @ altlinux . org >
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-12-06 06:53:16 +03:00
# include "defs.h"
2015-06-17 22:54:21 +03:00
# ifdef HAVE_SYS_XATTR_H
# include <sys / xattr.h>
2014-12-06 06:53:16 +03:00
# endif
# include "xlat/xattrflags.h"
2016-05-10 21:52:06 +03:00
# ifndef XATTR_SIZE_MAX
# define XATTR_SIZE_MAX 65536
# endif
2014-12-06 06:53:16 +03:00
static void
2016-12-22 23:54:10 +03:00
print_xattr_val ( struct tcb * const tcp ,
2016-12-26 13:26:03 +03:00
const kernel_ulong_t addr ,
const kernel_ulong_t insize ,
const kernel_ulong_t size )
2014-12-06 06:53:16 +03:00
{
2015-07-15 02:34:06 +03:00
tprints ( " , " ) ;
2016-12-22 18:10:51 +03:00
if ( size > XATTR_SIZE_MAX )
2015-07-15 02:34:06 +03:00
printaddr ( addr ) ;
2016-12-22 18:10:51 +03:00
else
printstr_ex ( tcp , addr , size , QUOTE_OMIT_TRAILING_0 ) ;
2016-12-26 13:16:35 +03:00
tprintf ( " , % " PRI_klu , insize ) ;
2014-12-06 06:53:16 +03:00
}
2015-04-07 04:36:50 +03:00
SYS_FUNC ( setxattr )
2014-12-06 06:53:16 +03:00
{
2015-07-15 02:38:58 +03:00
printpath ( tcp , tcp - > u_arg [ 0 ] ) ;
tprints ( " , " ) ;
2016-12-20 19:43:26 +03:00
printstr ( tcp , tcp - > u_arg [ 1 ] ) ;
2015-07-15 02:38:58 +03:00
print_xattr_val ( tcp , tcp - > u_arg [ 2 ] , tcp - > u_arg [ 3 ] , tcp - > u_arg [ 3 ] ) ;
tprints ( " , " ) ;
printflags ( xattrflags , tcp - > u_arg [ 4 ] , " XATTR_??? " ) ;
return RVAL_DECODED ;
2014-12-06 06:53:16 +03:00
}
2015-04-07 04:36:50 +03:00
SYS_FUNC ( fsetxattr )
2014-12-06 06:53:16 +03:00
{
2015-07-15 02:38:58 +03:00
printfd ( tcp , tcp - > u_arg [ 0 ] ) ;
tprints ( " , " ) ;
2016-12-20 19:43:26 +03:00
printstr ( tcp , tcp - > u_arg [ 1 ] ) ;
2015-07-15 02:38:58 +03:00
print_xattr_val ( tcp , tcp - > u_arg [ 2 ] , tcp - > u_arg [ 3 ] , tcp - > u_arg [ 3 ] ) ;
tprints ( " , " ) ;
printflags ( xattrflags , tcp - > u_arg [ 4 ] , " XATTR_??? " ) ;
return RVAL_DECODED ;
2014-12-06 06:53:16 +03:00
}
2015-04-07 04:36:50 +03:00
SYS_FUNC ( getxattr )
2014-12-06 06:53:16 +03:00
{
if ( entering ( tcp ) ) {
printpath ( tcp , tcp - > u_arg [ 0 ] ) ;
tprints ( " , " ) ;
2016-12-20 19:43:26 +03:00
printstr ( tcp , tcp - > u_arg [ 1 ] ) ;
2014-12-06 06:53:16 +03:00
} else {
2015-07-15 02:25:15 +03:00
print_xattr_val ( tcp , tcp - > u_arg [ 2 ] , tcp - > u_arg [ 3 ] , tcp - > u_rval ) ;
2014-12-06 06:53:16 +03:00
}
return 0 ;
}
2015-04-07 04:36:50 +03:00
SYS_FUNC ( fgetxattr )
2014-12-06 06:53:16 +03:00
{
if ( entering ( tcp ) ) {
printfd ( tcp , tcp - > u_arg [ 0 ] ) ;
tprints ( " , " ) ;
2016-12-20 19:43:26 +03:00
printstr ( tcp , tcp - > u_arg [ 1 ] ) ;
2014-12-06 06:53:16 +03:00
} else {
2015-07-15 02:25:15 +03:00
print_xattr_val ( tcp , tcp - > u_arg [ 2 ] , tcp - > u_arg [ 3 ] , tcp - > u_rval ) ;
2014-12-06 06:53:16 +03:00
}
return 0 ;
}
static void
2016-12-26 13:26:03 +03:00
print_xattr_list ( struct tcb * const tcp , const kernel_ulong_t addr ,
const kernel_ulong_t size )
2014-12-06 06:53:16 +03:00
{
2016-05-10 21:52:06 +03:00
if ( ! size | | syserror ( tcp ) ) {
2015-07-15 02:31:35 +03:00
printaddr ( addr ) ;
2014-12-06 06:53:16 +03:00
} else {
2016-12-20 19:43:26 +03:00
printstrn ( tcp , addr , tcp - > u_rval ) ;
2014-12-06 06:53:16 +03:00
}
2016-12-26 13:16:35 +03:00
tprintf ( " , % " PRI_klu , size ) ;
2014-12-06 06:53:16 +03:00
}
2015-04-07 04:36:50 +03:00
SYS_FUNC ( listxattr )
2014-12-06 06:53:16 +03:00
{
if ( entering ( tcp ) ) {
printpath ( tcp , tcp - > u_arg [ 0 ] ) ;
tprints ( " , " ) ;
} else {
print_xattr_list ( tcp , tcp - > u_arg [ 1 ] , tcp - > u_arg [ 2 ] ) ;
}
return 0 ;
}
2015-04-07 04:36:50 +03:00
SYS_FUNC ( flistxattr )
2014-12-06 06:53:16 +03:00
{
if ( entering ( tcp ) ) {
printfd ( tcp , tcp - > u_arg [ 0 ] ) ;
tprints ( " , " ) ;
} else {
print_xattr_list ( tcp , tcp - > u_arg [ 1 ] , tcp - > u_arg [ 2 ] ) ;
}
return 0 ;
}
2015-04-07 04:36:50 +03:00
SYS_FUNC ( removexattr )
2014-12-06 06:53:16 +03:00
{
2015-07-15 02:38:58 +03:00
printpath ( tcp , tcp - > u_arg [ 0 ] ) ;
tprints ( " , " ) ;
2016-12-20 19:43:26 +03:00
printstr ( tcp , tcp - > u_arg [ 1 ] ) ;
2015-07-15 02:38:58 +03:00
return RVAL_DECODED ;
2014-12-06 06:53:16 +03:00
}
2015-04-07 04:36:50 +03:00
SYS_FUNC ( fremovexattr )
2014-12-06 06:53:16 +03:00
{
2015-07-15 02:38:58 +03:00
printfd ( tcp , tcp - > u_arg [ 0 ] ) ;
tprints ( " , " ) ;
2016-12-20 19:43:26 +03:00
printstr ( tcp , tcp - > u_arg [ 1 ] ) ;
2015-07-15 02:38:58 +03:00
return RVAL_DECODED ;
2014-12-06 06:53:16 +03:00
}