475 references to Sys
System.Private.CoreLib (475)
LibraryImports.g.cs (69)
5621internal static partial int Access(string path, global::Interop.Sys.AccessMode mode) 5650static extern unsafe int __PInvoke(byte* __path_native, global::Interop.Sys.AccessMode __mode_native); 6191internal static partial bool FileSystemSupportsLocking(global::Microsoft.Win32.SafeHandles.SafeFileHandle fd, global::Interop.Sys.LockOperations lockOperation, bool accessWrite) 6222static extern unsafe int __PInvoke(nint __fd_native, global::Interop.Sys.LockOperations __lockOperation_native, int __accessWrite_native); 6231internal static partial int FLock(global::Microsoft.Win32.SafeHandles.SafeFileHandle fd, global::Interop.Sys.LockOperations operation) 6260static extern unsafe int __PInvoke(nint __fd_native, global::Interop.Sys.LockOperations __operation_native); 6269internal static partial int FLock(nint fd, global::Interop.Sys.LockOperations operation) 6283static extern unsafe int __PInvoke(nint __fd_native, global::Interop.Sys.LockOperations __operation_native); 6368internal static partial double GetCpuUtilization(ref global::Interop.Sys.ProcessCpuInformation previousCpuInfo) 6372fixed (global::Interop.Sys.ProcessCpuInformation* __previousCpuInfo_native = &previousCpuInfo) 6380static extern unsafe double __PInvoke(global::Interop.Sys.ProcessCpuInformation* __previousCpuInfo_native); 6389internal static unsafe partial int Pipe(int* pipefd, global::Interop.Sys.PipeFlags flags) 6403static extern unsafe int __PInvoke(int* __pipefd_native, global::Interop.Sys.PipeFlags __flags_native); 6797internal static partial int LockFileRegion(global::System.Runtime.InteropServices.SafeHandle fd, long offset, long length, global::Interop.Sys.LockType lockType) 6826static extern unsafe int __PInvoke(nint __fd_native, long __offset_native, long __length_native, global::Interop.Sys.LockType __lockType_native); 6921internal static partial long LSeek(global::Microsoft.Win32.SafeHandles.SafeFileHandle fd, long offset, global::Interop.Sys.SeekWhence whence) 6950static extern unsafe long __PInvoke(nint __fd_native, long __offset_native, global::Interop.Sys.SeekWhence __whence_native); 7099internal static partial nint MMap(nint addr, ulong len, global::Interop.Sys.MemoryMappedProtections prot, global::Interop.Sys.MemoryMappedFlags flags, global::Microsoft.Win32.SafeHandles.SafeFileHandle fd, long offset) 7128static extern unsafe nint __PInvoke(nint __addr_native, ulong __len_native, global::Interop.Sys.MemoryMappedProtections __prot_native, global::Interop.Sys.MemoryMappedFlags __flags_native, nint __fd_native, long __offset_native); 7137internal static partial nint MMap(nint addr, ulong len, global::Interop.Sys.MemoryMappedProtections prot, global::Interop.Sys.MemoryMappedFlags flags, nint fd, long offset) 7151static extern unsafe nint __PInvoke(nint __addr_native, ulong __len_native, global::Interop.Sys.MemoryMappedProtections __prot_native, global::Interop.Sys.MemoryMappedFlags __flags_native, nint __fd_native, long __offset_native); 7191internal static partial global::Microsoft.Win32.SafeHandles.SafeFileHandle Open(string filename, global::Interop.Sys.OpenFlags flags, int mode) 7235static extern unsafe nint __PInvoke(byte* __filename_native, global::Interop.Sys.OpenFlags __flags_native, int __mode_native); 7244private static partial int PathConf(string path, global::Interop.Sys.PathConfName name) 7273static extern unsafe int __PInvoke(byte* __path_native, global::Interop.Sys.PathConfName __name_native); 7282internal static partial int PosixFAdvise(global::Microsoft.Win32.SafeHandles.SafeFileHandle fd, long offset, long length, global::Interop.Sys.FileAdvice advice) 7307static extern unsafe int __PInvoke(nint __fd_native, long __offset_native, long __length_native, global::Interop.Sys.FileAdvice __advice_native); 7392internal static unsafe partial long ReadV(global::System.Runtime.InteropServices.SafeHandle fd, global::Interop.Sys.IOVector* vectors, int vectorCount) 7421static extern unsafe long __PInvoke(nint __fd_native, global::Interop.Sys.IOVector* __vectors_native, int __vectorCount_native); 7430internal static unsafe partial long PReadV(global::System.Runtime.InteropServices.SafeHandle fd, global::Interop.Sys.IOVector* vectors, int vectorCount, long fileOffset) 7459static extern unsafe long __PInvoke(nint __fd_native, global::Interop.Sys.IOVector* __vectors_native, int __vectorCount_native, long __fileOffset_native); 7506internal static unsafe partial long PWriteV(global::System.Runtime.InteropServices.SafeHandle fd, global::Interop.Sys.IOVector* vectors, int vectorCount, long fileOffset) 7535static extern unsafe long __PInvoke(nint __fd_native, global::Interop.Sys.IOVector* __vectors_native, int __vectorCount_native, long __fileOffset_native); 7620internal static unsafe partial long WriteV(global::System.Runtime.InteropServices.SafeHandle fd, global::Interop.Sys.IOVector* vectors, int vectorCount) 7649static extern unsafe long __PInvoke(nint __fd_native, global::Interop.Sys.IOVector* __vectors_native, int __vectorCount_native); 7696internal static unsafe extern partial int ReadDir(nint dir, global::Interop.Sys.DirectoryEntry* outputEntry); 7856internal static partial int FStat(global::System.Runtime.InteropServices.SafeHandle fd, out global::Interop.Sys.FileStatus output) 7869fixed (global::Interop.Sys.FileStatus* __output_native = &output) 7888static extern unsafe int __PInvoke(nint __fd_native, global::Interop.Sys.FileStatus* __output_native); 7897internal static partial int Stat(string path, out global::Interop.Sys.FileStatus output) 7910fixed (global::Interop.Sys.FileStatus* __output_native = &output) 7929static extern unsafe int __PInvoke(byte* __path_native, global::Interop.Sys.FileStatus* __output_native); 7938internal static partial int LStat(string path, out global::Interop.Sys.FileStatus output) 7951fixed (global::Interop.Sys.FileStatus* __output_native = &output) 7970static extern unsafe int __PInvoke(byte* __path_native, global::Interop.Sys.FileStatus* __output_native); 7979internal static partial int Stat(global::System.ReadOnlySpan<char> path, out global::Interop.Sys.FileStatus output) 7992fixed (global::Interop.Sys.FileStatus* __output_native = &output) 8011static extern unsafe int __PInvoke(byte* __path_native, global::Interop.Sys.FileStatus* __output_native); 8020internal static partial int LStat(global::System.ReadOnlySpan<char> path, out global::Interop.Sys.FileStatus output) 8033fixed (global::Interop.Sys.FileStatus* __output_native = &output) 8052static extern unsafe int __PInvoke(byte* __path_native, global::Interop.Sys.FileStatus* __output_native); 8104internal static partial long SysConf(global::Interop.Sys.SysConfName name) 8118static extern unsafe long __PInvoke(global::Interop.Sys.SysConfName __name_native); 8127internal static partial void SysLog(global::Interop.Sys.SysLogPriority priority, string message, string arg1) 8155static extern unsafe void __PInvoke(global::Interop.Sys.SysLogPriority __priority_native, byte* __message_native, byte* __arg1_native); 8232internal static unsafe partial int UTimensat(string path, global::Interop.Sys.TimeSpec* times) 8261static extern unsafe int __PInvoke(byte* __path_native, global::Interop.Sys.TimeSpec* __times_native); 8270internal static unsafe partial int FUTimens(global::System.Runtime.InteropServices.SafeHandle fd, global::Interop.Sys.TimeSpec* times) 8299static extern unsafe int __PInvoke(nint __fd_native, global::Interop.Sys.TimeSpec* __times_native); 8446internal static unsafe partial int GetPwUidR(uint uid, out global::Interop.Sys.Passwd pwd, byte* buf, int bufLen) 8451fixed (global::Interop.Sys.Passwd* __pwd_native = &pwd) 8459static extern unsafe int __PInvoke(uint __uid_native, global::Interop.Sys.Passwd* __pwd_native, byte* __buf_native, int __bufLen_native); 8468internal static unsafe partial int GetPwNamR(string name, out global::Interop.Sys.Passwd pwd, byte* buf, int bufLen) 8480fixed (global::Interop.Sys.Passwd* __pwd_native = &pwd) 8496static extern unsafe int __PInvoke(byte* __name_native, global::Interop.Sys.Passwd* __pwd_native, byte* __buf_native, int __bufLen_native);
src\libraries\Common\src\Interop\Unix\Interop.Errors.cs (3)
124_error = Interop.Sys.ConvertErrorPlatformToPal(errno); 141get { return _rawErrno == -1 ? (_rawErrno = Interop.Sys.ConvertErrorPalToPlatform(_error)) : _rawErrno; } 146return Interop.Sys.StrError(RawErrno);
src\libraries\Common\src\Interop\Unix\Interop.IOErrors.cs (3)
42ThrowExceptionForIoErrno(Sys.GetLastErrorInfo(), path, isDirError); 53ThrowExceptionForIoErrno(Sys.GetLastErrorInfo(), path: null, isDirError: false); 99Exception e = Interop.GetExceptionForIoErrno(Sys.GetLastErrorInfo(), path, isDirError);
src\libraries\Common\src\Interop\Unix\System.Native\Interop.GetCwd.cs (1)
63ErrorInfo errorInfo = Interop.Sys.GetLastErrorInfo();
src\libraries\Common\src\Interop\Unix\System.Native\Interop.GetPwUid.cs (3)
37const int BufLen = Interop.Sys.Passwd.InitialBufferSize; 64Interop.Sys.Passwd passwd; 65int error = Interop.Sys.GetPwUidR(uid, out passwd, buf, bufLen);
src\libraries\Common\src\Interop\Unix\System.Native\Interop.GetRandomBytes.cs (2)
20Sys.GetNonCryptographicallySecureRandomBytes(buffer, length); 25if (Sys.GetCryptographicallySecureRandomBytes(buffer, length) != 0)
src\libraries\Common\src\Interop\Unix\System.Native\Interop.IsMemberOfGroup.cs (2)
30rv = Interop.Sys.GetGroups(groups.Length, pGroups); 38else if (rv == -1 && Interop.Sys.GetLastError() == Interop.Error.EINVAL)
src\libraries\System.Private.CoreLib\src\Internal\Console.Unix.cs (2)
18Interop.Sys.Log(pBytes, bytes.Length); 30Interop.Sys.LogError(pBytes, bytes.Length);
src\libraries\System.Private.CoreLib\src\Microsoft\Win32\SafeHandles\SafeFileHandle.Unix.cs (84)
64if (Interop.Sys.Fcntl.GetIsNonBlocking(this, out bool isNonBlocking) != 0) 66throw Interop.GetExceptionForIoErrno(Interop.Sys.GetLastErrorInfo(), Path); 110private static SafeFileHandle Open(string path, Interop.Sys.OpenFlags flags, int mode, bool failForSymlink, out bool wasSymlink, 111Func<Interop.ErrorInfo, Interop.Sys.OpenFlags, string, Exception?>? createOpenException) 115SafeFileHandle handle = Interop.Sys.Open(path, flags, mode); 120Interop.ErrorInfo error = Interop.Sys.GetLastErrorInfo(); 156Interop.Sys.Unlink(_path); // ignore errors; it's valid that the path may no longer exist 166Interop.Sys.FLock(handle, Interop.Sys.LockOperations.LOCK_UN); // ignore any errors 171return Interop.Sys.Close(handle) == 0; 189Interop.Sys.PipeFlags flags = Interop.Sys.PipeFlags.O_CLOEXEC; 192flags |= Interop.Sys.PipeFlags.O_NONBLOCK_READ; 197flags |= Interop.Sys.PipeFlags.O_NONBLOCK_WRITE; 204if (Interop.Sys.Pipe(fds, flags) != 0) 206Interop.ErrorInfo error = Interop.Sys.GetLastErrorInfo(); 212readFd = fds[Interop.Sys.ReadEndOfPipe]; 213writeFd = fds[Interop.Sys.WriteEndOfPipe]; 236Func<Interop.ErrorInfo, Interop.Sys.OpenFlags, string, Exception?>? createOpenException = null) 242Func<Interop.ErrorInfo, Interop.Sys.OpenFlags, string, Exception?>? createOpenException = null) 249Func<Interop.ErrorInfo, Interop.Sys.OpenFlags, string, Exception?>? createOpenException = null) 252Interop.Sys.OpenFlags openFlags = PreOpenConfigurationFromOptions(mode, access, share, options, failForSymlink); 295private static Interop.Sys.OpenFlags PreOpenConfigurationFromOptions(FileMode mode, FileAccess access, FileShare share, FileOptions options, bool failForSymlink) 298Interop.Sys.OpenFlags flags = default; 301flags |= Interop.Sys.OpenFlags.O_NOFOLLOW; 313flags |= Interop.Sys.OpenFlags.O_TRUNC; 319flags |= Interop.Sys.OpenFlags.O_CREAT; 323flags |= Interop.Sys.OpenFlags.O_CREAT; 326flags |= Interop.Sys.OpenFlags.O_TRUNC; 331flags |= (Interop.Sys.OpenFlags.O_CREAT | Interop.Sys.OpenFlags.O_EXCL); 339flags |= Interop.Sys.OpenFlags.O_RDONLY; 343flags |= Interop.Sys.OpenFlags.O_RDWR; 347flags |= Interop.Sys.OpenFlags.O_WRONLY; 354flags |= Interop.Sys.OpenFlags.O_CLOEXEC; 366flags |= Interop.Sys.OpenFlags.O_SYNC; 375Interop.Sys.FileStatus status = default; 387if ((status.Mode & Interop.Sys.FileTypes.S_IFMT) == Interop.Sys.FileTypes.S_IFDIR) 392if ((status.Mode & Interop.Sys.FileTypes.S_IFMT) == Interop.Sys.FileTypes.S_IFREG) 401Debug.Assert(status.Size == 0 || Interop.Sys.LSeek(this, 0, Interop.Sys.SeekWhence.SEEK_CUR) >= 0); 416Interop.Sys.LockOperations lockOperation = (share == FileShare.None) ? Interop.Sys.LockOperations.LOCK_EX : Interop.Sys.LockOperations.LOCK_SH; 417if (CanLockTheFile(lockOperation, access) && !(_isLocked = Interop.Sys.FLock(this, lockOperation | Interop.Sys.LockOperations.LOCK_NB) >= 0)) 423Interop.ErrorInfo errorInfo = Interop.Sys.GetLastErrorInfo(); 443Interop.Sys.FileStatus pathStatus; 444if (Interop.Sys.Stat(path, out pathStatus) < 0) 449Interop.ErrorInfo error = Interop.Sys.GetLastErrorInfo(); 471Interop.Sys.FileAdvice fadv = 472(options & FileOptions.RandomAccess) != 0 ? Interop.Sys.FileAdvice.POSIX_FADV_RANDOM : 473(options & FileOptions.SequentialScan) != 0 ? Interop.Sys.FileAdvice.POSIX_FADV_SEQUENTIAL : 477FileStreamHelpers.CheckFileCall(Interop.Sys.PosixFAdvise(this, 0, 0, fadv), path, 485if (Interop.Sys.FTruncate(this, 0) < 0) 487Interop.ErrorInfo errorInfo = Interop.Sys.GetLastErrorInfo(); 498if (preallocationSize > 0 && Interop.Sys.FAllocate(this, 0, preallocationSize) < 0) 500Interop.ErrorInfo errorInfo = Interop.Sys.GetLastErrorInfo(); 510Interop.Sys.Unlink(path); 522private bool CanLockTheFile(Interop.Sys.LockOperations lockOperation, FileAccess access) 524Debug.Assert(lockOperation == Interop.Sys.LockOperations.LOCK_EX || lockOperation == Interop.Sys.LockOperations.LOCK_SH); 531return Interop.Sys.FileSystemSupportsLocking(this, lockOperation, accessWrite: (access & FileAccess.Write) != 0); 534private void FStatCheckIO(string path, ref Interop.Sys.FileStatus status, ref bool statusHasValue) 538if (Interop.Sys.FStat(this, out status) != 0) 540Interop.ErrorInfo error = Interop.Sys.GetLastErrorInfo(); 556_canSeek = canSeek = Interop.Sys.LSeek(this, 0, Interop.Sys.SeekWhence.SEEK_CUR) >= 0 ? NullableBool.True : NullableBool.False; 564int result = Interop.Sys.FStat(this, out Interop.Sys.FileStatus status); 567Interop.ErrorInfo error = Interop.Sys.GetLastErrorInfo(); 574private static FileHandleType MapUnixFileTypeToFileType(Interop.Sys.FileStatus status) 575=> (status.Mode & Interop.Sys.FileTypes.S_IFMT) switch 577Interop.Sys.FileTypes.S_IFREG => FileHandleType.RegularFile, 578Interop.Sys.FileTypes.S_IFDIR => FileHandleType.Directory, 579Interop.Sys.FileTypes.S_IFLNK => FileHandleType.SymbolicLink, 580Interop.Sys.FileTypes.S_IFIFO => FileHandleType.Pipe, 581Interop.Sys.FileTypes.S_IFSOCK => FileHandleType.Socket, 582Interop.Sys.FileTypes.S_IFCHR => FileHandleType.CharacterDevice, 583Interop.Sys.FileTypes.S_IFBLK => FileHandleType.BlockDevice, 589int result = Interop.Sys.FStat(this, out Interop.Sys.FileStatus status);
src\libraries\System.Private.CoreLib\src\System\AppDomain.Unix.cs (2)
12Interop.Sys.ProcessCpuInformation cpuInfo = default; 13Interop.Sys.GetCpuUtilization(ref cpuInfo);
src\libraries\System.Private.CoreLib\src\System\DateTime.Unix.cs (1)
14return new DateTime(((ulong)(Interop.Sys.GetSystemTimeAsTicks() + UnixEpochTicks)) | KindUtc);
src\libraries\System.Private.CoreLib\src\System\Diagnostics\DebugProvider.Unix.cs (3)
56Interop.Sys.SysLog(Interop.Sys.SysLogPriority.LOG_DEBUG, "%s", message); 89int bytesWritten = Interop.Sys.Write((IntPtr)2 /* stderr */, buf + totalBytesWritten, bufCount);
src\libraries\System.Private.CoreLib\src\System\Diagnostics\Stopwatch.Unix.cs (1)
14public static long GetTimestamp() => Interop.Sys.GetTimestamp();
src\libraries\System.Private.CoreLib\src\System\Diagnostics\Tracing\RuntimeEventSourceHelper.Unix.cs (2)
8private static Interop.Sys.ProcessCpuInformation s_cpuInfo; 11Interop.Sys.GetCpuUtilization(ref s_cpuInfo) / Environment.ProcessorCount;
src\libraries\System.Private.CoreLib\src\System\Environment.GetFolderPathCore.Unix.cs (4)
30Interop.Sys.Access(path, Interop.Sys.AccessMode.R_OK) == 0) 185if (Interop.Sys.Access(userDirsPath, Interop.Sys.AccessMode.R_OK) == 0)
src\libraries\System.Private.CoreLib\src\System\Environment.OSVersion.Unix.cs (1)
8private static OperatingSystem GetOSVersion() => GetOperatingSystem(Interop.Sys.GetUnixRelease());
src\libraries\System.Private.CoreLib\src\System\Environment.Unix.cs (7)
15public static string[] GetLogicalDrives() => Interop.Sys.GetAllMountPoints(); 21string hostName = Interop.Sys.GetHostName(); 27public static string UserName => Interop.Sys.GetUserNameFromPasswd(Interop.Sys.GetEUid()); 29private static bool IsPrivilegedProcessCore() => Interop.Sys.GetEUid() == 0; 32private static int GetProcessId() => Interop.Sys.GetPid(); 35private static string? GetProcessPath() => Interop.Sys.GetProcessPath();
src\libraries\System.Private.CoreLib\src\System\Environment.UnixOrBrowser.cs (10)
20get => Interop.Sys.GetCwd(); 21set => Interop.CheckIo(Interop.Sys.ChDir(value), value, isDirError: true); 56private static int GetSystemPageSize() => CheckedSysConf(Interop.Sys.SysConfName._SC_PAGESIZE); 60/// <summary>Invoke <see cref="Interop.Sys.SysConf"/>, throwing if it fails.</summary> 61private static int CheckedSysConf(Interop.Sys.SysConfName name) 63long result = Interop.Sys.SysConf(name); 66Interop.ErrorInfo errno = Interop.Sys.GetLastErrorInfo(); 86Interop.Sys.ProcessCpuInformation cpuInfo = default; 87Interop.Sys.GetCpuUtilization(ref cpuInfo); 99public static long TickCount64 => Interop.Sys.GetLowResolutionTimestamp();
src\libraries\System.Private.CoreLib\src\System\IO\Directory.Unix.cs (1)
48if (Interop.Sys.MkdTemp(pPath) is null)
src\libraries\System.Private.CoreLib\src\System\IO\DriveInfoInternal.Unix.cs (1)
9internal static string[] GetLogicalDrives() => Interop.Sys.GetAllMountPoints();
src\libraries\System.Private.CoreLib\src\System\IO\Enumeration\FileSystemEntry.Unix.cs (7)
18private Interop.Sys.DirectoryEntry _directoryEntry; 34Interop.Sys.DirectoryEntry directoryEntry, 50bool isDirectory = directoryEntry.InodeType == Interop.Sys.NodeType.DT_DIR; 51bool isSymlink = directoryEntry.InodeType == Interop.Sys.NodeType.DT_LNK; 52bool isUnknown = directoryEntry.InodeType == Interop.Sys.NodeType.DT_UNKNOWN; 67entry._directoryEntry.InodeType = Interop.Sys.NodeType.DT_LNK; 164internal bool IsSymbolicLink => _directoryEntry.InodeType == Interop.Sys.NodeType.DT_LNK;
src\libraries\System.Private.CoreLib\src\System\IO\Enumeration\FileSystemEnumerator.Unix.cs (6)
27private Interop.Sys.DirectoryEntry _entry; 80IntPtr handle = Interop.Sys.OpenDir(path); 83Interop.ErrorInfo info = Interop.Sys.GetLastErrorInfo(); 97Interop.Sys.CloseDir(handle); 176fixed (Interop.Sys.DirectoryEntry* e = &_entry) 178result = Interop.Sys.ReadDir(_directoryHandle, e);
src\libraries\System.Private.CoreLib\src\System\IO\FileStatus.Unix.cs (34)
29private Interop.Sys.FileStatus _fileCache; 44return EntryExists && (_fileCache.UserFlags & (uint)Interop.Sys.UserFlags.UF_HIDDEN) == (uint)Interop.Sys.UserFlags.UF_HIDDEN; 106if (_fileCache.Uid == Interop.Sys.GetEUid()) 118if (Interop.Sys.IsMemberOfGroup(_fileCache.Gid)) 138return EntryExists && (_fileCache.Mode & Interop.Sys.FileTypes.S_IFMT) == Interop.Sys.FileTypes.S_IFLNK; 162if (!Interop.Sys.SupportsHiddenFlag) 246if (Interop.Sys.CanSetHiddenFlag) 251uint flags = hidden ? _fileCache.UserFlags | (uint)Interop.Sys.UserFlags.UF_HIDDEN : 252_fileCache.UserFlags & ~(uint)Interop.Sys.UserFlags.UF_HIDDEN; 253int rv = handle is not null ? Interop.Sys.FChflags(handle, flags) : 254Interop.Sys.LChflags(path!, flags); 277int rv = handle is not null ? Interop.Sys.FChMod(handle, newMode) : 278Interop.Sys.ChMod(path!, newMode); 304if ((_fileCache.Flags & Interop.Sys.FileStatusFlags.HasBirthTime) != 0) 392Interop.Sys.TimeSpec* buf = stackalloc Interop.Sys.TimeSpec[2]; 419? Interop.Sys.FUTimens(handle, buf) 420: Interop.Sys.UTimensat(path!, buf); 431bool updateCreationTime = checkCreationTime && (_fileCache.Flags & Interop.Sys.FileStatusFlags.HasBirthTime) != 0 && 486int rv = handle is not null ? Interop.Sys.FChMod(handle, (int)mode) 487: Interop.Sys.ChMod(path!, (int)mode); 506Interop.Sys.FStat(handle, out _fileCache) : 507Interop.Sys.LStat(Path.TrimEndingDirectorySeparator(path), out _fileCache); 511Interop.ErrorInfo errorInfo = Interop.Sys.GetLastErrorInfo(); 531int fileType = _fileCache.Mode & Interop.Sys.FileTypes.S_IFMT; 532bool isDirectory = fileType == Interop.Sys.FileTypes.S_IFDIR; 534if (fileType == Interop.Sys.FileTypes.S_IFLNK) 536if (Interop.Sys.Stat(path, out Interop.Sys.FileStatus target) == 0) 538isDirectory = (target.Mode & Interop.Sys.FileTypes.S_IFMT) == Interop.Sys.FileTypes.S_IFDIR; 541_fileCache.Mode = Interop.Sys.FileTypes.S_IFLNK | (target.Mode & (int)FileSystem.ValidUnixFileModes);
src\libraries\System.Private.CoreLib\src\System\IO\FileSystem.Exists.Unix.cs (13)
18Interop.Sys.FileStatus fileinfo; 21if (Interop.Sys.Stat(fullPath, out fileinfo) < 0) 23errorInfo = Interop.Sys.GetLastErrorInfo(); 27return (fileinfo.Mode & Interop.Sys.FileTypes.S_IFMT) == Interop.Sys.FileTypes.S_IFDIR; 37Interop.Sys.FileStatus fileinfo; 49if (Interop.Sys.LStat(fullPath, out fileinfo) < 0) 51errorInfo = Interop.Sys.GetLastErrorInfo(); 57if ((fileinfo.Mode & Interop.Sys.FileTypes.S_IFMT) == Interop.Sys.FileTypes.S_IFLNK) 59if (Interop.Sys.Stat(fullPath, out fileinfo) < 0) 65return (fileinfo.Mode & Interop.Sys.FileTypes.S_IFMT) != Interop.Sys.FileTypes.S_IFDIR;
src\libraries\System.Private.CoreLib\src\System\IO\FileSystem.Unix.cs (47)
51Interop.CheckIo(Interop.Sys.CopyFile(src, dst, fileLength)); 54private static Exception? CreateOpenExceptionForCopyFile(Interop.ErrorInfo error, Interop.Sys.OpenFlags flags, string path) 77if (Interop.Sys.Link(sourceFullPath, destFullPath) >= 0) 87Interop.ErrorInfo errorInfo = Interop.Sys.GetLastErrorInfo(); 126Interop.CheckIo(Interop.Sys.LStat(sourceFullPath, out Interop.Sys.FileStatus sourceStat), sourceFullPath); 129if ((sourceStat.Mode & Interop.Sys.FileTypes.S_IFMT) == Interop.Sys.FileTypes.S_IFDIR) 134Interop.Sys.FileStatus destStat; 135if (Interop.Sys.LStat(destFullPath, out destStat) == 0) 138if ((destStat.Mode & Interop.Sys.FileTypes.S_IFMT) == Interop.Sys.FileTypes.S_IFDIR) 154if (Interop.Sys.Unlink(destBackupFullPath) != 0) 156Interop.ErrorInfo errno = Interop.Sys.GetLastErrorInfo(); 170if (Interop.Sys.Stat(destFullPath, out _) != 0) 172Interop.ErrorInfo errno = Interop.Sys.GetLastErrorInfo(); 181Interop.CheckIo(Interop.Sys.Rename(sourceFullPath, destFullPath)); 195if (Interop.Sys.Rename(sourceFullPath, destFullPath) < 0) 197Interop.ErrorInfo errorInfo = Interop.Sys.GetLastErrorInfo(); 224Interop.Sys.FileStatus sourceStat, destStat; 225if (Interop.Sys.LStat(sourceFullPath, out sourceStat) == 0 && // source file exists 226(Interop.Sys.LStat(destFullPath, out destStat) != 0 || // dest file does not exist 229Interop.Sys.Rename(sourceFullPath, destFullPath) == 0) // try the rename 241if (Interop.Sys.Unlink(fullPath) < 0) 243Interop.ErrorInfo errorInfo = Interop.Sys.GetLastErrorInfo(); 296int result = Interop.Sys.MkDir(path, (int)unixCreateMode); 302Interop.ErrorInfo errorInfo = Interop.Sys.GetLastErrorInfo(); 340int result = Interop.Sys.MkDir(mkdirPath, (int)DefaultUnixCreateDirectoryMode); 346Interop.ErrorInfo errorInfo = Interop.Sys.GetLastErrorInfo(); 373int result = Interop.Sys.MkDir(mkdirPath, (int)mode); 376Interop.ErrorInfo errorInfo = Interop.Sys.GetLastErrorInfo(); 414if (!isCaseSensitiveRename && Interop.Sys.LStat(destNoDirectorySeparator, out Interop.Sys.FileStatus destFileStatus) >= 0) 419if (Interop.Sys.LStat(srcNoDirectorySeparator, out Interop.Sys.FileStatus sourceFileStatus) < 0) 438else if ((sourceFileStatus.Mode & Interop.Sys.FileTypes.S_IFMT) != Interop.Sys.FileTypes.S_IFDIR 449if (Interop.Sys.Rename(sourceFullPath, destNoDirectorySeparator) < 0) 451Interop.ErrorInfo errorInfo = Interop.Sys.GetLastErrorInfo(); 527if (Interop.Sys.RmDir(fullPath) < 0) 529Interop.ErrorInfo errorInfo = Interop.Sys.GetLastErrorInfo(); 662internal static string? GetLinkTarget(ReadOnlySpan<char> linkPath, bool isDirectory) => Interop.Sys.ReadLink(linkPath); 666Interop.CheckIo(Interop.Sys.SymLink(pathToTarget, path), path); 672Interop.CheckIo(Interop.Sys.Link(pathToTarget, path), path); 680string? linkTarget = Interop.Sys.ReadLink(linkPath); 683Interop.Error error = Interop.Sys.GetLastError(); 713current = Interop.Sys.ReadLink(sb.AsSpan());
src\libraries\System.Private.CoreLib\src\System\IO\Path.Unix.cs (7)
19bool result = Interop.Sys.LStat(fullPath, out Interop.Sys.FileStatus fileInfo) == Interop.Errors.ERROR_SUCCESS; 20isDirectory = result && (fileInfo.Mode & Interop.Sys.FileTypes.S_IFMT) == Interop.Sys.FileTypes.S_IFDIR; 62path = Combine(Interop.Sys.GetCwd(), path); 115IntPtr fd = Interop.CheckIo(Interop.Sys.MksTemps(pPath, SuffixByteLength), tempPath, isDirError: true); 116Interop.Sys.Close(fd); // ignore any errors from close; nothing to do if cleanup isn't possible
src\libraries\System.Private.CoreLib\src\System\IO\PersistedFiles.Unix.cs (4)
72const int BufLen = Interop.Sys.Passwd.InitialBufferSize; 101Interop.Sys.Passwd passwd; 102int error = Interop.Sys.GetPwUidR(Interop.Sys.GetEUid(), out passwd, buf, bufLen);
src\libraries\System.Private.CoreLib\src\System\IO\RandomAccess.Unix.cs (28)
23FileStreamHelpers.CheckFileCall(Interop.Sys.FTruncate(handle, length), handle.Path); 35result = Interop.Sys.ReadFromNonblocking(handle, bufPtr, buffer.Length); 40result = Interop.Sys.PRead(handle, bufPtr, buffer.Length, fileOffset); 42if (result == -1 && ShouldFallBackToNonOffsetSyscall(Interop.Sys.GetLastErrorInfo())) 50result = Interop.Sys.Read(handle, bufPtr, buffer.Length); 61Span<Interop.Sys.IOVector> vectors = buffers.Count <= IovStackThreshold ? stackalloc Interop.Sys.IOVector[IovStackThreshold] : new Interop.Sys.IOVector[buffers.Count]; 71vectors[i] = new Interop.Sys.IOVector { Base = (byte*)memoryHandle.Pointer, Count = (UIntPtr)buffer.Length }; 75fixed (Interop.Sys.IOVector* pinnedVectors = &MemoryMarshal.GetReference(vectors)) 79result = Interop.Sys.PReadV(handle, pinnedVectors, buffers.Count, fileOffset); 81if (result == -1 && ShouldFallBackToNonOffsetSyscall(Interop.Sys.GetLastErrorInfo())) 89result = Interop.Sys.ReadV(handle, pinnedVectors, buffers.Count); 123bytesWritten = Interop.Sys.WriteToNonblocking(handle, bufPtr, bytesToWrite); 127bytesWritten = Interop.Sys.PWrite(handle, bufPtr, bytesToWrite, fileOffset); 129if (bytesWritten == -1 && ShouldFallBackToNonOffsetSyscall(Interop.Sys.GetLastErrorInfo())) 137bytesWritten = Interop.Sys.Write(handle, bufPtr, bytesToWrite); 177Span<Interop.Sys.IOVector> vectors = buffersCount <= IovStackThreshold ? 178stackalloc Interop.Sys.IOVector[IovStackThreshold].Slice(0, buffersCount) : 179new Interop.Sys.IOVector[buffersCount]; 190vectors[i] = new Interop.Sys.IOVector { Base = (byte*)memoryHandle.Pointer, Count = (UIntPtr)buffer.Length }; 198Span<Interop.Sys.IOVector> left = vectors.Slice(buffersOffset); 199fixed (Interop.Sys.IOVector* pinnedVectors = &MemoryMarshal.GetReference(left)) 203bytesWritten = Interop.Sys.PWriteV(handle, pinnedVectors, left.Length, fileOffset); 205if (bytesWritten == -1 && ShouldFallBackToNonOffsetSyscall(Interop.Sys.GetLastErrorInfo())) 213bytesWritten = Interop.Sys.WriteV(handle, pinnedVectors, left.Length); 243Interop.Sys.IOVector current = vectors[buffersOffset]; 244vectors[buffersOffset] = new Interop.Sys.IOVector
src\libraries\System.Private.CoreLib\src\System\IO\SharedMemoryManager.Unix.cs (61)
24private static int SessionId { get; } = Interop.Sys.GetSid(Environment.ProcessId); 50Uid = IsUserScope ? Interop.Sys.GetEUid() : 0; 211Interop.Sys.FLock(fileHandle, Interop.Sys.LockOperations.LOCK_UN); 223if (Interop.Sys.FTruncate(fileHandle, (long)sharedDataTotalByteCount) < 0) 225Interop.ErrorInfo error = Interop.Sys.GetLastErrorInfo(); 231if (Interop.Sys.FStat(fileHandle, out Interop.Sys.FileStatus fileStatus) != 0) 233Interop.ErrorInfo error = Interop.Sys.GetLastErrorInfo(); 242if (Interop.Sys.FTruncate(fileHandle, (long)sharedDataTotalByteCount) < 0) 244Interop.ErrorInfo error = Interop.Sys.GetLastErrorInfo(); 256Interop.ErrorInfo errorInfo = Interop.Sys.GetLastErrorInfo(); 341Interop.Sys.FLock(_fileHandle, Interop.Sys.LockOperations.LOCK_UN); 356Interop.Sys.MUnmap((nint)_sharedDataHeader, _sharedDataTotalByteCount); 372Interop.Sys.Unlink(sharedMemoryFilePath); 374Interop.Sys.RmDir(sessionDirectoryPath); 423SafeFileHandle fd = Interop.Sys.Open(sharedMemoryFilePath, Interop.Sys.OpenFlags.O_RDWR | Interop.Sys.OpenFlags.O_CLOEXEC, 0); 424Interop.ErrorInfo error = Interop.Sys.GetLastErrorInfo(); 429if (Interop.Sys.FStat(fd, out Interop.Sys.FileStatus fileStatus) != 0) 431error = Interop.Sys.GetLastErrorInfo(); 469fd = Interop.Sys.Open( 471Interop.Sys.OpenFlags.O_RDWR | Interop.Sys.OpenFlags.O_CLOEXEC | Interop.Sys.OpenFlags.O_CREAT | Interop.Sys.OpenFlags.O_EXCL, 476error = Interop.Sys.GetLastErrorInfo(); 480int result = Interop.Sys.FChMod(fd, (int)permissionsMask); 484error = Interop.Sys.GetLastErrorInfo(); 486Interop.Sys.Unlink(sharedMemoryFilePath); 500int statResult = Interop.Sys.Stat(directoryPath, out Interop.Sys.FileStatus fileStatus); 502if (statResult != 0 && Interop.Sys.GetLastError() == Interop.Error.ENOENT) 541if (Interop.Sys.MkdTemp(tempPathPtr) == null) 544Interop.ErrorInfo error = Interop.Sys.GetLastErrorInfo(); 562if (Interop.Sys.Rename(tempPath, directoryPath) == 0) 570statResult = Interop.Sys.Stat(directoryPath, out fileStatus); 574if (statResult != 0 || (fileStatus.Mode & Interop.Sys.FileTypes.S_IFDIR) == 0) 578Interop.ErrorInfo error = Interop.Sys.GetLastErrorInfo(); 628|| (createIfNotExist && Interop.Sys.ChMod(directoryPath, (int)permissionsMask) == 0)) 653nint addr = Interop.Sys.MMap( 656Interop.Sys.MemoryMappedProtections.PROT_READ | Interop.Sys.MemoryMappedProtections.PROT_WRITE, 657Interop.Sys.MemoryMappedFlags.MAP_SHARED, 663Interop.ErrorInfo errorInfo = Interop.Sys.GetLastErrorInfo(); 672Interop.Sys.LockOperations lockOperation = exclusive ? Interop.Sys.LockOperations.LOCK_EX : Interop.Sys.LockOperations.LOCK_SH; 675lockOperation |= Interop.Sys.LockOperations.LOCK_NB; 677int result = Interop.Sys.FLock(sharedLockFileHandle, lockOperation); 684Interop.ErrorInfo errorInfo = Interop.Sys.GetLastErrorInfo(); 707Interop.Sys.MUnmap(addr, length); 730Interop.Sys.FLock(FileHandle, Interop.Sys.LockOperations.LOCK_UN); 764Interop.ErrorInfo error = Interop.Sys.GetLastErrorInfo(); 779fd = Interop.Sys.Open(sharedMemoryDirectory, Interop.Sys.OpenFlags.O_RDONLY, 0); 782Interop.ErrorInfo error = Interop.Sys.GetLastErrorInfo();
src\libraries\System.Private.CoreLib\src\System\IO\Strategies\FileStreamHelpers.Unix.cs (10)
23Interop.ErrorInfo errorInfo = Interop.Sys.GetLastErrorInfo(); 34CheckFileCall(Interop.Sys.LSeek(handle, offset, (Interop.Sys.SeekWhence)(int)origin), handle.Path); // SeekOrigin values are the same as Interop.libc.SeekWhence values 42if (Interop.Sys.FSync(handle) < 0) 44Interop.ErrorInfo errorInfo = Interop.Sys.GetLastErrorInfo(); 66CheckFileCall(Interop.Sys.LockFileRegion(handle, position, length, canWrite ? Interop.Sys.LockType.F_WRLCK : Interop.Sys.LockType.F_RDLCK), handle.Path); 76CheckFileCall(Interop.Sys.LockFileRegion(handle, position, length, Interop.Sys.LockType.F_UNLCK), handle.Path);
src\libraries\System.Private.CoreLib\src\System\IO\Strategies\UnixFileStreamStrategy.cs (3)
30long result = Interop.Sys.LSeek(_fileHandle, _filePosition, Interop.Sys.SeekWhence.SEEK_SET); 33Interop.ErrorInfo errorInfo = Interop.Sys.GetLastErrorInfo();
src\libraries\System.Private.CoreLib\src\System\Runtime\InteropServices\Marshal.Unix.cs (7)
87Interop.Sys.Free(pvNative); 106void* p = Interop.Sys.Malloc((nuint)cbNative & ~WIN32_ALLOC_ALIGN); 132void* p = Interop.Sys.Malloc((nuint)cbNative & ~WIN32_ALLOC_ALIGN); 155Interop.Sys.Free((byte*)ptr - sizeof(nuint)); 180return Interop.Sys.GetErrNo(); 192Interop.Sys.SetErrNo(error); 202return Interop.Sys.StrError(error);
src\libraries\System.Private.CoreLib\src\System\Runtime\InteropServices\NativeLibrary.cs (1)
257result = Interop.Sys.GetDefaultSearchOrderPseudoHandle();
src\libraries\System.Private.CoreLib\src\System\Runtime\InteropServices\NativeLibrary.Unix.cs (4)
14IntPtr ret = Interop.Sys.LoadLibrary(libraryName); 17string? message = Marshal.PtrToStringUTF8(Interop.Sys.GetLoadLibraryError()); 28Interop.Sys.FreeLibrary(handle); 33return Interop.Sys.GetProcAddress(handle, symbolName);
src\libraries\System.Private.CoreLib\src\System\Runtime\InteropServices\NativeMemory.Unix.cs (8)
47void* result = (adjustedByteCount < byteCount) ? null : Interop.Sys.AlignedAlloc(adjustedAlignment, adjustedByteCount); 69Interop.Sys.AlignedFree(ptr); 110void* result = (adjustedByteCount < byteCount) ? null : Interop.Sys.AlignedRealloc(ptr, adjustedAlignment, adjustedByteCount); 132void* result = Interop.Sys.Malloc((byteCount != 0) ? byteCount : 1); 158result = Interop.Sys.Calloc(elementCount, elementSize); 163result = Interop.Sys.Malloc(1); 186Interop.Sys.Free(ptr); 205void* result = Interop.Sys.Realloc(ptr, (byteCount != 0) ? byteCount : 1);
src\libraries\System.Private.CoreLib\src\System\Runtime\InteropServices\PosixSignalRegistration.Unix.cs (6)
16if (!Interop.Sys.InitializeTerminalAndSignalHandling()) 21Interop.Sys.SetPosixSignalHandler(&OnPosixSignal); 28int signo = Interop.Sys.GetPlatformSignalNumber(signal); 45!Interop.Sys.EnablePosixSignalHandling(signo)) 70Interop.Sys.DisablePosixSignalHandling(token.SigNo); 139Interop.Sys.HandleNonCanceledPosixSignal(signo);
src\libraries\System.Private.CoreLib\src\System\Runtime\InteropServices\RuntimeInformation.Unix.cs (2)
26Interop.OSReleaseFile.GetPrettyName() ?? Interop.Sys.GetUnixVersion(); 39osArch = Interop.Sys.GetOSArchitecture();
src\libraries\System.Private.CoreLib\src\System\Threading\LowLevelMonitor.Unix.cs (7)
14_nativeMonitor = Interop.Sys.LowLevelMonitor_Create(); 28Interop.Sys.LowLevelMonitor_Destroy(_nativeMonitor); 34Interop.Sys.LowLevelMonitor_Acquire(_nativeMonitor); 39Interop.Sys.LowLevelMonitor_Release(_nativeMonitor); 44Interop.Sys.LowLevelMonitor_Wait(_nativeMonitor); 57return Interop.Sys.LowLevelMonitor_TimedWait(_nativeMonitor, timeoutMilliseconds); 62Interop.Sys.LowLevelMonitor_Signal_Release(_nativeMonitor);
src\libraries\System.Private.CoreLib\src\System\Threading\NamedMutex.Unix.cs (14)
269if (Interop.Sys.LowLevelCrossProcessMutex_Init(v) != 0) 271Interop.ErrorInfo errorInfo = Interop.Sys.GetLastErrorInfo(); 296public static nuint SharedDataSize { get; } = (nuint)Interop.Sys.LowLevelCrossProcessMutex_Size(); 301Interop.Sys.LowLevelCrossProcessMutex_GetOwnerProcessAndThreadId(_sharedData, out uint ownerProcessId, out uint ownerThreadId); 308Interop.Sys.LowLevelCrossProcessMutex_SetOwnerProcessAndThreadId( 316get => Interop.Sys.LowLevelCrossProcessMutex_IsAbandoned(_sharedData); 317set => Interop.Sys.LowLevelCrossProcessMutex_SetAbandoned(_sharedData, value); 322Interop.Error lockResult = (Interop.Error)Interop.Sys.LowLevelCrossProcessMutex_Acquire(_sharedData, timeoutMilliseconds); 363Interop.Sys.LowLevelCrossProcessMutex_Release(_sharedData); 373Interop.Sys.LowLevelCrossProcessMutex_SetOwnerProcessAndThreadId( 378Interop.Sys.LowLevelCrossProcessMutex_Release(_sharedData); 388Interop.Sys.LowLevelCrossProcessMutex_Destroy(_sharedData); 453Interop.Sys.FLock(_sharedLockFileHandle, Interop.Sys.LockOperations.LOCK_UN);
src\libraries\System.Private.CoreLib\src\System\Threading\PortableThreadPool.Unix.cs (2)
15private Interop.Sys.ProcessCpuInformation _cpuInfo; 18Interop.Sys.GetCpuUtilization(ref _cpuInfo) / Environment.ProcessorCount;
src\libraries\System.Private.CoreLib\src\System\Threading\Thread.Unix.cs (1)
94internal static int GetCurrentProcessorNumber() => Interop.Sys.SchedGetCpu();
src\libraries\System.Private.CoreLib\src\System\TimeZoneInfo.Unix.NonAndroid.cs (1)
247string? symlinkPath = Interop.Sys.ReadLink(tzFilePath);