diff options
| author | Ron Yorston <rmy@pobox.com> | 2015-05-18 09:36:27 +0100 |
|---|---|---|
| committer | Ron Yorston <rmy@pobox.com> | 2015-05-18 09:36:27 +0100 |
| commit | 60063627a6d540871061854a362047e6517f821c (patch) | |
| tree | 0de228630450c64e085f2e3f5141b5ba17eccab3 /libbb/platform.c | |
| parent | ec39cb770ddd5c0e085d5c4ee10be65bab5e7a44 (diff) | |
| parent | 9a595bb36ded308e6d4336aef2c1cd3ac738a398 (diff) | |
| download | busybox-w32-FRP.tar.gz busybox-w32-FRP.tar.bz2 busybox-w32-FRP.zip | |
Merge branch 'busybox' into mergeFRP
Diffstat (limited to '')
| -rw-r--r-- | libbb/platform.c | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/libbb/platform.c b/libbb/platform.c index 8d90ca4e9..03bbb798b 100644 --- a/libbb/platform.c +++ b/libbb/platform.c | |||
| @@ -194,3 +194,22 @@ ssize_t FAST_FUNC getline(char **lineptr, size_t *n, FILE *stream) | |||
| 194 | return len; | 194 | return len; |
| 195 | } | 195 | } |
| 196 | #endif | 196 | #endif |
| 197 | |||
| 198 | #ifndef HAVE_TTYNAME_R | ||
| 199 | int ttyname_r(int fd, char *buf, size_t buflen) | ||
| 200 | { | ||
| 201 | int r; | ||
| 202 | char path[sizeof("/proc/self/fd/%d") + sizeof(int)*3]; | ||
| 203 | |||
| 204 | if (!isatty(fd)) | ||
| 205 | return errno == EINVAL ? ENOTTY : errno; | ||
| 206 | sprintf(path, "/proc/self/fd/%d", fd); | ||
| 207 | r = readlink(path, buf, buflen); | ||
| 208 | if (r < 0) | ||
| 209 | return errno; | ||
| 210 | if (r >= buflen) | ||
| 211 | return ERANGE; | ||
| 212 | buf[r] = '\0'; | ||
| 213 | return 0; | ||
| 214 | } | ||
| 215 | #endif | ||
