aruu

[MIRROR] Actual replacement for Busybox | suckless
git clone https://git.daat.foo/aruu.git
Log | Files | Refs | README | LICENSE

commit 646b508a48c255976a470baa815e1e4859d066a3
parent 96d88deeda5b81084098c4731ba1e29dca0e53ba
Author: xplshn <anto@xplshn.com.ar>
Date:   Tue, 24 Nov 2026 14:39:21 -0300

cc: own path from proc_selfexe

Diffstat:
Mcmd/dev/cc/driver.c | 3++-
Mcmd/dev/cc/pp.c | 3++-
Mshared/libutil/proc_linux.c | 6++++++
Mshared/libutil/proc_other.c | 9+++++++++
Mshared/proc.h | 3+++
5 files changed, 22 insertions(+), 2 deletions(-)

diff --git a/cmd/dev/cc/driver.c b/cmd/dev/cc/driver.c @@ -17,6 +17,7 @@ #include "util.h" #include "paths.h" +#include "proc.h" enum filetype { NONE, /* detect based on file extension */ @@ -357,7 +358,7 @@ resolvepath(const char *arg0, const char *binname, const char *devrelpath) size_t n; struct stat st; - n = readlink("/proc/self/exe", self, sizeof(self) - 1); + n = proc_selfexe(self, sizeof(self) - 1); if (n == -1) { n = strlen(arg0); if (n > sizeof(self) - 1) diff --git a/cmd/dev/cc/pp.c b/cmd/dev/cc/pp.c @@ -7,6 +7,7 @@ #include <unistd.h> #include "util.h" #include "cc.h" +#include "proc.h" struct macroparam { char *name; @@ -135,7 +136,7 @@ include(void) if (!f) { static const char *const rel[] = {"include", "../lib/aruu/include"}; char self[FILENAME_MAX]; - ssize_t n = readlink("/proc/self/exe", self, sizeof(self) - 1); + ssize_t n = proc_selfexe(self, sizeof(self) - 1); if (n == -1) { n = strlen(argv0); if (n > (ssize_t)sizeof(self) - 1) diff --git a/shared/libutil/proc_linux.c b/shared/libutil/proc_linux.c @@ -264,4 +264,10 @@ proc_ttyname(unsigned major, unsigned minor, char *buf, size_t n) snprintf(buf, n, "?"); } +ssize_t +proc_selfexe(char *buf, size_t n) +{ + return readlink(ARUU_LINUX_PATH_PROC "/self/exe", buf, n); +} + #endif diff --git a/shared/libutil/proc_other.c b/shared/libutil/proc_other.c @@ -90,4 +90,13 @@ proc_ttyname(unsigned major, unsigned minor, char *buf, size_t n) strlcpy(buf, "?", n); } +ssize_t +proc_selfexe(char *buf, size_t n) +{ + (void)buf; + (void)n; + errno = ENOTSUP; + return -1; +} + #endif diff --git a/shared/proc.h b/shared/proc.h @@ -83,5 +83,8 @@ int proc_args(pid_t pid, char *buf, size_t n); int proc_cwd(pid_t pid, char *buf, size_t n); /* the terminal's name as ps shows it: pts/3, tty1 or ? for none */ void proc_ttyname(unsigned major, unsigned minor, char *buf, size_t n); +/* the path of the running program's own file, readlink style: not + * terminated, -1 where the kernel does not tell */ +ssize_t proc_selfexe(char *buf, size_t n); #endif