コード例 #1
0
        protected override void DisposeInternal()
        {
            _handle.Dispose();
            // _handle.FailCode != success, we cannot delete the file probably, and there's nothing much we can do here.
            // just add to log and continue
            if (_handle.FailCode == FailCodes.Success)
            {
                return;
            }

            if (_logger.IsInfoEnabled)
            {
                _logger.Info($"Unable to dispose handle for {FileName.FullPath} (ignoring). rc={_handle.FailCode}. DeleteOnClose={DeleteOnClose}, "
                             + $"errorCode={PalHelper.GetNativeErrorString(_handle.ErrorNo, "Unable to dispose handle for {FileName.FullPath} (ignoring).", out _)}",
                             new IOException($"Unable to dispose handle for {FileName.FullPath} (ignoring)."));
            }
        }
コード例 #2
0
ファイル: PosixHelper.cs プロジェクト: yitaom2/ravendb
        public static unsafe void AllocateFileSpace(StorageEnvironmentOptions options, int fd, long size, string file)
        {
            bool usingLseek;
            var  result = Syscall.AllocateFileSpace(fd, size, file, out usingLseek);

            if (result == (int)Errno.ENOSPC)
            {
                var diskSpaceResult = DiskSpaceChecker.GetDiskSpaceInfo(file);

                // Use Pal's detailed error string (until PosixHelper will be entirely removed)
                var nativeMsg = PalHelper.GetNativeErrorString(result, "Failed to AllocateFileSpace (PosixHelper)", out _);

                throw new DiskFullException(file, size, diskSpaceResult?.TotalFreeSpace.GetValue(SizeUnit.Bytes), nativeMsg);
            }
            if (result != 0)
            {
                Syscall.ThrowLastError(result, $"posix_fallocate(\"{file}\", {size})");
            }
        }