debloat code that depends on /proc/self/fd/%d with shared function

I intend to add more Linux workarounds that depend on using these
pathnames, and some of them will be in "syscall" functions that, from
an anti-bloat standpoint, should not depend on the whole snprintf
framework.
This commit is contained in:
Rich Felker
2013-08-02 12:59:45 -04:00
parent 0dc4824479
commit c8c0844f7f
5 changed files with 26 additions and 6 deletions

View File

@ -6,6 +6,8 @@
#include <errno.h>
#include <unistd.h>
void __procfdname(char *, unsigned);
char *realpath(const char *restrict filename, char *restrict resolved)
{
int fd;
@ -21,7 +23,7 @@ char *realpath(const char *restrict filename, char *restrict resolved)
fd = open(filename, O_RDONLY|O_NONBLOCK|O_CLOEXEC);
if (fd < 0) return 0;
snprintf(buf, sizeof buf, "/proc/self/fd/%d", fd);
__procfdname(buf, fd);
if (!resolved) {
alloc = 1;