aboutsummaryrefslogtreecommitdiff
path: root/toys/other/pwdx.c
diff options
context:
space:
mode:
Diffstat (limited to 'toys/other/pwdx.c')
-rw-r--r--toys/other/pwdx.c14
1 files changed, 4 insertions, 10 deletions
diff --git a/toys/other/pwdx.c b/toys/other/pwdx.c
index bde16e79..2a72dba3 100644
--- a/toys/other/pwdx.c
+++ b/toys/other/pwdx.c
@@ -20,20 +20,14 @@ void pwdx_main(void)
char **optargs;
for (optargs = toys.optargs; *optargs; optargs++) {
- char *path;
- int num_bytes;
+ char *path = toybuf;
- path = xmprintf("/proc/%s/cwd", *optargs);
- num_bytes = readlink(path, toybuf, sizeof(toybuf)-1);
- free(path);
-
- if (num_bytes==-1) {
+ sprintf(toybuf, "/proc/%d/cwd", atoi(*optargs));
+ if (!readlink0(path, toybuf, sizeof(toybuf))) {
path = strerror(errno);
toys.exitval = 1;
- } else {
- path = toybuf;
- toybuf[num_bytes] = 0;
}
+
xprintf("%s: %s\n", *optargs, path);
}
}