diff options
-rw-r--r-- | libsandbox/libsandbox.c | 5 | ||||
-rw-r--r-- | libsbutil/gnulib/xalloc.h | 1 | ||||
-rw-r--r-- | libsbutil/local.mk | 1 | ||||
-rw-r--r-- | libsbutil/sb_getcwd.c | 13 | ||||
-rw-r--r-- | libsbutil/sbutil.h | 1 |
5 files changed, 21 insertions, 0 deletions
diff --git a/libsandbox/libsandbox.c b/libsandbox/libsandbox.c index c4637bb..ab3d955 100644 --- a/libsandbox/libsandbox.c +++ b/libsandbox/libsandbox.c @@ -428,6 +428,11 @@ char *egetcwd(char *buf, size_t size) return tmpbuf; } +char *sb_getcwd(char *buf, size_t size) +{ + return egetcwd(buf, size); +} + void __sb_dump_backtrace(void) { const char *cmdline = sb_get_cmdline(trace_pid); diff --git a/libsbutil/gnulib/xalloc.h b/libsbutil/gnulib/xalloc.h index be20647..da7d70c 100644 --- a/libsbutil/gnulib/xalloc.h +++ b/libsbutil/gnulib/xalloc.h @@ -1,3 +1,4 @@ #include <sbutil.h> /* make canonicalize use unwrapped faccessat */ #define faccessat sbio_faccessat +#define getcwd sb_getcwd diff --git a/libsbutil/local.mk b/libsbutil/local.mk index 93e5518..1e8917c 100644 --- a/libsbutil/local.mk +++ b/libsbutil/local.mk @@ -18,6 +18,7 @@ noinst_LIBRARIES += %D%/libsbutil.a %D%/environment.c \ %D%/sb_backtrace.c \ %D%/sb_efuncs.c \ + %D%/sb_getcwd.c \ %D%/sb_gdb.c \ %D%/sb_method.c \ %D%/sb_open.c \ diff --git a/libsbutil/sb_getcwd.c b/libsbutil/sb_getcwd.c new file mode 100644 index 0000000..2ba1f39 --- /dev/null +++ b/libsbutil/sb_getcwd.c @@ -0,0 +1,13 @@ +/* + * Copyright 2025 Gentoo Authors + * Distributed under the terms of the GNU General Public License v2 + */ + +#include "headers.h" +#include "sbutil.h" + +__attribute__ ((weak)) +char *sb_getcwd(char *buf, size_t size) +{ + return getcwd(buf, size); +} diff --git a/libsbutil/sbutil.h b/libsbutil/sbutil.h index de89786..eaad087 100644 --- a/libsbutil/sbutil.h +++ b/libsbutil/sbutil.h @@ -112,6 +112,7 @@ void sb_close_all_fds(void); int sb_copy_file_to_fd(const char *file, int ofd); int sb_exists(int dirfd, const char *pathname, int flags); int sb_fstat(int fd, mode_t *mode, int64_t *size); +char *sb_getcwd(char *buf, size_t size); /* Reliable output */ __printf(1, 2) void sb_printf(const char *format, ...); |