Skip to content

Commit 5844f4b

Browse files
bozutafvivier
authored andcommitted
linux-user: Add strace support for printing arguments of chown()/lchown()
This patch implements strace argument printing functionality for syscalls: *chown, lchown - change ownership of a file int chown(const char *pathname, uid_t owner, gid_t group) int lchown(const char *pathname, uid_t owner, gid_t group) man page: https://www.man7.org/linux/man-pages/man2/lchown.2.html Implementation notes: Both syscalls use strings as arguments and thus a separate printing function was stated in "strace.list" for them. Both syscalls share the same number and types of arguments and thus share a same definition in file "syscall.c". This defintion uses existing functions "print_string()" to print the string argument and "print_raw_param()" to print other two arguments that are of basic types. Signed-off-by: Filip Bozuta <[email protected]> Reviewed-by: Laurent Vivier <[email protected]> Message-Id: <[email protected]> Signed-off-by: Laurent Vivier <[email protected]>
1 parent af861de commit 5844f4b

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

linux-user/strace.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1452,6 +1452,21 @@ print_chmod(const struct syscallname *name,
14521452
}
14531453
#endif
14541454

1455+
#if defined(TARGET_NR_chown) || defined(TARGET_NR_lchown)
1456+
static void
1457+
print_chown(const struct syscallname *name,
1458+
abi_long arg0, abi_long arg1, abi_long arg2,
1459+
abi_long arg3, abi_long arg4, abi_long arg5)
1460+
{
1461+
print_syscall_prologue(name);
1462+
print_string(arg0, 0);
1463+
print_raw_param("%d", arg1, 0);
1464+
print_raw_param("%d", arg2, 1);
1465+
print_syscall_epilogue(name);
1466+
}
1467+
#define print_lchown print_chown
1468+
#endif
1469+
14551470
#ifdef TARGET_NR_clock_adjtime
14561471
static void
14571472
print_clock_adjtime(const struct syscallname *name,

linux-user/strace.list

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@
7171
{ TARGET_NR_chmod, "chmod" , NULL, print_chmod, NULL },
7272
#endif
7373
#ifdef TARGET_NR_chown
74-
{ TARGET_NR_chown, "chown" , NULL, NULL, NULL },
74+
{ TARGET_NR_chown, "chown" , NULL, print_chown, NULL },
7575
#endif
7676
#ifdef TARGET_NR_chown32
7777
{ TARGET_NR_chown32, "chown32" , NULL, NULL, NULL },
@@ -475,7 +475,7 @@
475475
{ TARGET_NR_kill, "kill", NULL, print_kill, NULL },
476476
#endif
477477
#ifdef TARGET_NR_lchown
478-
{ TARGET_NR_lchown, "lchown" , NULL, NULL, NULL },
478+
{ TARGET_NR_lchown, "lchown" , NULL, print_lchown, NULL },
479479
#endif
480480
#ifdef TARGET_NR_lchown32
481481
{ TARGET_NR_lchown32, "lchown32" , NULL, NULL, NULL },

0 commit comments

Comments
 (0)