Dmitry V. Levin | 46245b3 | 2014-12-06 03:53:16 +0000 | [diff] [blame] | 1 | #include "defs.h" |
| 2 | |
| 3 | static int |
| 4 | decode_readlink(struct tcb *tcp, int offset) |
| 5 | { |
| 6 | if (entering(tcp)) { |
| 7 | printpath(tcp, tcp->u_arg[offset]); |
| 8 | tprints(", "); |
| 9 | } else { |
| 10 | if (syserror(tcp)) |
Dmitry V. Levin | 8e0a18f | 2015-07-17 17:24:41 +0000 | [diff] [blame] | 11 | printaddr(tcp->u_arg[offset + 1]); |
Dmitry V. Levin | 46245b3 | 2014-12-06 03:53:16 +0000 | [diff] [blame] | 12 | else |
| 13 | /* Used to use printpathn(), but readlink |
| 14 | * neither includes NUL in the returned count, |
| 15 | * nor actually writes it into memory. |
| 16 | * printpathn() would decide on printing |
| 17 | * "..." continuation based on garbage |
| 18 | * past return buffer's end. |
| 19 | */ |
| 20 | printstr(tcp, tcp->u_arg[offset + 1], tcp->u_rval); |
| 21 | tprintf(", %lu", tcp->u_arg[offset + 2]); |
| 22 | } |
| 23 | return 0; |
| 24 | } |
| 25 | |
Dmitry V. Levin | a0bd374 | 2015-04-07 01:36:50 +0000 | [diff] [blame] | 26 | SYS_FUNC(readlink) |
Dmitry V. Levin | 46245b3 | 2014-12-06 03:53:16 +0000 | [diff] [blame] | 27 | { |
| 28 | return decode_readlink(tcp, 0); |
| 29 | } |
| 30 | |
Dmitry V. Levin | a0bd374 | 2015-04-07 01:36:50 +0000 | [diff] [blame] | 31 | SYS_FUNC(readlinkat) |
Dmitry V. Levin | 46245b3 | 2014-12-06 03:53:16 +0000 | [diff] [blame] | 32 | { |
| 33 | if (entering(tcp)) |
| 34 | print_dirfd(tcp, tcp->u_arg[0]); |
| 35 | return decode_readlink(tcp, 1); |
| 36 | } |