bdevfs = 0x62646576,
bfs = 0x1BADFACE,
binfmt_misc = 0x42494E4D,
+ bootfs = 0xA56D3FF9,
btrfs = 0x9123683E,
ceph = 0x00C36400,
cgroupfs = 0x0027E0EB,
ext3 = 0xEF53,
ext4 = 0xEF53,
fat = 0x4006,
+ fd = 0xF00D1E,
fhgfs = 0x19830326,
fuse = 0x65735546,
fuseblk = 0x65735546,
jffs2 = 0x72B6,
jfs = 0x3153464A,
kafs = 0x6B414653,
+ lofs = 0xEF53, /* loopback filesystem, magic same as ext2 */
logfs = 0xC97E8168,
lustre = 0x0BD00BD0,
minix_old = 0x137F, /* orig. minix */
case "bdevfs":
case "befs":
case "bfs":
+ case "bootfs":
case "bpf_fs":
case "btrfs":
case "btrfs_test":
case "jffs":
case "jffs2":
case "jfs":
+ case "lofs":
case "logfs":
case "lxfs":
case "minix (30 char.)":
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":
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":
case "securityfs":
case "selinux":
case "selinuxfs":
+ case "sharefs":
case "sockfs":
case "sysfs":
case "tmpfs":
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>
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()
#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
#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
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)
{
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));
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))
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 ()
#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>
#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;
#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>
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;
#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
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)
assert(name != NULL);
assert(mpi != NULL);
-#if defined(HAVE_STATFS)
+#if HAVE_NON_LEGACY_STATFS
struct statfs stats;
memset(&stats, 0, sizeof(struct statfs));
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
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
#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)
return true;
default:
- *palProtocolType = (int)palProtocolType;
+ *palProtocolType = (int32_t)(intptr_t)palProtocolType;
return false;
}
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);
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;
}
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()
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;
/**
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);
include(CheckSymbolExists)
include(CheckTypeSize)
-
if (CLR_CMAKE_TARGET_ANDROID)
set(PAL_UNIX_NAME \"ANDROID\")
elseif (CLR_CMAKE_TARGET_ARCH_WASM)
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.
"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
check_symbol_exists(
"statfs"
${STATFS_INCLUDES}
- HAVE_STATFS
-)
+ HAVE_STATFS)
check_type_size(
"struct statfs"
return 0;
}
"
- BIND_ADDRLEN_UNSIGNED
-)
+ BIND_ADDRLEN_UNSIGNED)
check_c_source_compiles(
"
return 0;
}
"
- IPV6MR_INTERFACE_UNSIGNED
-)
+ IPV6MR_INTERFACE_UNSIGNED)
check_include_files(
"sys/inotify.h"
"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>
#include <netinet/tcp_var.h>
int main(void) { return 0; }
"
- HAVE_NETINET_TCP_VAR_H
-)
+ HAVE_NETINET_TCP_VAR_H)
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(
"
#include <netinet/ip_var.h>
int main(void) { return 0; }
"
- HAVE_NETINET_IP_VAR_H
-)
+ HAVE_NETINET_IP_VAR_H)
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
#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)
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)
return 0;
}
"
- HAVE_GETDOMAINNAME_SIZET
-)
+ HAVE_GETDOMAINNAME_SIZET)
set (CMAKE_REQUIRED_FLAGS ${PREVIOUS_CMAKE_REQUIRED_FLAGS})
set (PREVIOUS_CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES})
}
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);
}
}