summaryrefslogtreecommitdiff
path: root/src/unistd
diff options
context:
space:
mode:
authorRich Felker <dalias@aerifal.cx>2013-08-02 12:59:45 -0400
committerRich Felker <dalias@aerifal.cx>2013-08-02 12:59:45 -0400
commitc8c0844f7fbcb955848ca84432e5ffcf71f1cef1 (patch)
tree57aee97670957a956d6a387d1b33d6fd987765e9 /src/unistd
parent0dc4824479e357a3e23a02d35527e23fca920343 (diff)
downloadmusl-c8c0844f7fbcb955848ca84432e5ffcf71f1cef1.tar.gz
musl-c8c0844f7fbcb955848ca84432e5ffcf71f1cef1.tar.bz2
musl-c8c0844f7fbcb955848ca84432e5ffcf71f1cef1.tar.xz
musl-c8c0844f7fbcb955848ca84432e5ffcf71f1cef1.zip
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.
Diffstat (limited to 'src/unistd')
-rw-r--r--src/unistd/ttyname_r.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/unistd/ttyname_r.c b/src/unistd/ttyname_r.c
index 2255e2df..a2ce3511 100644
--- a/src/unistd/ttyname_r.c
+++ b/src/unistd/ttyname_r.c
@@ -3,6 +3,8 @@
#include <stdio.h>
#include <string.h>
+void __procfdname(char *, unsigned);
+
int ttyname_r(int fd, char *name, size_t size)
{
char procname[sizeof "/proc/self/fd/" + 3*sizeof(int) + 2];
@@ -10,7 +12,7 @@ int ttyname_r(int fd, char *name, size_t size)
if (!isatty(fd)) return ENOTTY;
- snprintf(procname, sizeof procname, "/proc/self/fd/%d", fd);
+ __procfdname(procname, fd);
l = readlink(procname, name, size);
if (l < 0) return errno;