mirror of
https://github.com/Thealexbarney/LibHac.git
synced 2024-11-14 10:49:41 +01:00
Flesh out FileSystemProxy functions a bit more including 11.0.0 ones
This commit is contained in:
parent
2f9fbdb818
commit
d0e608775e
8 changed files with 214 additions and 24 deletions
|
@ -42,12 +42,22 @@ namespace LibHac.FsSrv
|
|||
return _serviceImpl.OutputAccessLogToSdCard(textBuffer.Buffer, programInfo.ProgramIdValue, _processId);
|
||||
}
|
||||
|
||||
public Result OutputApplicationInfoAccessLog(in ApplicationInfo applicationInfo)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public Result OutputMultiProgramTagAccessLog()
|
||||
{
|
||||
_serviceImpl.OutputAccessLogToSdCard(MultiProgramTag, _processId).IgnoreResult();
|
||||
return Result.Success;
|
||||
}
|
||||
|
||||
public Result FlushAccessLogOnSdCard()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
private Result GetProgramInfo(out ProgramInfo programInfo)
|
||||
{
|
||||
return _serviceImpl.GetProgramInfo(out programInfo, _processId);
|
||||
|
|
|
@ -48,6 +48,16 @@ namespace LibHac.FsSrv
|
|||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public Result FlushAccessLogSdCardWriter()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public Result FinalizeAccessLogSdCardWriter()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
internal Result GetProgramInfo(out ProgramInfo programInfo, ulong processId)
|
||||
{
|
||||
return _config.ProgramRegistry.GetProgramInfo(out programInfo, processId);
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
using LibHac.Fs;
|
||||
using System;
|
||||
using LibHac.Fs;
|
||||
using LibHac.FsSrv.Impl;
|
||||
using LibHac.FsSrv.Sf;
|
||||
using LibHac.Sf;
|
||||
|
@ -18,6 +19,68 @@ namespace LibHac.FsSrv
|
|||
_processId = processId;
|
||||
}
|
||||
|
||||
private Result GetProgramInfo(out ProgramInfo programInfo)
|
||||
{
|
||||
return GetProgramInfo(out programInfo, _processId);
|
||||
}
|
||||
|
||||
private Result GetProgramInfo(out ProgramInfo programInfo, ulong processId)
|
||||
{
|
||||
return _serviceImpl.GetProgramInfo(out programInfo, processId);
|
||||
}
|
||||
|
||||
private Result CheckCapabilityById(BaseFileSystemId id, ulong processId)
|
||||
{
|
||||
Result rc = GetProgramInfo(out ProgramInfo programInfo, processId);
|
||||
if (rc.IsFailure()) return rc;
|
||||
|
||||
if (id == BaseFileSystemId.TemporaryDirectory)
|
||||
{
|
||||
Accessibility accessibility =
|
||||
programInfo.AccessControl.GetAccessibilityFor(AccessibilityType.MountTemporaryDirectory);
|
||||
|
||||
if (!accessibility.CanRead || !accessibility.CanWrite)
|
||||
return ResultFs.PermissionDenied.Log();
|
||||
}
|
||||
else
|
||||
{
|
||||
Accessibility accessibility =
|
||||
programInfo.AccessControl.GetAccessibilityFor(AccessibilityType.MountAllBaseFileSystem);
|
||||
|
||||
if (!accessibility.CanRead || !accessibility.CanWrite)
|
||||
return ResultFs.PermissionDenied.Log();
|
||||
}
|
||||
|
||||
return Result.Success;
|
||||
}
|
||||
|
||||
public Result OpenBaseFileSystem(out ReferenceCountedDisposable<IFileSystemSf> fileSystem,
|
||||
BaseFileSystemId fileSystemId)
|
||||
{
|
||||
fileSystem = default;
|
||||
|
||||
Result rc = CheckCapabilityById(fileSystemId, _processId);
|
||||
if (rc.IsFailure()) return rc;
|
||||
|
||||
ReferenceCountedDisposable<IFileSystem> fs = null;
|
||||
|
||||
try
|
||||
{
|
||||
// Open the file system
|
||||
rc = _serviceImpl.OpenBaseFileSystem(out fs, fileSystemId);
|
||||
if (rc.IsFailure()) return rc;
|
||||
|
||||
// Create an SF adapter for the file system
|
||||
fileSystem = FileSystemInterfaceAdapter.CreateShared(ref fs);
|
||||
|
||||
return Result.Success;
|
||||
}
|
||||
finally
|
||||
{
|
||||
fs?.Dispose();
|
||||
}
|
||||
}
|
||||
|
||||
public Result OpenBisFileSystem(out ReferenceCountedDisposable<IFileSystemSf> fileSystem, in FspPath rootPath,
|
||||
BisPartitionId partitionId)
|
||||
{
|
||||
|
@ -71,6 +134,11 @@ namespace LibHac.FsSrv
|
|||
}
|
||||
}
|
||||
|
||||
public Result SetBisRootForHost(BisPartitionId partitionId, in FspPath path)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public Result CreatePaddingFile(long size)
|
||||
{
|
||||
// File size must be non-negative
|
||||
|
@ -201,14 +269,14 @@ namespace LibHac.FsSrv
|
|||
return ResultFs.PermissionDenied.Log();
|
||||
|
||||
// Get the base file system ID
|
||||
int id;
|
||||
BaseFileSystemId fileSystemId;
|
||||
switch (directoryId)
|
||||
{
|
||||
case ImageDirectoryId.Nand:
|
||||
id = 0;
|
||||
fileSystemId = BaseFileSystemId.ImageDirectoryNand;
|
||||
break;
|
||||
case ImageDirectoryId.SdCard:
|
||||
id = 1;
|
||||
fileSystemId = BaseFileSystemId.ImageDirectorySdCard;
|
||||
break;
|
||||
default:
|
||||
return ResultFs.InvalidArgument.Log();
|
||||
|
@ -217,7 +285,7 @@ namespace LibHac.FsSrv
|
|||
|
||||
try
|
||||
{
|
||||
rc = _serviceImpl.OpenBaseFileSystem(out fs, id);
|
||||
rc = _serviceImpl.OpenBaseFileSystem(out fs, fileSystemId);
|
||||
if (rc.IsFailure()) return rc;
|
||||
|
||||
// Create an SF adapter for the file system
|
||||
|
@ -248,10 +316,5 @@ namespace LibHac.FsSrv
|
|||
bisWiper = new ReferenceCountedDisposable<IWiper>(wiper);
|
||||
return Result.Success;
|
||||
}
|
||||
|
||||
private Result GetProgramInfo(out ProgramInfo programInfo)
|
||||
{
|
||||
return _serviceImpl.GetProgramInfo(out programInfo, _processId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -35,7 +35,8 @@ namespace LibHac.FsSrv
|
|||
public ProgramRegistryImpl ProgramRegistry;
|
||||
}
|
||||
|
||||
public Result OpenBaseFileSystem(out ReferenceCountedDisposable<IFileSystem> fileSystem, int fileSystemId)
|
||||
public Result OpenBaseFileSystem(out ReferenceCountedDisposable<IFileSystem> fileSystem,
|
||||
BaseFileSystemId fileSystemId)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
|
|
@ -23,6 +23,12 @@ namespace LibHac.FsSrv
|
|||
ProgramRegistry = new ProgramRegistryImpl(Config.ProgramRegistryService);
|
||||
}
|
||||
|
||||
public Result OpenCloudBackupWorkStorageFileSystem(out ReferenceCountedDisposable<IFileSystem> fileSystem,
|
||||
CloudBackupWorkStorageId storageId)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public Result OpenCustomStorageFileSystem(out ReferenceCountedDisposable<IFileSystem> fileSystem,
|
||||
CustomStorageId storageId)
|
||||
{
|
||||
|
|
|
@ -443,7 +443,7 @@ namespace LibHac.FsSrv
|
|||
public Result OpenBaseFileSystem(out ReferenceCountedDisposable<IFileSystemSf> fileSystem,
|
||||
BaseFileSystemId fileSystemId)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
return GetBaseFileSystemService().OpenBaseFileSystem(out fileSystem, fileSystemId);
|
||||
}
|
||||
|
||||
public Result OpenBisFileSystem(out ReferenceCountedDisposable<IFileSystemSf> fileSystem, in FspPath rootPath,
|
||||
|
@ -697,31 +697,56 @@ namespace LibHac.FsSrv
|
|||
|
||||
public Result OpenSaveDataTransferManager(out ReferenceCountedDisposable<ISaveDataTransferManager> manager)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
manager = default;
|
||||
|
||||
Result rc = GetSaveDataFileSystemService(out SaveDataFileSystemService saveFsService);
|
||||
if (rc.IsFailure()) return rc;
|
||||
|
||||
return saveFsService.OpenSaveDataTransferManager(out manager);
|
||||
}
|
||||
|
||||
public Result OpenSaveDataTransferManagerVersion2(
|
||||
out ReferenceCountedDisposable<ISaveDataTransferManagerWithDivision> manager)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
manager = default;
|
||||
|
||||
Result rc = GetSaveDataFileSystemService(out SaveDataFileSystemService saveFsService);
|
||||
if (rc.IsFailure()) return rc;
|
||||
|
||||
return saveFsService.OpenSaveDataTransferManagerVersion2(out manager);
|
||||
}
|
||||
|
||||
public Result OpenSaveDataTransferManagerForSaveDataRepair(
|
||||
out ReferenceCountedDisposable<ISaveDataTransferManagerForSaveDataRepair> manager)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
manager = default;
|
||||
|
||||
Result rc = GetSaveDataFileSystemService(out SaveDataFileSystemService saveFsService);
|
||||
if (rc.IsFailure()) return rc;
|
||||
|
||||
return saveFsService.OpenSaveDataTransferManagerForSaveDataRepair(out manager);
|
||||
}
|
||||
|
||||
public Result OpenSaveDataTransferManagerForRepair(
|
||||
out ReferenceCountedDisposable<ISaveDataTransferManagerForRepair> manager)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
manager = default;
|
||||
|
||||
Result rc = GetSaveDataFileSystemService(out SaveDataFileSystemService saveFsService);
|
||||
if (rc.IsFailure()) return rc;
|
||||
|
||||
return saveFsService.OpenSaveDataTransferManagerForRepair(out manager);
|
||||
}
|
||||
|
||||
public Result OpenSaveDataTransferProhibiter(
|
||||
out ReferenceCountedDisposable<ISaveDataTransferProhibiter> prohibiter, Ncm.ApplicationId applicationId)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
prohibiter = default;
|
||||
|
||||
Result rc = GetSaveDataFileSystemService(out SaveDataFileSystemService saveFsService);
|
||||
if (rc.IsFailure()) return rc;
|
||||
|
||||
return saveFsService.OpenSaveDataTransferProhibiter(out prohibiter, applicationId);
|
||||
}
|
||||
|
||||
public Result ListAccessibleSaveDataOwnerId(out int readCount, OutBuffer idBuffer, ProgramId programId,
|
||||
|
@ -787,7 +812,35 @@ namespace LibHac.FsSrv
|
|||
public Result OpenCloudBackupWorkStorageFileSystem(out ReferenceCountedDisposable<IFileSystemSf> fileSystem,
|
||||
CloudBackupWorkStorageId storageId)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
fileSystem = default;
|
||||
var storageFlag = StorageType.NonGameCard;
|
||||
using var scopedLayoutType = new ScopedStorageLayoutTypeSetter(storageFlag);
|
||||
|
||||
Result rc = GetProgramInfo(out ProgramInfo programInfo);
|
||||
if (rc.IsFailure()) return rc;
|
||||
|
||||
Accessibility accessibility =
|
||||
programInfo.AccessControl.GetAccessibilityFor(AccessibilityType.MountCloudBackupWorkStorage);
|
||||
|
||||
if (!accessibility.CanRead || !accessibility.CanWrite)
|
||||
return ResultFs.PermissionDenied.Log();
|
||||
|
||||
ReferenceCountedDisposable<IFileSystem> tempFs = null;
|
||||
try
|
||||
{
|
||||
rc = FsProxyCore.OpenCloudBackupWorkStorageFileSystem(out tempFs, storageId);
|
||||
if (rc.IsFailure()) return rc;
|
||||
|
||||
tempFs = StorageLayoutTypeSetFileSystem.CreateShared(ref tempFs, storageFlag);
|
||||
tempFs = AsynchronousAccessFileSystem.CreateShared(ref tempFs);
|
||||
fileSystem = FileSystemInterfaceAdapter.CreateShared(ref tempFs);
|
||||
|
||||
return Result.Success;
|
||||
}
|
||||
finally
|
||||
{
|
||||
tempFs?.Dispose();
|
||||
}
|
||||
}
|
||||
|
||||
public Result OpenCustomStorageFileSystem(out ReferenceCountedDisposable<IFileSystemSf> fileSystem, CustomStorageId storageId)
|
||||
|
@ -933,7 +986,7 @@ namespace LibHac.FsSrv
|
|||
|
||||
public Result SetBisRootForHost(BisPartitionId partitionId, in FspPath path)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
return GetBaseFileSystemService().SetBisRootForHost(partitionId, in path);
|
||||
}
|
||||
|
||||
public Result VerifySaveDataFileSystemBySaveDataSpaceId(SaveDataSpaceId spaceId, ulong saveDataId,
|
||||
|
@ -1015,12 +1068,12 @@ namespace LibHac.FsSrv
|
|||
|
||||
public Result OutputApplicationInfoAccessLog(in ApplicationInfo applicationInfo)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
return GetAccessLogService().OutputApplicationInfoAccessLog(in applicationInfo);
|
||||
}
|
||||
|
||||
public Result FlushAccessLogOnSdCard()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
return GetAccessLogService().FlushAccessLogOnSdCard();
|
||||
}
|
||||
|
||||
public Result RegisterUpdatePartition()
|
||||
|
@ -1055,7 +1108,10 @@ namespace LibHac.FsSrv
|
|||
|
||||
public Result OverrideSaveDataTransferTokenSignVerificationKey(InBuffer key)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
Result rc = GetSaveDataFileSystemService(out SaveDataFileSystemService saveFsService);
|
||||
if (rc.IsFailure()) return rc;
|
||||
|
||||
return saveFsService.OverrideSaveDataTransferTokenSignVerificationKey(key);
|
||||
}
|
||||
|
||||
public Result SetSdCardAccessibility(bool isAccessible)
|
||||
|
|
|
@ -396,7 +396,7 @@ namespace LibHac.FsSrv.Impl
|
|||
return new Accessibility(accessBits.CanMountContentStorageRead(), accessBits.CanMountContentStorageWrite());
|
||||
case AccessibilityType.MountImageAndVideoStorage:
|
||||
return new Accessibility(accessBits.CanMountImageAndVideoStorageRead(), accessBits.CanMountImageAndVideoStorageWrite());
|
||||
case AccessibilityType.MountCloudBackupWorkStorageRead:
|
||||
case AccessibilityType.MountCloudBackupWorkStorage:
|
||||
return new Accessibility(accessBits.CanMountCloudBackupWorkStorageRead(), accessBits.CanMountCloudBackupWorkStorageWrite());
|
||||
case AccessibilityType.MountCustomStorage:
|
||||
return new Accessibility(accessBits.CanMountCustomStorage0Read(), accessBits.CanMountCustomStorage0Write());
|
||||
|
@ -468,6 +468,10 @@ namespace LibHac.FsSrv.Impl
|
|||
return new Accessibility(accessBits.CanMountRegisteredUpdatePartitionRead() && FsServer.IsDebugMode, false);
|
||||
case AccessibilityType.MountSaveDataInternalStorage:
|
||||
return new Accessibility(accessBits.CanOpenSaveDataInternalStorageRead(), accessBits.CanOpenSaveDataInternalStorageWrite());
|
||||
case AccessibilityType.MountTemporaryDirectory:
|
||||
return new Accessibility(accessBits.CanMountTemporaryDirectoryRead(), accessBits.CanMountTemporaryDirectoryWrite());
|
||||
case AccessibilityType.MountAllBaseFileSystem:
|
||||
return new Accessibility(accessBits.CanMountAllBaseFileSystemRead(), accessBits.CanMountAllBaseFileSystemWrite());
|
||||
case AccessibilityType.NotMount:
|
||||
return new Accessibility(false, false);
|
||||
default:
|
||||
|
@ -611,6 +615,8 @@ namespace LibHac.FsSrv.Impl
|
|||
public bool CanInvalidateBisCache() => Has(Bits.BisAllRaw);
|
||||
public bool CanIsAccessFailureDetected() => Has(Bits.AccessFailureResolution);
|
||||
public bool CanListAccessibleSaveDataOwnerId() => Has(Bits.SaveDataTransferVersion2 | Bits.SaveDataTransfer | Bits.CreateSaveData);
|
||||
public bool CanMountAllBaseFileSystemRead() => Has(Bits.None);
|
||||
public bool CanMountAllBaseFileSystemWrite() => Has(Bits.None);
|
||||
public bool CanMountApplicationPackageRead() => Has(Bits.ContentManager | Bits.ApplicationInfo);
|
||||
public bool CanMountBisCalibrationFileRead() => Has(Bits.BisAllRaw | Bits.Calibration);
|
||||
public bool CanMountBisCalibrationFileWrite() => Has(Bits.BisAllRaw | Bits.Calibration);
|
||||
|
@ -654,6 +660,8 @@ namespace LibHac.FsSrv.Impl
|
|||
public bool CanMountSystemDataPrivateRead() => Has(Bits.SystemData | Bits.SystemSaveData);
|
||||
public bool CanMountSystemSaveDataRead() => Has(Bits.SaveDataBackUp | Bits.SystemSaveData);
|
||||
public bool CanMountSystemSaveDataWrite() => Has(Bits.SaveDataBackUp | Bits.SystemSaveData);
|
||||
public bool CanMountTemporaryDirectoryRead() => Has(Bits.Debug);
|
||||
public bool CanMountTemporaryDirectoryWrite() => Has(Bits.Debug);
|
||||
public bool CanNotifySystemDataUpdateEvent() => Has(Bits.SystemUpdate);
|
||||
public bool CanOpenAccessFailureDetectionEventNotifier() => Has(Bits.AccessFailureResolution);
|
||||
public bool CanOpenBisPartitionBootConfigAndPackage2Part1Read() => Has(Bits.SystemUpdate | Bits.BisAllRaw);
|
||||
|
@ -850,7 +858,7 @@ namespace LibHac.FsSrv.Impl
|
|||
MountSaveDataStorage,
|
||||
MountContentStorage,
|
||||
MountImageAndVideoStorage,
|
||||
MountCloudBackupWorkStorageRead,
|
||||
MountCloudBackupWorkStorage,
|
||||
MountCustomStorage,
|
||||
MountBisCalibrationFile,
|
||||
MountBisSafeMode,
|
||||
|
@ -886,6 +894,8 @@ namespace LibHac.FsSrv.Impl
|
|||
MountHost,
|
||||
MountRegisteredUpdatePartition,
|
||||
MountSaveDataInternalStorage,
|
||||
MountTemporaryDirectory,
|
||||
MountAllBaseFileSystem,
|
||||
NotMount
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1573,6 +1573,35 @@ namespace LibHac.FsSrv
|
|||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public Result OpenSaveDataTransferManager(out ReferenceCountedDisposable<ISaveDataTransferManager> manager)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public Result OpenSaveDataTransferManagerVersion2(
|
||||
out ReferenceCountedDisposable<ISaveDataTransferManagerWithDivision> manager)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public Result OpenSaveDataTransferManagerForSaveDataRepair(
|
||||
out ReferenceCountedDisposable<ISaveDataTransferManagerForSaveDataRepair> manager)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public Result OpenSaveDataTransferManagerForRepair(
|
||||
out ReferenceCountedDisposable<ISaveDataTransferManagerForRepair> manager)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public Result OpenSaveDataTransferProhibiter(
|
||||
out ReferenceCountedDisposable<ISaveDataTransferProhibiter> prohibiter, Ncm.ApplicationId applicationId)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public Result OpenSaveDataMover(out ReferenceCountedDisposable<ISaveDataMover> saveMover,
|
||||
SaveDataSpaceId sourceSpaceId, SaveDataSpaceId destinationSpaceId, NativeHandle workBufferHandle,
|
||||
ulong workBufferSize)
|
||||
|
@ -1814,6 +1843,11 @@ namespace LibHac.FsSrv
|
|||
}
|
||||
}
|
||||
|
||||
public Result OverrideSaveDataTransferTokenSignVerificationKey(InBuffer key)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public Result SetSdCardAccessibility(bool isAccessible)
|
||||
{
|
||||
Result rc = GetProgramInfo(out ProgramInfo programInfo);
|
||||
|
|
Loading…
Reference in a new issue