Update to LibHac v0.14.3 (#2925)

* Update to LibHac v0.14.3

* Fix loading NCAs that don't have a data partition
This commit is contained in:
Alex Barney 2021-12-23 09:55:50 -07:00 committed by GitHub
parent cb43cc7e32
commit aa932a6df1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
33 changed files with 554 additions and 406 deletions

View file

@ -1,21 +1,22 @@
using LibHac;
using LibHac.Common;
using LibHac.Fs;
using LibHac.FsSrv.Sf;
using Path = LibHac.FsSrv.Sf.Path;
namespace Ryujinx.HLE.HOS.Services.Fs.FileSystemProxy
{
class IFileSystem : DisposableIpcService
{
private ReferenceCountedDisposable<LibHac.FsSrv.Sf.IFileSystem> _fileSystem;
private SharedRef<LibHac.FsSrv.Sf.IFileSystem> _fileSystem;
public IFileSystem(ReferenceCountedDisposable<LibHac.FsSrv.Sf.IFileSystem> provider)
public IFileSystem(ref SharedRef<LibHac.FsSrv.Sf.IFileSystem> provider)
{
_fileSystem = provider;
_fileSystem = SharedRef<LibHac.FsSrv.Sf.IFileSystem>.CreateMove(ref provider);
}
public ReferenceCountedDisposable<LibHac.FsSrv.Sf.IFileSystem> GetBaseFileSystem()
public SharedRef<LibHac.FsSrv.Sf.IFileSystem> GetBaseFileSystem()
{
return _fileSystem;
return SharedRef<LibHac.FsSrv.Sf.IFileSystem>.CreateCopy(in _fileSystem);
}
[CommandHipc(0)]
@ -29,7 +30,7 @@ namespace Ryujinx.HLE.HOS.Services.Fs.FileSystemProxy
long size = context.RequestData.ReadInt64();
return (ResultCode)_fileSystem.Target.CreateFile(in name, size, createOption).Value;
return (ResultCode)_fileSystem.Get.CreateFile(in name, size, createOption).Value;
}
[CommandHipc(1)]
@ -38,7 +39,7 @@ namespace Ryujinx.HLE.HOS.Services.Fs.FileSystemProxy
{
ref readonly Path name = ref FileSystemProxyHelper.GetSfPath(context);
return (ResultCode)_fileSystem.Target.DeleteFile(in name).Value;
return (ResultCode)_fileSystem.Get.DeleteFile(in name).Value;
}
[CommandHipc(2)]
@ -47,7 +48,7 @@ namespace Ryujinx.HLE.HOS.Services.Fs.FileSystemProxy
{
ref readonly Path name = ref FileSystemProxyHelper.GetSfPath(context);
return (ResultCode)_fileSystem.Target.CreateDirectory(in name).Value;
return (ResultCode)_fileSystem.Get.CreateDirectory(in name).Value;
}
[CommandHipc(3)]
@ -56,7 +57,7 @@ namespace Ryujinx.HLE.HOS.Services.Fs.FileSystemProxy
{
ref readonly Path name = ref FileSystemProxyHelper.GetSfPath(context);
return (ResultCode)_fileSystem.Target.DeleteDirectory(in name).Value;
return (ResultCode)_fileSystem.Get.DeleteDirectory(in name).Value;
}
[CommandHipc(4)]
@ -65,7 +66,7 @@ namespace Ryujinx.HLE.HOS.Services.Fs.FileSystemProxy
{
ref readonly Path name = ref FileSystemProxyHelper.GetSfPath(context);
return (ResultCode)_fileSystem.Target.DeleteDirectoryRecursively(in name).Value;
return (ResultCode)_fileSystem.Get.DeleteDirectoryRecursively(in name).Value;
}
[CommandHipc(5)]
@ -75,7 +76,7 @@ namespace Ryujinx.HLE.HOS.Services.Fs.FileSystemProxy
ref readonly Path currentName = ref FileSystemProxyHelper.GetSfPath(context, index: 0);
ref readonly Path newName = ref FileSystemProxyHelper.GetSfPath(context, index: 1);
return (ResultCode)_fileSystem.Target.RenameFile(in currentName, in newName).Value;
return (ResultCode)_fileSystem.Get.RenameFile(in currentName, in newName).Value;
}
[CommandHipc(6)]
@ -85,7 +86,7 @@ namespace Ryujinx.HLE.HOS.Services.Fs.FileSystemProxy
ref readonly Path currentName = ref FileSystemProxyHelper.GetSfPath(context, index: 0);
ref readonly Path newName = ref FileSystemProxyHelper.GetSfPath(context, index: 1);
return (ResultCode)_fileSystem.Target.RenameDirectory(in currentName, in newName).Value;
return (ResultCode)_fileSystem.Get.RenameDirectory(in currentName, in newName).Value;
}
[CommandHipc(7)]
@ -94,7 +95,7 @@ namespace Ryujinx.HLE.HOS.Services.Fs.FileSystemProxy
{
ref readonly Path name = ref FileSystemProxyHelper.GetSfPath(context);
Result result = _fileSystem.Target.GetEntryType(out uint entryType, in name);
Result result = _fileSystem.Get.GetEntryType(out uint entryType, in name);
context.ResponseData.Write((int)entryType);
@ -108,12 +109,13 @@ namespace Ryujinx.HLE.HOS.Services.Fs.FileSystemProxy
uint mode = context.RequestData.ReadUInt32();
ref readonly Path name = ref FileSystemProxyHelper.GetSfPath(context);
using var file = new SharedRef<LibHac.FsSrv.Sf.IFile>();
Result result = _fileSystem.Target.OpenFile(out ReferenceCountedDisposable<LibHac.FsSrv.Sf.IFile> file, in name, mode);
Result result = _fileSystem.Get.OpenFile(ref file.Ref(), in name, mode);
if (result.IsSuccess())
{
IFile fileInterface = new IFile(file);
IFile fileInterface = new IFile(ref file.Ref());
MakeObject(context, fileInterface);
}
@ -128,12 +130,13 @@ namespace Ryujinx.HLE.HOS.Services.Fs.FileSystemProxy
uint mode = context.RequestData.ReadUInt32();
ref readonly Path name = ref FileSystemProxyHelper.GetSfPath(context);
using var dir = new SharedRef<LibHac.FsSrv.Sf.IDirectory>();
Result result = _fileSystem.Target.OpenDirectory(out ReferenceCountedDisposable<LibHac.FsSrv.Sf.IDirectory> dir, name, mode);
Result result = _fileSystem.Get.OpenDirectory(ref dir.Ref(), name, mode);
if (result.IsSuccess())
{
IDirectory dirInterface = new IDirectory(dir);
IDirectory dirInterface = new IDirectory(ref dir.Ref());
MakeObject(context, dirInterface);
}
@ -145,7 +148,7 @@ namespace Ryujinx.HLE.HOS.Services.Fs.FileSystemProxy
// Commit()
public ResultCode Commit(ServiceCtx context)
{
return (ResultCode)_fileSystem.Target.Commit().Value;
return (ResultCode)_fileSystem.Get.Commit().Value;
}
[CommandHipc(11)]
@ -154,7 +157,7 @@ namespace Ryujinx.HLE.HOS.Services.Fs.FileSystemProxy
{
ref readonly Path name = ref FileSystemProxyHelper.GetSfPath(context);
Result result = _fileSystem.Target.GetFreeSpaceSize(out long size, in name);
Result result = _fileSystem.Get.GetFreeSpaceSize(out long size, in name);
context.ResponseData.Write(size);
@ -167,7 +170,7 @@ namespace Ryujinx.HLE.HOS.Services.Fs.FileSystemProxy
{
ref readonly Path name = ref FileSystemProxyHelper.GetSfPath(context);
Result result = _fileSystem.Target.GetTotalSpaceSize(out long size, in name);
Result result = _fileSystem.Get.GetTotalSpaceSize(out long size, in name);
context.ResponseData.Write(size);
@ -180,7 +183,7 @@ namespace Ryujinx.HLE.HOS.Services.Fs.FileSystemProxy
{
ref readonly Path name = ref FileSystemProxyHelper.GetSfPath(context);
return (ResultCode)_fileSystem.Target.CleanDirectoryRecursively(in name).Value;
return (ResultCode)_fileSystem.Get.CleanDirectoryRecursively(in name).Value;
}
[CommandHipc(14)]
@ -189,7 +192,7 @@ namespace Ryujinx.HLE.HOS.Services.Fs.FileSystemProxy
{
ref readonly Path name = ref FileSystemProxyHelper.GetSfPath(context);
Result result = _fileSystem.Target.GetFileTimeStampRaw(out FileTimeStampRaw timestamp, in name);
Result result = _fileSystem.Get.GetFileTimeStampRaw(out FileTimeStampRaw timestamp, in name);
context.ResponseData.Write(timestamp.Created);
context.ResponseData.Write(timestamp.Modified);
@ -209,7 +212,7 @@ namespace Ryujinx.HLE.HOS.Services.Fs.FileSystemProxy
{
if (isDisposing)
{
_fileSystem?.Dispose();
_fileSystem.Destroy();
}
}
}