Port Native libraries to SunOS (#34867)
authorAdeel Mujahid <adeelbm@outlook.com>
Tue, 14 Apr 2020 01:20:44 +0000 (04:20 +0300)
committerGitHub <noreply@github.com>
Tue, 14 Apr 2020 01:20:44 +0000 (18:20 -0700)
15 files changed:
src/libraries/Common/src/Interop/Unix/System.Native/Interop.MountPoints.FormatInfo.cs
src/libraries/Common/src/Interop/Unix/System.Native/Interop.SysLog.cs
src/libraries/Native/Unix/CMakeLists.txt
src/libraries/Native/Unix/Common/pal_config.h.in
src/libraries/Native/Unix/System.IO.Ports.Native/pal_termios.c
src/libraries/Native/Unix/System.Native/CMakeLists.txt
src/libraries/Native/Unix/System.Native/pal_interfaceaddresses.c
src/libraries/Native/Unix/System.Native/pal_maphardwaretype.c
src/libraries/Native/Unix/System.Native/pal_mount.c
src/libraries/Native/Unix/System.Native/pal_networking.c
src/libraries/Native/Unix/System.Native/pal_process.c
src/libraries/Native/Unix/System.Native/pal_process.h
src/libraries/Native/Unix/System.Native/pal_uid.c
src/libraries/Native/Unix/configure.cmake
src/libraries/System.Private.CoreLib/src/System/Diagnostics/DebugProvider.Unix.cs

index ee5e427..e02afa5 100644 (file)
@@ -44,6 +44,7 @@ internal static partial class Interop
             bdevfs = 0x62646576,
             bfs = 0x1BADFACE,
             binfmt_misc = 0x42494E4D,
+            bootfs = 0xA56D3FF9,
             btrfs = 0x9123683E,
             ceph = 0x00C36400,
             cgroupfs = 0x0027E0EB,
@@ -65,6 +66,7 @@ internal static partial class Interop
             ext3 = 0xEF53,
             ext4 = 0xEF53,
             fat = 0x4006,
+            fd = 0xF00D1E,
             fhgfs = 0x19830326,
             fuse = 0x65735546,
             fuseblk = 0x65735546,
@@ -86,6 +88,7 @@ internal static partial class Interop
             jffs2 = 0x72B6,
             jfs = 0x3153464A,
             kafs = 0x6B414653,
+            lofs = 0xEF53, /* loopback filesystem, magic same as ext2 */
             logfs = 0xC97E8168,
             lustre = 0x0BD00BD0,
             minix_old = 0x137F, /* orig. minix */
@@ -227,6 +230,7 @@ internal static partial class Interop
                 case "bdevfs":
                 case "befs":
                 case "bfs":
+                case "bootfs":
                 case "bpf_fs":
                 case "btrfs":
                 case "btrfs_test":
@@ -261,6 +265,7 @@ internal static partial class Interop
                 case "jffs":
                 case "jffs2":
                 case "jfs":
+                case "lofs":
                 case "logfs":
                 case "lxfs":
                 case "minix (30 char.)":
@@ -384,15 +389,18 @@ internal static partial class Interop
                 case "cgroupfs":
                 case "cgroup2fs":
                 case "configfs":
+                case "cpuset":
                 case "cramfs":
                 case "cramfs-wend":
                 case "cryptkeeper":
-                case "cpuset":
+                case "ctfs":
                 case "debugfs":
+                case "dev":
                 case "devfs":
                 case "devpts":
                 case "devtmpfs":
                 case "encfs":
+                case "fd":
                 case "fdesc":
                 case "fuse.gvfsd-fuse":
                 case "fusectl":
@@ -400,9 +408,11 @@ internal static partial class Interop
                 case "hugetlbfs":
                 case "libpam-encfs":
                 case "ibpam-mount":
+                case "mntfs":
+                case "mqueue":
                 case "mtpfs":
                 case "mythtvfs":
-                case "mqueue":
+                case "objfs":
                 case "openprom":
                 case "openpromfs":
                 case "pipefs":
@@ -417,6 +427,7 @@ internal static partial class Interop
                 case "securityfs":
                 case "selinux":
                 case "selinuxfs":
+                case "sharefs":
                 case "sockfs":
                 case "sysfs":
                 case "tmpfs":
index 2edde6f..8933e9c 100644 (file)
@@ -19,28 +19,6 @@ internal static partial class Interop
             LOG_NOTICE      = 5,        /* normal but significant condition */
             LOG_INFO        = 6,        /* informational */
             LOG_DEBUG       = 7,        /* debug-level messages */
-            // Facilities
-            LOG_KERN        = (0<<3),   /* kernel messages */
-            LOG_USER        = (1<<3),   /* random user-level messages */
-            LOG_MAIL        = (2<<3),   /* mail system */
-            LOG_DAEMON      = (3<<3),   /* system daemons */
-            LOG_AUTH        = (4<<3),   /* authorization messages */
-            LOG_SYSLOG      = (5<<3),   /* messages generated internally by syslogd */
-            LOG_LPR         = (6<<3),   /* line printer subsystem */
-            LOG_NEWS        = (7<<3),   /* network news subsystem */
-            LOG_UUCP        = (8<<3),   /* UUCP subsystem */
-            LOG_CRON        = (9<<3),   /* clock daemon */
-            LOG_AUTHPRIV    = (10<<3),  /* authorization messages (private) */
-            LOG_FTP         = (11<<3),  /* ftp daemon */
-            // Between FTP and Local is reserved for system use
-            LOG_LOCAL0      = (16<<3),  /* reserved for local use */
-            LOG_LOCAL1      = (17<<3),  /* reserved for local use */
-            LOG_LOCAL2      = (18<<3),  /* reserved for local use */
-            LOG_LOCAL3      = (19<<3),  /* reserved for local use */
-            LOG_LOCAL4      = (20<<3),  /* reserved for local use */
-            LOG_LOCAL5      = (21<<3),  /* reserved for local use */
-            LOG_LOCAL6      = (22<<3),  /* reserved for local use */
-            LOG_LOCAL7      = (23<<3),  /* reserved for local use */
         }
 
         /// <summary>
index 76742dd..f14ada6 100644 (file)
@@ -170,7 +170,13 @@ if(CLR_CMAKE_TARGET_UNIX)
             add_link_options(-Wl,-bind_at_load)
         else()
             add_compile_options($<$<COMPILE_LANGUAGE:ASM>:-Wa,--noexecstack>)
-            add_link_options(-Wl,--build-id=sha1 -Wl,-z,relro,-z,now)
+            if(CLR_CMAKE_TARGET_SUNOS)
+                add_definitions(-D__EXTENSIONS__ -D_XPG4_2 -D_POSIX_PTHREAD_SEMANTICS)
+            else()
+                # -z,now is required for full relro.
+                # see https://www.redhat.com/en/blog/hardening-elf-binaries-using-relocation-read-only-relro
+                add_link_options(-Wl,--build-id=sha1 -Wl,-z,relro,-z,now)
+            endif()
         endif()
     endif()
 
index c74c4c9..46c3dc7 100644 (file)
@@ -26,6 +26,7 @@
 #cmakedefine01 HAVE_MNTINFO
 #cmakedefine01 HAVE_STATFS_FSTYPENAME
 #cmakedefine01 HAVE_STATVFS_FSTYPENAME
+#cmakedefine01 HAVE_NON_LEGACY_STATFS
 #cmakedefine01 HAVE_STRCPY_S
 #cmakedefine01 HAVE_STRLCPY
 #cmakedefine01 HAVE_SHM_OPEN_THAT_WORKS_WELL_ENOUGH_WITH_MMAP
 #cmakedefine01 HAVE_RT_MSGHDR2
 #cmakedefine01 HAVE_IF_MSGHDR2
 #cmakedefine01 HAVE_SYS_SYSCTL_H
+#cmakedefine01 HAVE_SYS_IOCTL_H
+#cmakedefine01 HAVE_SYS_FILIO_H
+#cmakedefine01 HAVE_NETPACKET_PACKET_H
+#cmakedefine01 HAVE_NET_IF_ARP_H
+#cmakedefine01 HAVE_SYS_MNTENT_H
 #cmakedefine01 HAVE_NET_IFMEDIA_H
 #cmakedefine01 HAVE_LINUX_RTNETLINK_H
 #cmakedefine01 HAVE_LINUX_CAN_H
 #cmakedefine01 HAVE_TCP_H_TCP_KEEPALIVE
 #cmakedefine01 HAVE_BUILTIN_MUL_OVERFLOW
 #cmakedefine01 HAVE_DISCONNECTX
+#cmakedefine01 HAVE_CFSETSPEED
+#cmakedefine01 HAVE_CFMAKERAW
+#cmakedefine01 HAVE_GETGROUPLIST
 
 // Mac OS X has stat64, but it is deprecated since plain stat now
 // provides the same 64-bit aware struct when targeting OS X > 10.5
index ece77cb..0943826 100644 (file)
@@ -9,6 +9,9 @@
 #include <unistd.h>
 #include <errno.h>
 #include <pal_termios.h>
+#if HAVE_SYS_FILIO_H
+#include <sys/filio.h>
+#endif
 
 /* This is dup of System/IO/Ports/NativeMethods.cs */
 enum
@@ -359,7 +362,12 @@ int32_t SystemIoPortsNative_TermiosSetSpeed(intptr_t handle, int32_t speed)
         return  -1;
     }
 
+#if HAVE_CFSETSPEED
     cfsetspeed(&term, brate);
+#else // on SunOS, set input and output speeds individually
+    cfsetispeed(&term, brate);
+    cfsetospeed(&term, brate);
+#endif
 
     if (tcsetattr(fd, TCSANOW, &term) < 0)
     {
@@ -418,7 +426,15 @@ int32_t SystemIoPortsNative_TermiosReset(intptr_t handle, int32_t speed, int32_t
         return  -1;
     }
 
+#if HAVE_CFMAKERAW
     cfmakeraw(&term);
+#else
+    term.c_iflag &= ~(IMAXBEL|IGNBRK|BRKINT|PARMRK|ISTRIP|INLCR|IGNCR|ICRNL|IXON);
+    term.c_oflag &= ~OPOST;
+    term.c_lflag &= ~(ECHO|ECHONL|ICANON|ISIG|IEXTEN);
+    term.c_cflag &= ~(CSIZE|PARENB);
+    term.c_cflag |= CS8;
+#endif
     term.c_cflag |=  (CLOCAL | CREAD);
     term.c_lflag &= ~((tcflag_t)(ICANON | ECHO | ECHOE | ECHOK | ECHONL | ISIG | IEXTEN ));
     term.c_oflag &= ~((tcflag_t)(OPOST));
@@ -495,7 +511,11 @@ int32_t SystemIoPortsNative_TermiosReset(intptr_t handle, int32_t speed, int32_t
             return -1;
         }
 
+#if HAVE_CFSETSPEED
         ret = cfsetspeed(&term, brate);
+#else
+        ret = cfsetispeed(&term, brate) & cfsetospeed(&term, brate);
+#endif
     }
 
     if ((ret != 0) || (tcsetattr(fd, TCSANOW, &term) < 0))
index 2c3da0d..e3bf253 100644 (file)
@@ -56,10 +56,10 @@ if (GEN_SHARED_LIB)
 
     if (CLR_CMAKE_TARGET_FREEBSD)
         target_link_libraries(System.Native pthread)
-    if (HAVE_INOTIFY)
-        find_library(INOTIFY_LIBRARY inotify HINTS /usr/local/lib)
-        target_link_libraries(System.Native ${INOTIFY_LIBRARY})
-    endif ()
+        if (HAVE_INOTIFY)
+            find_library(INOTIFY_LIBRARY inotify HINTS /usr/local/lib)
+            target_link_libraries(System.Native ${INOTIFY_LIBRARY})
+        endif ()
     endif ()
     install_with_stripped_symbols (System.Native PROGRAMS .)
 endif ()
index a182578..7c64c54 100644 (file)
@@ -20,6 +20,9 @@
 #if HAVE_SYS_SYSCTL_H
 #include <sys/sysctl.h>
 #endif
+#if HAVE_SYS_IOCTL_H
+#include <sys/ioctl.h>
+#endif
 #if HAVE_ETHTOOL_H
 #include <linux/ethtool.h>
 #include <linux/sockios.h>
 
 #if defined(AF_PACKET)
 #include <sys/ioctl.h>
-#if defined(_WASM_)
+#if HAVE_NETPACKET_PACKET_H
 #include <netpacket/packet.h>
-#else // _WASM_
+#else
 #include <linux/if_packet.h>
-#endif // _WASM_
+#endif
 #elif defined(AF_LINK)
 #include <net/if_dl.h>
 #include <net/if_types.h>
@@ -431,7 +434,7 @@ int32_t SystemNative_GetNetworkInterfaces(int32_t * interfaceCount, NetworkInter
 #endif
 }
 
-#if HAVE_RT_MSGHDR
+#if HAVE_RT_MSGHDR && defined(CTL_NET)
 int32_t SystemNative_EnumerateGatewayAddressesForInterface(uint32_t interfaceIndex, GatewayAddressFound onGatewayFound)
 {
     static struct in6_addr anyaddr = IN6ADDR_ANY_INIT;
index dbd74cc..1289307 100644 (file)
@@ -9,13 +9,16 @@
 #include <sys/types.h>
 
 #if defined(AF_PACKET)
-#if defined(_WASM_)
+#if HAVE_NETPACKET_PACKET_H
 #include <netpacket/packet.h>
-#include <net/if_arp.h>
-#else // _WASM_
+#else
 #include <linux/if_packet.h>
+#endif
+#if HAVE_NET_IF_ARP_H
+#include <net/if_arp.h>
+#else
 #include <linux/if_arp.h>
-#endif // _WASM_
+#endif
 #elif defined(AF_LINK)
 #include <net/if_dl.h>
 #include <net/if_types.h>
@@ -43,7 +46,9 @@ uint16_t MapHardwareType(uint16_t nativeType)
         case ARPHRD_PPP:
             return NetworkInterfaceType_Ppp;
         case ARPHRD_TUNNEL:
+#ifdef ARPHRD_TUNNEL6
         case ARPHRD_TUNNEL6:
+#endif
             return NetworkInterfaceType_Tunnel;
         case ARPHRD_LOOPBACK:
             return NetworkInterfaceType_Loopback;
index 7fe0aee..ce4daa7 100644 (file)
 #include <sys/mount.h>
 #else
 #include <sys/statfs.h>
+#if HAVE_SYS_MNTENT_H
+#include <sys/mntent.h>
+#include <sys/mnttab.h>
+#include <sys/statvfs.h>
+#else
 #include <mntent.h>
+#endif
 #define STRING_BUFFER_SIZE 8192
 
 // Android does not define MNTOPT_RO
@@ -42,8 +48,28 @@ static int32_t GetMountInfo(MountPointFound onFound)
     return 0;
 }
 
-#else
+#elif HAVE_SYS_MNTENT_H
+    int result = -1;
+    FILE* fp = fopen("/proc/mounts", MNTOPT_RO);
+    if (fp != NULL)
+    {
+        char buffer[STRING_BUFFER_SIZE] = {0};
+        struct mnttab entry;
+        while(getmntent(fp, &entry) == 0)
+        {
+            onFound(entry.mnt_mountp);
+        }
 
+        result = fclose(fp);
+        assert(result == 1); // documented to always return 1
+        result =
+            0; // We need to standardize a success return code between our implementations, so settle on 0 for success
+    }
+
+    return result;
+}
+
+#else
     int result = -1;
     FILE* fp = setmntent("/proc/mounts", MNTOPT_RO);
     if (fp != NULL)
@@ -78,7 +104,7 @@ int32_t SystemNative_GetSpaceInfoForMountPoint(const char* name, MountPointInfor
     assert(name != NULL);
     assert(mpi != NULL);
 
-#if defined(HAVE_STATFS)
+#if HAVE_NON_LEGACY_STATFS
     struct statfs stats;
     memset(&stats, 0, sizeof(struct statfs));
 
@@ -117,7 +143,7 @@ SystemNative_GetFormatInfoForMountPoint(const char* name, char* formatNameBuffer
     assert((formatNameBuffer != NULL) && (formatType != NULL));
     assert(bufferLength > 0);
 
-#if defined(HAVE_STATFS)
+#if HAVE_NON_LEGACY_STATFS
     struct statfs stats;
     int result = statfs(name, &stats);
 #else
@@ -142,12 +168,12 @@ SystemNative_GetFormatInfoForMountPoint(const char* name, char* formatNameBuffer
             SafeStringCopy(formatNameBuffer, Int32ToSizeT(bufferLength), stats.f_fstypename);
             *formatType = -1;
         }
-#elif defined(HAVE_STATFS)
+#elif HAVE_NON_LEGACY_STATFS
         assert(formatType != NULL);
         *formatType = (int64_t)(stats.f_type);
         SafeStringCopy(formatNameBuffer, Int32ToSizeT(bufferLength), "");
 #else
-               *formatType = 0;
+        *formatType = 0;
 #endif
     }
     else
index 08540e2..0506694 100644 (file)
 #if HAVE_LINUX_CAN_H
 #include <linux/can.h>
 #endif
+#if HAVE_SYS_FILIO_H
+#include <sys/filio.h>
+#endif
+
 #if HAVE_KQUEUE
 #if KEVENT_HAS_VOID_UDATA
 static void* GetKeventUdata(uintptr_t udata)
@@ -2310,7 +2314,7 @@ static bool TryConvertProtocolTypePlatformToPal(int32_t palAddressFamily, int pl
                     return true;
 
                 default:
-                    *palProtocolType = (int)palProtocolType;
+                    *palProtocolType = (int32_t)(intptr_t)palProtocolType;
                     return false;
             }
 
index 93d4188..2a50285 100644 (file)
@@ -42,26 +42,6 @@ c_static_assert(PAL_LOG_WARNING == LOG_WARNING);
 c_static_assert(PAL_LOG_NOTICE == LOG_NOTICE);
 c_static_assert(PAL_LOG_INFO == LOG_INFO);
 c_static_assert(PAL_LOG_DEBUG == LOG_DEBUG);
-c_static_assert(PAL_LOG_KERN == LOG_KERN);
-c_static_assert(PAL_LOG_USER == LOG_USER);
-c_static_assert(PAL_LOG_MAIL == LOG_MAIL);
-c_static_assert(PAL_LOG_DAEMON == LOG_DAEMON);
-c_static_assert(PAL_LOG_AUTH == LOG_AUTH);
-c_static_assert(PAL_LOG_SYSLOG == LOG_SYSLOG);
-c_static_assert(PAL_LOG_LPR == LOG_LPR);
-c_static_assert(PAL_LOG_NEWS == LOG_NEWS);
-c_static_assert(PAL_LOG_UUCP == LOG_UUCP);
-c_static_assert(PAL_LOG_CRON == LOG_CRON);
-c_static_assert(PAL_LOG_AUTHPRIV == LOG_AUTHPRIV);
-c_static_assert(PAL_LOG_FTP == LOG_FTP);
-c_static_assert(PAL_LOG_LOCAL0 == LOG_LOCAL0);
-c_static_assert(PAL_LOG_LOCAL1 == LOG_LOCAL1);
-c_static_assert(PAL_LOG_LOCAL2 == LOG_LOCAL2);
-c_static_assert(PAL_LOG_LOCAL3 == LOG_LOCAL3);
-c_static_assert(PAL_LOG_LOCAL4 == LOG_LOCAL4);
-c_static_assert(PAL_LOG_LOCAL5 == LOG_LOCAL5);
-c_static_assert(PAL_LOG_LOCAL6 == LOG_LOCAL6);
-c_static_assert(PAL_LOG_LOCAL7 == LOG_LOCAL7);
 
 // Validate that out PriorityWhich values are correct for the platform
 c_static_assert(PAL_PRIO_PROCESS == (int)PRIO_PROCESS);
@@ -546,12 +526,21 @@ static int32_t ConvertRLimitResourcesPalToPlatform(RLimitResources value)
             return RLIMIT_CORE;
         case PAL_RLIMIT_AS:
             return RLIMIT_AS;
+#ifdef RLIMIT_RSS
         case PAL_RLIMIT_RSS:
             return RLIMIT_RSS;
+#endif
+#ifdef RLIMIT_MEMLOCK
         case PAL_RLIMIT_MEMLOCK:
             return RLIMIT_MEMLOCK;
+#elif defined(RLIMIT_VMEM)
+        case PAL_RLIMIT_MEMLOCK:
+            return RLIMIT_VMEM;
+#endif
+#ifdef RLIMIT_NPROC
         case PAL_RLIMIT_NPROC:
             return RLIMIT_NPROC;
+#endif
         case PAL_RLIMIT_NOFILE:
             return RLIMIT_NOFILE;
     }
@@ -656,7 +645,7 @@ int32_t SystemNative_GetSid(int32_t pid)
 
 void SystemNative_SysLog(SysLogPriority priority, const char* message, const char* arg1)
 {
-    syslog((int)priority, message, arg1);
+    syslog((int)(LOG_USER | priority), message, arg1);
 }
 
 int32_t SystemNative_WaitIdAnyExitedNoHangNoWait()
index d75f25b..7ad8007 100644 (file)
@@ -95,28 +95,6 @@ typedef enum
     PAL_LOG_NOTICE = 5,  /* normal but significant condition */
     PAL_LOG_INFO = 6,    /* informational */
     PAL_LOG_DEBUG = 7,   /* debug-level messages */
-    // Facilities
-    PAL_LOG_KERN = (0 << 3),      /* kernel messages */
-    PAL_LOG_USER = (1 << 3),      /* random user-level messages */
-    PAL_LOG_MAIL = (2 << 3),      /* mail system */
-    PAL_LOG_DAEMON = (3 << 3),    /* system daemons */
-    PAL_LOG_AUTH = (4 << 3),      /* authorization messages */
-    PAL_LOG_SYSLOG = (5 << 3),    /* messages generated internally by syslogd */
-    PAL_LOG_LPR = (6 << 3),       /* line printer subsystem */
-    PAL_LOG_NEWS = (7 << 3),      /* network news subsystem */
-    PAL_LOG_UUCP = (8 << 3),      /* UUCP subsystem */
-    PAL_LOG_CRON = (9 << 3),      /* clock daemon */
-    PAL_LOG_AUTHPRIV = (10 << 3), /* authorization messages (private) */
-    PAL_LOG_FTP = (11 << 3),      /* ftp daemon */
-    // Between FTP and Local is reserved for system use
-    PAL_LOG_LOCAL0 = (16 << 3), /* reserved for local use */
-    PAL_LOG_LOCAL1 = (17 << 3), /* reserved for local use */
-    PAL_LOG_LOCAL2 = (18 << 3), /* reserved for local use */
-    PAL_LOG_LOCAL3 = (19 << 3), /* reserved for local use */
-    PAL_LOG_LOCAL4 = (20 << 3), /* reserved for local use */
-    PAL_LOG_LOCAL5 = (21 << 3), /* reserved for local use */
-    PAL_LOG_LOCAL6 = (22 << 3), /* reserved for local use */
-    PAL_LOG_LOCAL7 = (23 << 3), /* reserved for local use */
 } SysLogPriority;
 
 /**
index 166465b..41053d3 100644 (file)
@@ -112,6 +112,73 @@ uint32_t SystemNative_GetUid()
 static pthread_mutex_t s_groupLock = PTHREAD_MUTEX_INITIALIZER;
 #endif
 
+#if !HAVE_GETGROUPLIST
+int getgrouplist(const char *uname, gid_t agroup, gid_t *groups, int *groupCount)
+{
+    int ngroups = 1;
+    int maxgroups = *groupCount;
+
+    if (groups)
+    {
+        groups[ngroups] = agroup;
+    }
+    if (maxgroups > 1)
+    {
+        if (groups)
+            groups[ngroups++] = agroup;
+        else
+            ngroups++;
+    }
+
+    setgrent();
+
+    int i;
+    int result = 0;
+    const struct group *group;
+
+    while ((group = getgrent()) != NULL)
+    {
+        if (groups)
+        {
+            bool found = false;
+            for (i = 0; i < ngroups; i++)
+            {
+                if (group->gr_gid == groups[i])
+                {
+                    found = true;
+                    break;
+                }
+            }
+            if (found)
+                break;
+        }
+
+        for (i = 0; group->gr_mem[i]; i++)
+        {
+            if (!strcmp(group->gr_mem[i], uname))
+            {
+                if (ngroups >= maxgroups)
+                {
+                    result = -1;
+                    break;
+                }
+
+                if (groups)
+                    groups[ngroups++] = group->gr_gid;
+                else
+                    ngroups++;
+
+                break;
+            }
+        }
+    }
+
+    endgrent();
+    *groupCount = ngroups;
+    return result;
+}
+#endif
+
 int32_t SystemNative_GetGroupList(const char* name, uint32_t group, uint32_t* groups, int32_t* ngroups)
 {
     assert(name != NULL);
index c043ced..8faaf1f 100644 (file)
@@ -7,7 +7,6 @@ include(CheckStructHasMember)
 include(CheckSymbolExists)
 include(CheckTypeSize)
 
-
 if (CLR_CMAKE_TARGET_ANDROID)
     set(PAL_UNIX_NAME \"ANDROID\")
 elseif (CLR_CMAKE_TARGET_ARCH_WASM)
@@ -36,7 +35,7 @@ elseif (CLR_CMAKE_TARGET_SUNOS)
     set(CMAKE_LIBRARY_PATH ${CMAKE_LIBRARY_PATH} /opt/local/lib)
     include_directories(SYSTEM /opt/local/include)
 else ()
-    message(FATAL_ERROR "Unknown platform.  Cannot define PAL_UNIX_NAME, used by RuntimeInformation.")
+    message(FATAL_ERROR "Unknown platform. Cannot define PAL_UNIX_NAME, used by RuntimeInformation.")
 endif ()
 
 # We compile with -Werror, so we need to make sure these code fragments compile without warnings.
@@ -232,6 +231,16 @@ check_symbol_exists(
     "termios.h"
     HAVE_TCSANOW)
 
+check_symbol_exists(
+    cfsetspeed
+    termios.h
+    HAVE_CFSETSPEED)
+
+check_symbol_exists(
+    cfmakeraw
+    termios.h
+    HAVE_CFMAKERAW)
+
 check_struct_has_member(
     "struct utsname"
     domainname
@@ -303,8 +312,7 @@ set(CMAKE_EXTRA_INCLUDE_FILES ${STATFS_INCLUDES})
 check_symbol_exists(
     "statfs"
     ${STATFS_INCLUDES}
-    HAVE_STATFS
-)
+    HAVE_STATFS)
 
 check_type_size(
     "struct statfs"
@@ -578,8 +586,7 @@ check_c_source_compiles(
         return 0;
     }
     "
-    BIND_ADDRLEN_UNSIGNED
-)
+    BIND_ADDRLEN_UNSIGNED)
 
 check_c_source_compiles(
     "
@@ -594,8 +601,7 @@ check_c_source_compiles(
         return 0;
     }
     "
-    IPV6MR_INTERFACE_UNSIGNED
-)
+    IPV6MR_INTERFACE_UNSIGNED)
 
 check_include_files(
     "sys/inotify.h"
@@ -630,6 +636,13 @@ check_prototype_definition(
     "sys/types.h;sys/event.h"
     KEVENT_REQUIRES_INT_PARAMS)
 
+check_prototype_definition(
+    statfs
+    "int statfs(const char *path, struct statfs *buf)"
+    0
+    ${STATFS_INCLUDES}
+    HAVE_NON_LEGACY_STATFS)
+
 check_c_source_compiles(
     "
     #include <stdlib.h>
@@ -671,8 +684,7 @@ check_c_source_compiles(
     #include <netinet/tcp_var.h>
     int main(void) { return 0; }
     "
-    HAVE_NETINET_TCP_VAR_H
-)
+    HAVE_NETINET_TCP_VAR_H)
 
 check_c_source_compiles(
     "
@@ -686,8 +698,7 @@ check_c_source_compiles(
     #include <netinet/udp_var.h>
     int main(void) { return 0; }
     "
-    HAVE_NETINET_UDP_VAR_H
-)
+    HAVE_NETINET_UDP_VAR_H)
 
 check_c_source_compiles(
     "
@@ -699,8 +710,7 @@ check_c_source_compiles(
     #include <netinet/ip_var.h>
     int main(void) { return 0; }
     "
-    HAVE_NETINET_IP_VAR_H
-)
+    HAVE_NETINET_IP_VAR_H)
 
 check_c_source_compiles(
     "
@@ -713,8 +723,7 @@ check_c_source_compiles(
     #include <netinet/icmp_var.h>
     int main(void) { return 0; }
     "
-    HAVE_NETINET_ICMP_VAR_H
-)
+    HAVE_NETINET_ICMP_VAR_H)
 
 check_include_files(
     sys/cdefs.h
@@ -734,16 +743,19 @@ check_c_source_compiles(
     #include <netinet/tcp.h>
     int main(void) { int x = TCP_ESTABLISHED; return x; }
     "
-    HAVE_TCP_H_TCPSTATE_ENUM
-)
+    HAVE_TCP_H_TCPSTATE_ENUM)
 
 set(CMAKE_REQUIRED_DEFINITIONS)
 
 check_symbol_exists(
     TCPS_ESTABLISHED
     "netinet/tcp_fsm.h"
-    HAVE_TCP_FSM_H
-)
+    HAVE_TCP_FSM_H)
+
+check_symbol_exists(
+    getgrouplist
+    "unistd.h;grp.h"
+    HAVE_GETGROUPLIST)
 
 if(CLR_CMAKE_TARGET_IOS OR CLR_CMAKE_TARGET_TVOS)
     set(HAVE_IOS_NET_ROUTE_H 1)
@@ -774,6 +786,26 @@ check_include_files(
     HAVE_SYS_SYSCTL_H)
 
 check_include_files(
+    "sys/ioctl.h"
+    HAVE_SYS_IOCTL_H)
+
+check_include_files(
+    "sys/filio.h"
+    HAVE_SYS_FILIO_H)
+
+check_include_files(
+    "sys/types.h;netpacket/packet.h"
+    HAVE_NETPACKET_PACKET_H)
+
+check_include_files(
+    "net/if_arp.h"
+    HAVE_NET_IF_ARP_H)
+
+check_include_files(
+    "sys/mntent.h"
+    HAVE_SYS_MNTENT_H)
+
+check_include_files(
     "stdint.h;net/if_media.h"
     HAVE_NET_IFMEDIA_H)
 
@@ -816,8 +848,7 @@ check_c_source_compiles(
         return 0;
     }
     "
-    HAVE_GETDOMAINNAME_SIZET
-)
+    HAVE_GETDOMAINNAME_SIZET)
 set (CMAKE_REQUIRED_FLAGS ${PREVIOUS_CMAKE_REQUIRED_FLAGS})
 
 set (PREVIOUS_CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES})
index 55dcaff..4ae912c 100644 (file)
@@ -54,7 +54,7 @@ namespace System.Diagnostics
             }
             else
             {
-                Interop.Sys.SysLog(Interop.Sys.SysLogPriority.LOG_USER | Interop.Sys.SysLogPriority.LOG_DEBUG, "%s", message);
+                Interop.Sys.SysLog(Interop.Sys.SysLogPriority.LOG_DEBUG, "%s", message);
             }
         }