From fbedacfc8caa1ec8f14e664a881cb0a93c8f8712 Mon Sep 17 00:00:00 2001 From: Jérémie Koenig Date: Fri, 26 Mar 2010 19:08:53 +0100 Subject: Hurd compat fixes. Mostly dealing with absent PATH_MAX MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Jérémie Koenig Signed-off-by: Denys Vlasenko --- libbb/safe_gethostname.c | 6 +++++- libbb/xconnect.c | 10 ++++++++++ libbb/xreadlink.c | 6 ++---- 3 files changed, 17 insertions(+), 5 deletions(-) (limited to 'libbb') diff --git a/libbb/safe_gethostname.c b/libbb/safe_gethostname.c index 7407fb782..e93254b2b 100644 --- a/libbb/safe_gethostname.c +++ b/libbb/safe_gethostname.c @@ -59,8 +59,12 @@ char* FAST_FUNC safe_gethostname(void) */ char* FAST_FUNC safe_getdomainname(void) { +/* The field domainname of struct utsname is Linux specific. */ +#if defined(__linux__) struct utsname uts; - uname(&uts); return xstrndup(!uts.domainname[0] ? "?" : uts.domainname, sizeof(uts.domainname)); +#else + return xstrdup("?"); +#endif } diff --git a/libbb/xconnect.c b/libbb/xconnect.c index 97751eb27..d8c8d02d5 100644 --- a/libbb/xconnect.c +++ b/libbb/xconnect.c @@ -21,6 +21,8 @@ int FAST_FUNC setsockopt_broadcast(int fd) { return setsockopt(fd, SOL_SOCKET, SO_BROADCAST, &const_int_1, sizeof(const_int_1)); } + +#ifdef SO_BINDTODEVICE int FAST_FUNC setsockopt_bindtodevice(int fd, const char *iface) { int r; @@ -36,6 +38,14 @@ int FAST_FUNC setsockopt_bindtodevice(int fd, const char *iface) bb_perror_msg("can't bind to interface %s", iface); return r; } +#else +int FAST_FUNC setsockopt_bindtodevice(int fd UNUSED_PARAM, + const char *iface UNUSED_PARAM) +{ + bb_error_msg("SO_BINDTODEVICE is not supported on this system"); + return -1; +} +#endif len_and_sockaddr* FAST_FUNC get_sock_lsa(int fd) { diff --git a/libbb/xreadlink.c b/libbb/xreadlink.c index 8d232f16b..faa0e1646 100644 --- a/libbb/xreadlink.c +++ b/libbb/xreadlink.c @@ -100,18 +100,16 @@ char* FAST_FUNC xmalloc_readlink_or_warn(const char *path) return buf; } -/* UNUSED */ -#if 0 char* FAST_FUNC xmalloc_realpath(const char *path) { #if defined(__GLIBC__) && !defined(__UCLIBC__) /* glibc provides a non-standard extension */ + /* new: POSIX.1-2008 specifies this behavior as well */ return realpath(path, NULL); #else char buf[PATH_MAX+1]; - /* on error returns NULL (xstrdup(NULL) ==NULL) */ + /* on error returns NULL (xstrdup(NULL) == NULL) */ return xstrdup(realpath(path, buf)); #endif } -#endif -- cgit v1.2.3