Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix illumos build regressions #55916

Merged
merged 9 commits into from
Aug 5, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/coreclr/jit/morph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12748,6 +12748,8 @@ GenTree* Compiler::fgMorphSmpOp(GenTree* tree, MorphAddrContext* mac)

CM_ADD_OP:

FALLTHROUGH;

case GT_OR:
case GT_XOR:
case GT_AND:
Expand Down
6 changes: 6 additions & 0 deletions src/coreclr/minipal/Unix/doublemapping.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,12 @@ bool VMToOSInterface::CreateDoubleMemoryMapper(void** pHandle, size_t *pMaxExecu

#ifdef TARGET_FREEBSD
int fd = shm_open(SHM_ANON, O_RDWR | O_CREAT, S_IRWXU);
#elif defined(TARGET_SUNOS) // has POSIX implementation
char name[24];
sprintf(name, "/shm-dotnet-%d", getpid());
name[sizeof(name) - 1] = '\0';
shm_unlink(name);
int fd = shm_open(name, O_RDWR | O_CREAT | O_EXCL | O_NOFOLLOW, 0600);
#else // TARGET_FREEBSD
int fd = memfd_create("doublemapper", MFD_CLOEXEC);
#endif // TARGET_FREEBSD
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ private static DriveType GetDriveType(string fileSystemName)
case "qnx6":
case "reiserfs":
case "rpc_pipefs":
case "sffs":
case "smackfs":
case "squashfs":
case "swap":
Expand All @@ -179,6 +180,8 @@ private static DriveType GetDriveType(string fileSystemName)
case "umsdos":
case "umview-mod-umfuseext2":
case "v9fs":
case "vagrant":
case "vboxfs":
case "vxfs":
case "vxfs_olt":
case "vzfs":
Expand Down Expand Up @@ -304,6 +307,7 @@ private static DriveType GetDriveType(string fileSystemName)
case "sockfs":
case "sysfs":
case "tmpfs":
case "udev":
case "usbdev":
case "usbdevfs":
return DriveType.Ram;
Expand All @@ -314,8 +318,8 @@ private static DriveType GetDriveType(string fileSystemName)
case "vfat":
return DriveType.Removable;

// Categorize as "Unknown" everything else not explicitly
// recognized as a particular drive type.
// Categorize as "Unknown" everything else not explicitly
// recognized as a particular drive type.
default:
return DriveType.Unknown;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,11 @@ internal enum UnixFileSystemTypes : long
coda = 0x73757245,
coherent = 0x012FF7B7,
configfs = 0x62656570,
cpuset = 0x01021994, // same as tmpfs
cramfs = 0x28CD3D45,
ctfs = 0x01021994, // same as tmpfs
debugfs = 0x64626720,
dev = 0x1373, // same as devfs
devfs = 0x1373,
devpts = 0x1CD1,
ecryptfs = 0xF15F,
Expand Down Expand Up @@ -81,15 +84,17 @@ internal enum UnixFileSystemTypes : long
minix2 = 0x2468, /* minix V2 */
minix2v2 = 0x2478, /* MINIX V2, 30 char names */
minix3 = 0x4D5A,
mntfs = 0x01021994, // same as tmpfs
mqueue = 0x19800202,
msdos = 0x4D44,
nfs = 0x6969,
nfsd = 0x6E667364,
nilfs = 0x3434,
novell = 0x564C,
ntfs = 0x5346544E,
openprom = 0x9FA1,
objfs = 0x01021994, // same as tmpfs
ocfs2 = 0x7461636F,
openprom = 0x9FA1,
omfs = 0xC2993D87,
overlay = 0x794C7630,
overlayfs = 0x794C764F,
Expand All @@ -107,6 +112,8 @@ internal enum UnixFileSystemTypes : long
samba = 0x517B,
securityfs = 0x73636673,
selinux = 0xF97CFF8C,
sffs = 0x786F4256, // same as vboxfs
sharefs = 0x01021994, // same as tmpfs
smb = 0x517B,
smb2 = 0xFE534D42,
sockfs = 0x534F434B,
Expand All @@ -122,13 +129,16 @@ internal enum UnixFileSystemTypes : long
ufs2 = 0x19540119,
usbdevice = 0x9FA2,
v9fs = 0x01021997,
vagrant = 0x786F4256, // same as vboxfs
vboxfs = 0x786F4256,
vmhgfs = 0xBACBACBC,
vxfs = 0xA501FCF5,
vzfs = 0x565A4653,
xenfs = 0xABBA1974,
xenix = 0x012FF7B4,
xfs = 0x58465342,
xia = 0x012FD16D,
udev = 0x01021994, // same as tmpfs
zfs = 0x2FC12FC1,
}

Expand Down
2 changes: 1 addition & 1 deletion src/libraries/Native/Unix/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ if(CLR_CMAKE_TARGET_UNIX)
else()
add_compile_options($<$<COMPILE_LANGUAGE:ASM>:-Wa,--noexecstack>)
if(CLR_CMAKE_TARGET_SUNOS)
add_definitions(-D__EXTENSIONS__ -D_XPG4_2 -D_POSIX_PTHREAD_SEMANTICS)
add_definitions(-D__EXTENSIONS__ -D_XPG4_2 -D_POSIX_PTHREAD_SEMANTICS -DTARGET_SUNOS)
else()
# -z,now is required for full relro.
# see https://www.redhat.com/en/blog/hardening-elf-binaries-using-relocation-read-only-relro
Expand Down
139 changes: 137 additions & 2 deletions src/libraries/Native/Unix/System.Native/pal_io.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,18 @@
#include <sys/vfs.h>
#elif HAVE_STATFS_MOUNT // BSD
#include <sys/mount.h>
#elif !HAVE_NON_LEGACY_STATFS // SunOS
#include <sys/types.h>
#include <sys/statvfs.h>
#include <sys/vfs.h>
#endif

#ifdef _AIX
#include <alloca.h>
// Somehow, AIX mangles the definition for this behind a C++ def
// Redeclare it here
extern int getpeereid(int, uid_t *__restrict__, gid_t *__restrict__);
#elif defined(__sun)
#elif defined(TARGET_SUNOS)
#ifndef _KERNEL
#define _KERNEL
#define UNDEF_KERNEL
Expand Down Expand Up @@ -1405,8 +1409,139 @@ int64_t SystemNative_GetFileSystemType(intptr_t fd)
// which got deprecated in macOS 10.6, in favor of statfs
while ((statfsRes = fstatfs(ToFileDescriptor(fd), &statfsArgs)) == -1 && errno == EINTR) ;
return statfsRes == -1 ? (int64_t)-1 : (int64_t)statfsArgs.f_type;
#elif !HAVE_NON_LEGACY_STATFS
int statfsRes;
struct statvfs statfsArgs;
while ((statfsRes = fstatvfs(ToFileDescriptor(fd), &statfsArgs)) == -1 && errno == EINTR) ;
if (statfsRes == -1) return (int64_t)-1;

int64_t result = -1;

if (strcmp(statfsArgs.f_basetype, "adfs") == 0) result = 0xADF5;
else if (strcmp(statfsArgs.f_basetype, "affs") == 0) result = 0xADFF;
else if (strcmp(statfsArgs.f_basetype, "afs") == 0) result = 0x5346414F;
else if (strcmp(statfsArgs.f_basetype, "anoninode") == 0) result = 0x09041934;
else if (strcmp(statfsArgs.f_basetype, "aufs") == 0) result = 0x61756673;
else if (strcmp(statfsArgs.f_basetype, "autofs") == 0) result = 0x0187;
else if (strcmp(statfsArgs.f_basetype, "autofs4") == 0) result = 0x6D4A556D;
else if (strcmp(statfsArgs.f_basetype, "befs") == 0) result = 0x42465331;
else if (strcmp(statfsArgs.f_basetype, "bdevfs") == 0) result = 0x62646576;
else if (strcmp(statfsArgs.f_basetype, "bfs") == 0) result = 0x1BADFACE;
else if (strcmp(statfsArgs.f_basetype, "binfmt_misc") == 0) result = 0x42494E4D;
else if (strcmp(statfsArgs.f_basetype, "bootfs") == 0) result = 0xA56D3FF9;
else if (strcmp(statfsArgs.f_basetype, "btrfs") == 0) result = 0x9123683E;
else if (strcmp(statfsArgs.f_basetype, "ceph") == 0) result = 0x00C36400;
else if (strcmp(statfsArgs.f_basetype, "cgroupfs") == 0) result = 0x0027E0EB;
else if (strcmp(statfsArgs.f_basetype, "cgroup2fs") == 0) result = 0x63677270;
else if (strcmp(statfsArgs.f_basetype, "cifs") == 0) result = 0xFF534D42;
else if (strcmp(statfsArgs.f_basetype, "coda") == 0) result = 0x73757245;
else if (strcmp(statfsArgs.f_basetype, "coherent") == 0) result = 0x012FF7B7;
else if (strcmp(statfsArgs.f_basetype, "configfs") == 0) result = 0x62656570;
else if (strcmp(statfsArgs.f_basetype, "cpuset") == 0) result = 0x01021994;
else if (strcmp(statfsArgs.f_basetype, "cramfs") == 0) result = 0x28CD3D45;
else if (strcmp(statfsArgs.f_basetype, "ctfs") == 0) result = 0x01021994;
else if (strcmp(statfsArgs.f_basetype, "debugfs") == 0) result = 0x64626720;
else if (strcmp(statfsArgs.f_basetype, "dev") == 0) result = 0x1373;
else if (strcmp(statfsArgs.f_basetype, "devfs") == 0) result = 0x1373;
else if (strcmp(statfsArgs.f_basetype, "devpts") == 0) result = 0x1CD1;
else if (strcmp(statfsArgs.f_basetype, "ecryptfs") == 0) result = 0xF15F;
else if (strcmp(statfsArgs.f_basetype, "efs") == 0) result = 0x00414A53;
else if (strcmp(statfsArgs.f_basetype, "exofs") == 0) result = 0x5DF5;
else if (strcmp(statfsArgs.f_basetype, "ext") == 0) result = 0x137D;
else if (strcmp(statfsArgs.f_basetype, "ext2_old") == 0) result = 0xEF51;
else if (strcmp(statfsArgs.f_basetype, "ext2") == 0) result = 0xEF53;
else if (strcmp(statfsArgs.f_basetype, "ext3") == 0) result = 0xEF53;
else if (strcmp(statfsArgs.f_basetype, "ext4") == 0) result = 0xEF53;
else if (strcmp(statfsArgs.f_basetype, "fat") == 0) result = 0x4006;
else if (strcmp(statfsArgs.f_basetype, "fd") == 0) result = 0xF00D1E;
else if (strcmp(statfsArgs.f_basetype, "fhgfs") == 0) result = 0x19830326;
else if (strcmp(statfsArgs.f_basetype, "fuse") == 0) result = 0x65735546;
else if (strcmp(statfsArgs.f_basetype, "fuseblk") == 0) result = 0x65735546;
else if (strcmp(statfsArgs.f_basetype, "fusectl") == 0) result = 0x65735543;
else if (strcmp(statfsArgs.f_basetype, "futexfs") == 0) result = 0x0BAD1DEA;
else if (strcmp(statfsArgs.f_basetype, "gfsgfs2") == 0) result = 0x1161970;
else if (strcmp(statfsArgs.f_basetype, "gfs2") == 0) result = 0x01161970;
else if (strcmp(statfsArgs.f_basetype, "gpfs") == 0) result = 0x47504653;
else if (strcmp(statfsArgs.f_basetype, "hfs") == 0) result = 0x4244;
else if (strcmp(statfsArgs.f_basetype, "hfsplus") == 0) result = 0x482B;
else if (strcmp(statfsArgs.f_basetype, "hpfs") == 0) result = 0xF995E849;
else if (strcmp(statfsArgs.f_basetype, "hugetlbfs") == 0) result = 0x958458F6;
else if (strcmp(statfsArgs.f_basetype, "inodefs") == 0) result = 0x11307854;
else if (strcmp(statfsArgs.f_basetype, "inotifyfs") == 0) result = 0x2BAD1DEA;
else if (strcmp(statfsArgs.f_basetype, "isofs") == 0) result = 0x9660;
else if (strcmp(statfsArgs.f_basetype, "jffs") == 0) result = 0x07C0;
else if (strcmp(statfsArgs.f_basetype, "jffs2") == 0) result = 0x72B6;
else if (strcmp(statfsArgs.f_basetype, "jfs") == 0) result = 0x3153464A;
else if (strcmp(statfsArgs.f_basetype, "kafs") == 0) result = 0x6B414653;
else if (strcmp(statfsArgs.f_basetype, "lofs") == 0) result = 0xEF53;
else if (strcmp(statfsArgs.f_basetype, "logfs") == 0) result = 0xC97E8168;
else if (strcmp(statfsArgs.f_basetype, "lustre") == 0) result = 0x0BD00BD0;
else if (strcmp(statfsArgs.f_basetype, "minix_old") == 0) result = 0x137F;
else if (strcmp(statfsArgs.f_basetype, "minix") == 0) result = 0x138F;
else if (strcmp(statfsArgs.f_basetype, "minix2") == 0) result = 0x2468;
else if (strcmp(statfsArgs.f_basetype, "minix2v2") == 0) result = 0x2478;
else if (strcmp(statfsArgs.f_basetype, "minix3") == 0) result = 0x4D5A;
else if (strcmp(statfsArgs.f_basetype, "mntfs") == 0) result = 0x01021994;
else if (strcmp(statfsArgs.f_basetype, "mqueue") == 0) result = 0x19800202;
else if (strcmp(statfsArgs.f_basetype, "msdos") == 0) result = 0x4D44;
else if (strcmp(statfsArgs.f_basetype, "nfs") == 0) result = 0x6969;
else if (strcmp(statfsArgs.f_basetype, "nfsd") == 0) result = 0x6E667364;
else if (strcmp(statfsArgs.f_basetype, "nilfs") == 0) result = 0x3434;
else if (strcmp(statfsArgs.f_basetype, "novell") == 0) result = 0x564C;
else if (strcmp(statfsArgs.f_basetype, "ntfs") == 0) result = 0x5346544E;
else if (strcmp(statfsArgs.f_basetype, "objfs") == 0) result = 0x01021994;
else if (strcmp(statfsArgs.f_basetype, "ocfs2") == 0) result = 0x7461636F;
else if (strcmp(statfsArgs.f_basetype, "openprom") == 0) result = 0x9FA1;
else if (strcmp(statfsArgs.f_basetype, "omfs") == 0) result = 0xC2993D87;
else if (strcmp(statfsArgs.f_basetype, "overlay") == 0) result = 0x794C7630;
else if (strcmp(statfsArgs.f_basetype, "overlayfs") == 0) result = 0x794C764F;
else if (strcmp(statfsArgs.f_basetype, "panfs") == 0) result = 0xAAD7AAEA;
else if (strcmp(statfsArgs.f_basetype, "pipefs") == 0) result = 0x50495045;
else if (strcmp(statfsArgs.f_basetype, "proc") == 0) result = 0x9FA0;
else if (strcmp(statfsArgs.f_basetype, "pstorefs") == 0) result = 0x6165676C;
else if (strcmp(statfsArgs.f_basetype, "qnx4") == 0) result = 0x002F;
else if (strcmp(statfsArgs.f_basetype, "qnx6") == 0) result = 0x68191122;
else if (strcmp(statfsArgs.f_basetype, "ramfs") == 0) result = 0x858458F6;
else if (strcmp(statfsArgs.f_basetype, "reiserfs") == 0) result = 0x52654973;
else if (strcmp(statfsArgs.f_basetype, "romfs") == 0) result = 0x7275;
else if (strcmp(statfsArgs.f_basetype, "rootfs") == 0) result = 0x53464846;
else if (strcmp(statfsArgs.f_basetype, "rpc_pipefs") == 0) result = 0x67596969;
else if (strcmp(statfsArgs.f_basetype, "samba") == 0) result = 0x517B;
else if (strcmp(statfsArgs.f_basetype, "securityfs") == 0) result = 0x73636673;
else if (strcmp(statfsArgs.f_basetype, "selinux") == 0) result = 0xF97CFF8C;
else if (strcmp(statfsArgs.f_basetype, "sffs") == 0) result = 0x786F4256;
else if (strcmp(statfsArgs.f_basetype, "sharefs") == 0) result = 0x01021994;
else if (strcmp(statfsArgs.f_basetype, "smb") == 0) result = 0x517B;
else if (strcmp(statfsArgs.f_basetype, "smb2") == 0) result = 0xFE534D42;
else if (strcmp(statfsArgs.f_basetype, "sockfs") == 0) result = 0x534F434B;
else if (strcmp(statfsArgs.f_basetype, "squashfs") == 0) result = 0x73717368;
else if (strcmp(statfsArgs.f_basetype, "sysfs") == 0) result = 0x62656572;
else if (strcmp(statfsArgs.f_basetype, "sysv2") == 0) result = 0x012FF7B6;
else if (strcmp(statfsArgs.f_basetype, "sysv4") == 0) result = 0x012FF7B5;
else if (strcmp(statfsArgs.f_basetype, "tmpfs") == 0) result = 0x01021994;
else if (strcmp(statfsArgs.f_basetype, "ubifs") == 0) result = 0x24051905;
else if (strcmp(statfsArgs.f_basetype, "udf") == 0) result = 0x15013346;
else if (strcmp(statfsArgs.f_basetype, "ufs") == 0) result = 0x00011954;
else if (strcmp(statfsArgs.f_basetype, "ufscigam") == 0) result = 0x54190100;
else if (strcmp(statfsArgs.f_basetype, "ufs2") == 0) result = 0x19540119;
else if (strcmp(statfsArgs.f_basetype, "usbdevice") == 0) result = 0x9FA2;
else if (strcmp(statfsArgs.f_basetype, "v9fs") == 0) result = 0x01021997;
else if (strcmp(statfsArgs.f_basetype, "vagrant") == 0) result = 0x786F4256;
else if (strcmp(statfsArgs.f_basetype, "vboxfs") == 0) result = 0x786F4256;
else if (strcmp(statfsArgs.f_basetype, "vmhgfs") == 0) result = 0xBACBACBC;
else if (strcmp(statfsArgs.f_basetype, "vxfs") == 0) result = 0xA501FCF5;
else if (strcmp(statfsArgs.f_basetype, "vzfs") == 0) result = 0x565A4653;
else if (strcmp(statfsArgs.f_basetype, "xenfs") == 0) result = 0xABBA1974;
else if (strcmp(statfsArgs.f_basetype, "xenix") == 0) result = 0x012FF7B4;
else if (strcmp(statfsArgs.f_basetype, "xfs") == 0) result = 0x58465342;
else if (strcmp(statfsArgs.f_basetype, "xia") == 0) result = 0x012FD16D;
else if (strcmp(statfsArgs.f_basetype, "udev") == 0) result = 0x01021994;
else if (strcmp(statfsArgs.f_basetype, "zfs") == 0) result = 0x2FC12FC1;

assert(result != -1);
return result;
#else
#error "Platform doesn't support fstatfs"
#error "Platform doesn't support fstatfs or fstatvfs"
#endif
}

Expand Down
13 changes: 6 additions & 7 deletions src/libraries/Native/Unix/System.Native/pal_memory.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,15 @@

#if HAVE_MALLOC_SIZE
#include <malloc/malloc.h>
#define MALLOC_SIZE(s) malloc_size(s)
#elif HAVE_MALLOC_USABLE_SIZE
#include <malloc.h>
#define MALLOC_SIZE(s) malloc_usable_size(s)
#elif HAVE_MALLOC_USABLE_SIZE_NP
#include <malloc_np.h>
#define MALLOC_SIZE(s) malloc_usable_size(s)
#elif defined(TARGET_SUNOS)
#define MALLOC_SIZE(s) (*((size_t*)(s)-1))
#else
#error "Platform doesn't support malloc_usable_size or malloc_size"
#endif
Expand Down Expand Up @@ -67,13 +72,7 @@ void SystemNative_Free(void* ptr)

uintptr_t SystemNative_GetUsableSize(void* ptr)
{
#if HAVE_MALLOC_SIZE
return malloc_size(ptr);
#elif HAVE_MALLOC_USABLE_SIZE || HAVE_MALLOC_USABLE_SIZE_NP
return malloc_usable_size(ptr);
#else
#error "Platform doesn't support malloc_usable_size or malloc_size"
#endif
return MALLOC_SIZE(ptr);
}

void* SystemNative_Malloc(uintptr_t size)
Expand Down
4 changes: 4 additions & 0 deletions src/native/corehost/bundle/extractor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
#include "pal.h"
#include "utils.h"

#ifdef __sun
#include <alloca.h>
#endif

#if defined(NATIVE_LIBS_EMBEDDED)
extern "C"
{
Expand Down