Ensure UserFileSystemForDebug/Private are updated to 13.1.0

This commit is contained in:
Alex Barney 2021-12-25 01:26:52 -07:00
parent ac378020dc
commit 3940ca9d76
6 changed files with 130 additions and 6 deletions

View File

@ -0,0 +1,31 @@
using System;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
namespace LibHac.Common.FixedArrays;
[StructLayout(LayoutKind.Sequential)]
public struct Array512<T>
{
public const int Length = 512;
private Array256<T> _0;
private Array256<T> _256;
public ref T this[int i] => ref Items[i];
public Span<T> Items
{
[MethodImpl(MethodImplOptions.AggressiveInlining)]
get => SpanHelpers.CreateSpan(ref MemoryMarshal.GetReference(_0.Items), Length);
}
public readonly ReadOnlySpan<T> ItemsRo
{
[MethodImpl(MethodImplOptions.AggressiveInlining)]
get => SpanHelpers.CreateSpan(ref MemoryMarshal.GetReference(_0.ItemsRo), Length);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static implicit operator ReadOnlySpan<T>(in Array512<T> value) => value.ItemsRo;
}

View File

@ -0,0 +1,32 @@
using System;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
namespace LibHac.Common.FixedArrays;
[StructLayout(LayoutKind.Sequential)]
public struct Array769<T>
{
public const int Length = 769;
private Array512<T> _0;
private Array256<T> _512;
private Array1<T> _768;
public ref T this[int i] => ref Items[i];
public Span<T> Items
{
[MethodImpl(MethodImplOptions.AggressiveInlining)]
get => SpanHelpers.CreateSpan(ref MemoryMarshal.GetReference(_0.Items), Length);
}
public readonly ReadOnlySpan<T> ItemsRo
{
[MethodImpl(MethodImplOptions.AggressiveInlining)]
get => SpanHelpers.CreateSpan(ref MemoryMarshal.GetReference(_0.ItemsRo), Length);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static implicit operator ReadOnlySpan<T>(in Array769<T> value) => value.ItemsRo;
}

View File

@ -0,0 +1,30 @@
using LibHac.Common;
using LibHac.Fs.Impl;
namespace LibHac.Fs.Fsa;
/// <summary>
/// Contains functions meant for debug use for interacting with mounted file systems.
/// </summary>
/// <remarks>Based on FS 13.1.0 (nnSdk 13.4.0)</remarks>
public static class UserFileSystemForDebug
{
internal static Result GetFileTimeStampRawForDebug(this FileSystemClientImpl fs, out FileTimeStampRaw timeStamp,
U8Span path)
{
UnsafeHelpers.SkipParamInit(out timeStamp);
Result rc = fs.FindFileSystem(out FileSystemAccessor fileSystem, out U8Span subPath, path);
if (rc.IsFailure()) return rc.Miss();
return fileSystem.GetFileTimeStampRaw(out timeStamp, subPath);
}
public static Result GetFileTimeStampRawForDebug(this FileSystemClient fs, out FileTimeStampRaw timeStamp,
U8Span path)
{
Result rc = fs.Impl.GetFileTimeStampRawForDebug(out timeStamp, path);
fs.Impl.AbortIfNeeded(rc);
return rc;
}
}

View File

@ -6,9 +6,13 @@ using static LibHac.Fs.Impl.AccessLogStrings;
namespace LibHac.Fs.Fsa;
/// <summary>
/// Contains functions meant for internal use for interacting with mounted file systems.
/// </summary>
/// <remarks>Based on FS 13.1.0 (nnSdk 13.4.0)</remarks>
public static class UserFileSystemPrivate
{
public static Result CreateFile(this FileSystemClient fs, U8Span path, long size, CreateFileOptions options)
public static Result CreateFile(this FileSystemClient fs, U8Span path, long size, CreateFileOptions option)
{
Result rc;
U8Span subPath;
@ -37,7 +41,7 @@ public static class UserFileSystemPrivate
if (fs.Impl.IsEnabledAccessLog() && fileSystem.IsEnabledAccessLog())
{
Tick start = fs.Hos.Os.GetSystemTick();
rc = fileSystem.CreateFile(subPath, size, options);
rc = fileSystem.CreateFile(subPath, size, option);
Tick end = fs.Hos.Os.GetSystemTick();
var sb = new U8StringBuilder(logBuffer, true);
@ -48,7 +52,7 @@ public static class UserFileSystemPrivate
}
else
{
rc = fileSystem.CreateFile(subPath, size, options);
rc = fileSystem.CreateFile(subPath, size, option);
}
fs.Impl.AbortIfNeeded(rc);
return rc;
@ -62,7 +66,7 @@ public static class UserFileSystemPrivate
fs.Impl.AbortIfNeeded(rc);
if (rc.IsFailure()) return rc;
rc = fileSystem.GetFreeSpaceSize(out totalSpace, subPath);
rc = fileSystem.GetTotalSpaceSize(out totalSpace, subPath);
fs.Impl.AbortIfNeeded(rc);
return rc;
}
@ -73,7 +77,23 @@ public static class UserFileSystemPrivate
fs.Impl.AbortIfNeeded(rc);
if (rc.IsFailure()) return rc;
rc = fileSystem.QueryEntry(Span<byte>.Empty, ReadOnlySpan<byte>.Empty, QueryId.SetConcatenationFileAttribute, subPath);
rc = fileSystem.QueryEntry(Span<byte>.Empty, ReadOnlySpan<byte>.Empty, QueryId.SetConcatenationFileAttribute,
subPath);
fs.Impl.AbortIfNeeded(rc);
return rc;
}
public static Result QueryUnpreparedFileInformation(this FileSystemClient fs, out UnpreparedFileInformation info,
U8Span path)
{
UnsafeHelpers.SkipParamInit(out info);
Result rc = fs.Impl.FindFileSystem(out FileSystemAccessor fileSystem, out _, path);
fs.Impl.AbortIfNeeded(rc);
if (rc.IsFailure()) return rc;
rc = fileSystem.QueryEntry(SpanHelpers.AsByteSpan(ref info), ReadOnlySpan<byte>.Empty,
QueryId.QueryUnpreparedFileInformation, new U8Span(new[] { (byte)'/' }));
fs.Impl.AbortIfNeeded(rc);
return rc;
}

View File

@ -12,6 +12,11 @@ public struct UnpreparedRangeInfo
public Array20<byte> Reserved;
}
public struct UnpreparedFileInformation
{
public Array769<byte> Path;
}
public struct LazyLoadArguments
{
public int GuideIndex;

View File

@ -14,6 +14,12 @@ public class LazyLoadTypeTests
Assert.Equal(0x40, Unsafe.SizeOf<UnpreparedRangeInfo>());
}
[Fact]
public static void UnpreparedFileInformationSizeIs0x301()
{
Assert.Equal(0x301, Unsafe.SizeOf<UnpreparedFileInformation>());
}
[Fact]
public static void LazyLoadArgumentsSizeIs0x40()
{