mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-12-18 05:28:36 -07:00
linux-user: Add strace support for printing argument of syscalls used for extended attributes
This patch implements strace argument printing functionality for following syscalls:
*getxattr, lgetxattr, fgetxattr - retrieve an extended attribute value
ssize_t getxattr(const char *path, const char *name, void *value, size_t size)
ssize_t lgetxattr(const char *path, const char *name, void *value, size_t size)
ssize_t fgetxattr(int fd, const char *name, void *value, size_t size)
man page: https://www.man7.org/linux/man-pages/man2/getxattr.2.html
*listxattr, llistxattr, flistxattr - list extended attribute names
ssize_t listxattr(const char *path, char *list, size_t size)
ssize_t llistxattr(const char *path, char *list, size_t size)
ssize_t flistxattr(int fd, char *list, size_t size)
man page: https://www.man7.org/linux/man-pages/man2/listxattr.2.html
*removexattr, lremovexattr, fremovexattr - remove an extended attribute
int removexattr(const char *path, const char *name)
int lremovexattr(const char *path, const char *name)
int fremovexattr(int fd, const char *name)
man page: https://www.man7.org/linux/man-pages/man2/removexattr.2.html
Implementation notes:
All of the syscalls have strings as argument types and thus a separate
printing function was stated in file "strace.list" for every one of them.
All of these printing functions were defined in "strace.c" using existing
printing functions for appropriate argument types:
"print_string()" - for (const char*) type
"print_pointer()" - for (char*) and (void *) type
"print_raw_param()" for (int) and (size_t) type
Syscalls "getxattr()" and "lgetxattr()" have the same number and type of
arguments and thus their print functions ("print_getxattr", "print_lgetxattr")
share a same definition. The same statement applies to syscalls "listxattr()"
and "llistxattr()".
Function "print_syscall_ret_listxattr()" was added to print the returned list
of extended attributes for syscalls "print_listxattr(), print_llistxattr() and
print_flistxattr()".
Signed-off-by: Filip Bozuta <Filip.Bozuta@syrmia.com>
Reviewed-by: Laurent Vivier <laurent@vivier.eu>
Message-Id: <20200619123331.17387-4-filip.bozuta@syrmia.com>
Signed-off-by: Laurent Vivier <laurent@vivier.eu>
This commit is contained in:
parent
c42569f65c
commit
4fc3cdde40
2 changed files with 133 additions and 9 deletions
|
|
@ -826,6 +826,40 @@ print_syscall_ret_adjtimex(const struct syscallname *name, abi_long ret,
|
|||
}
|
||||
#endif
|
||||
|
||||
#if defined(TARGET_NR_listxattr) || defined(TARGET_NR_llistxattr) \
|
||||
|| defined(TARGGET_NR_flistxattr)
|
||||
static void
|
||||
print_syscall_ret_listxattr(const struct syscallname *name, abi_long ret,
|
||||
abi_long arg0, abi_long arg1, abi_long arg2,
|
||||
abi_long arg3, abi_long arg4, abi_long arg5)
|
||||
{
|
||||
print_syscall_err(ret);
|
||||
|
||||
if (ret >= 0) {
|
||||
qemu_log(TARGET_ABI_FMT_ld, ret);
|
||||
qemu_log(" (list = ");
|
||||
if (arg1 != 0) {
|
||||
abi_long attr = arg1;
|
||||
while (ret) {
|
||||
if (attr != arg1) {
|
||||
qemu_log(",");
|
||||
}
|
||||
print_string(attr, 1);
|
||||
ret -= target_strlen(attr) + 1;
|
||||
attr += target_strlen(attr) + 1;
|
||||
}
|
||||
} else {
|
||||
qemu_log("NULL");
|
||||
}
|
||||
qemu_log(")");
|
||||
}
|
||||
|
||||
qemu_log("\n");
|
||||
}
|
||||
#define print_syscall_ret_llistxattr print_syscall_ret_listxattr
|
||||
#define print_syscall_ret_flistxattr print_syscall_ret_listxattr
|
||||
#endif
|
||||
|
||||
UNUSED static struct flags access_flags[] = {
|
||||
FLAG_GENERIC(F_OK),
|
||||
FLAG_GENERIC(R_OK),
|
||||
|
|
@ -1633,6 +1667,93 @@ print_fcntl(const struct syscallname *name,
|
|||
#define print_fcntl64 print_fcntl
|
||||
#endif
|
||||
|
||||
#ifdef TARGET_NR_fgetxattr
|
||||
static void
|
||||
print_fgetxattr(const struct syscallname *name,
|
||||
abi_long arg0, abi_long arg1, abi_long arg2,
|
||||
abi_long arg3, abi_long arg4, abi_long arg5)
|
||||
{
|
||||
print_syscall_prologue(name);
|
||||
print_raw_param("%d", arg0, 0);
|
||||
print_string(arg1, 0);
|
||||
print_pointer(arg2, 0);
|
||||
print_raw_param(TARGET_FMT_lu, arg3, 1);
|
||||
print_syscall_epilogue(name);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef TARGET_NR_flistxattr
|
||||
static void
|
||||
print_flistxattr(const struct syscallname *name,
|
||||
abi_long arg0, abi_long arg1, abi_long arg2,
|
||||
abi_long arg3, abi_long arg4, abi_long arg5)
|
||||
{
|
||||
print_syscall_prologue(name);
|
||||
print_raw_param("%d", arg0, 0);
|
||||
print_pointer(arg1, 0);
|
||||
print_raw_param(TARGET_FMT_lu, arg2, 1);
|
||||
print_syscall_epilogue(name);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(TARGET_NR_getxattr) || defined(TARGET_NR_lgetxattr)
|
||||
static void
|
||||
print_getxattr(const struct syscallname *name,
|
||||
abi_long arg0, abi_long arg1, abi_long arg2,
|
||||
abi_long arg3, abi_long arg4, abi_long arg5)
|
||||
{
|
||||
print_syscall_prologue(name);
|
||||
print_string(arg0, 0);
|
||||
print_string(arg1, 0);
|
||||
print_pointer(arg2, 0);
|
||||
print_raw_param(TARGET_FMT_lu, arg3, 1);
|
||||
print_syscall_epilogue(name);
|
||||
}
|
||||
#define print_lgetxattr print_getxattr
|
||||
#endif
|
||||
|
||||
#if defined(TARGET_NR_listxattr) || defined(TARGET_NR_llistxattr)
|
||||
static void
|
||||
print_listxattr(const struct syscallname *name,
|
||||
abi_long arg0, abi_long arg1, abi_long arg2,
|
||||
abi_long arg3, abi_long arg4, abi_long arg5)
|
||||
{
|
||||
print_syscall_prologue(name);
|
||||
print_string(arg0, 0);
|
||||
print_pointer(arg1, 0);
|
||||
print_raw_param(TARGET_FMT_lu, arg2, 1);
|
||||
print_syscall_epilogue(name);
|
||||
}
|
||||
#define print_llistxattr print_listxattr
|
||||
#endif
|
||||
|
||||
#if defined(TARGET_NR_fremovexattr)
|
||||
static void
|
||||
print_fremovexattr(const struct syscallname *name,
|
||||
abi_long arg0, abi_long arg1, abi_long arg2,
|
||||
abi_long arg3, abi_long arg4, abi_long arg5)
|
||||
{
|
||||
print_syscall_prologue(name);
|
||||
print_raw_param("%d", arg0, 0);
|
||||
print_string(arg1, 1);
|
||||
print_syscall_epilogue(name);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(TARGET_NR_removexattr) || defined(TARGET_NR_lremovexattr)
|
||||
static void
|
||||
print_removexattr(const struct syscallname *name,
|
||||
abi_long arg0, abi_long arg1, abi_long arg2,
|
||||
abi_long arg3, abi_long arg4, abi_long arg5)
|
||||
{
|
||||
print_syscall_prologue(name);
|
||||
print_string(arg0, 0);
|
||||
print_string(arg1, 1);
|
||||
print_syscall_epilogue(name);
|
||||
}
|
||||
#define print_lremovexattr print_removexattr
|
||||
#endif
|
||||
|
||||
#ifdef TARGET_NR_futimesat
|
||||
static void
|
||||
print_futimesat(const struct syscallname *name,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue