avoid linking an undefined function, sysfs is linux only (#474)

This commit is contained in:
Robert Nagy 2021-12-15 13:33:09 +01:00 committed by GitHub
parent f3b9ad2086
commit 0843d0c5b2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -25,6 +25,7 @@
#define LOOPBACK_DEV "lo" #define LOOPBACK_DEV "lo"
#endif #endif
#if defined(__linux__)
static bool sysfs_devtype(char *dest, size_t n, const char *ifnam) { static bool sysfs_devtype(char *dest, size_t n, const char *ifnam) {
FILE *fp; FILE *fp;
char buf[1024]; char buf[1024];
@ -54,6 +55,7 @@ static bool sysfs_devtype(char *dest, size_t n, const char *ifnam) {
fclose(fp); fclose(fp);
return true; return true;
} }
#endif
static bool is_virtual(const char *ifname) { static bool is_virtual(const char *ifname) {
char path[1024]; char path[1024];
@ -131,7 +133,7 @@ static net_type_t iface_type(const char *ifname) {
close(s); close(s);
return NET_TYPE_ETHERNET; return NET_TYPE_ETHERNET;
} }
#else #elif defined(__linux__)
char devtype[32]; char devtype[32];
if (!sysfs_devtype(devtype, sizeof(devtype), ifname)) if (!sysfs_devtype(devtype, sizeof(devtype), ifname))