IFileSystemProxy.cs 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562
  1. using LibHac;
  2. using LibHac.Fs;
  3. using LibHac.FsSrv;
  4. using LibHac.FsSystem;
  5. using LibHac.FsSystem.NcaUtils;
  6. using LibHac.Ncm;
  7. using Ryujinx.Common;
  8. using Ryujinx.Common.Logging;
  9. using Ryujinx.Cpu;
  10. using Ryujinx.HLE.HOS.Services.Fs.FileSystemProxy;
  11. using System.IO;
  12. using static Ryujinx.HLE.Utilities.StringUtils;
  13. using StorageId = Ryujinx.HLE.FileSystem.StorageId;
  14. namespace Ryujinx.HLE.HOS.Services.Fs
  15. {
  16. [Service("fsp-srv")]
  17. class IFileSystemProxy : IpcService
  18. {
  19. private LibHac.FsSrv.IFileSystemProxy _baseFileSystemProxy;
  20. public IFileSystemProxy(ServiceCtx context)
  21. {
  22. _baseFileSystemProxy = context.Device.FileSystem.FsServer.CreateFileSystemProxyService();
  23. }
  24. [CommandHipc(1)]
  25. // Initialize(u64, pid)
  26. public ResultCode Initialize(ServiceCtx context)
  27. {
  28. return ResultCode.Success;
  29. }
  30. [CommandHipc(8)]
  31. // OpenFileSystemWithId(nn::fssrv::sf::FileSystemType filesystem_type, nn::ApplicationId tid, buffer<bytes<0x301>, 0x19, 0x301> path)
  32. // -> object<nn::fssrv::sf::IFileSystem> contentFs
  33. public ResultCode OpenFileSystemWithId(ServiceCtx context)
  34. {
  35. FileSystemType fileSystemType = (FileSystemType)context.RequestData.ReadInt32();
  36. ulong titleId = context.RequestData.ReadUInt64();
  37. string switchPath = ReadUtf8String(context);
  38. string fullPath = context.Device.FileSystem.SwitchPathToSystemPath(switchPath);
  39. if (!File.Exists(fullPath))
  40. {
  41. if (fullPath.Contains("."))
  42. {
  43. ResultCode result = FileSystemProxyHelper.OpenFileSystemFromInternalFile(context, fullPath, out FileSystemProxy.IFileSystem fileSystem);
  44. if (result == ResultCode.Success)
  45. {
  46. MakeObject(context, fileSystem);
  47. }
  48. return result;
  49. }
  50. return ResultCode.PathDoesNotExist;
  51. }
  52. FileStream fileStream = new FileStream(fullPath, FileMode.Open, FileAccess.Read);
  53. string extension = Path.GetExtension(fullPath);
  54. if (extension == ".nca")
  55. {
  56. ResultCode result = FileSystemProxyHelper.OpenNcaFs(context, fullPath, fileStream.AsStorage(), out FileSystemProxy.IFileSystem fileSystem);
  57. if (result == ResultCode.Success)
  58. {
  59. MakeObject(context, fileSystem);
  60. }
  61. return result;
  62. }
  63. else if (extension == ".nsp")
  64. {
  65. ResultCode result = FileSystemProxyHelper.OpenNsp(context, fullPath, out FileSystemProxy.IFileSystem fileSystem);
  66. if (result == ResultCode.Success)
  67. {
  68. MakeObject(context, fileSystem);
  69. }
  70. return result;
  71. }
  72. return ResultCode.InvalidInput;
  73. }
  74. [CommandHipc(11)]
  75. // OpenBisFileSystem(nn::fssrv::sf::Partition partitionID, buffer<bytes<0x301>, 0x19, 0x301>) -> object<nn::fssrv::sf::IFileSystem> Bis
  76. public ResultCode OpenBisFileSystem(ServiceCtx context)
  77. {
  78. BisPartitionId bisPartitionId = (BisPartitionId)context.RequestData.ReadInt32();
  79. Result rc = FileSystemProxyHelper.ReadFsPath(out FsPath path, context);
  80. if (rc.IsFailure()) return (ResultCode)rc.Value;
  81. rc = _baseFileSystemProxy.OpenBisFileSystem(out LibHac.Fs.Fsa.IFileSystem fileSystem, ref path, bisPartitionId);
  82. if (rc.IsFailure()) return (ResultCode)rc.Value;
  83. MakeObject(context, new FileSystemProxy.IFileSystem(fileSystem));
  84. return ResultCode.Success;
  85. }
  86. [CommandHipc(18)]
  87. // OpenSdCardFileSystem() -> object<nn::fssrv::sf::IFileSystem>
  88. public ResultCode OpenSdCardFileSystem(ServiceCtx context)
  89. {
  90. Result rc = _baseFileSystemProxy.OpenSdCardFileSystem(out LibHac.Fs.Fsa.IFileSystem fileSystem);
  91. if (rc.IsFailure()) return (ResultCode)rc.Value;
  92. MakeObject(context, new FileSystemProxy.IFileSystem(fileSystem));
  93. return ResultCode.Success;
  94. }
  95. [CommandHipc(21)]
  96. public ResultCode DeleteSaveDataFileSystem(ServiceCtx context)
  97. {
  98. ulong saveDataId = context.RequestData.ReadUInt64();
  99. Result result = _baseFileSystemProxy.DeleteSaveDataFileSystem(saveDataId);
  100. return (ResultCode)result.Value;
  101. }
  102. [CommandHipc(22)]
  103. public ResultCode CreateSaveDataFileSystem(ServiceCtx context)
  104. {
  105. SaveDataAttribute attribute = context.RequestData.ReadStruct<SaveDataAttribute>();
  106. SaveDataCreationInfo creationInfo = context.RequestData.ReadStruct<SaveDataCreationInfo>();
  107. SaveMetaCreateInfo metaCreateInfo = context.RequestData.ReadStruct<SaveMetaCreateInfo>();
  108. // TODO: There's currently no program registry for FS to reference.
  109. // Workaround that by setting the application ID and owner ID if they're not already set
  110. if (attribute.ProgramId == ProgramId.InvalidId)
  111. {
  112. attribute.ProgramId = new ProgramId(context.Device.Application.TitleId);
  113. }
  114. Logger.Info?.Print(LogClass.ServiceFs, $"Creating save with title ID {attribute.ProgramId.Value:x16}");
  115. Result result = _baseFileSystemProxy.CreateSaveDataFileSystem(ref attribute, ref creationInfo, ref metaCreateInfo);
  116. return (ResultCode)result.Value;
  117. }
  118. [CommandHipc(23)]
  119. public ResultCode CreateSaveDataFileSystemBySystemSaveDataId(ServiceCtx context)
  120. {
  121. SaveDataAttribute attribute = context.RequestData.ReadStruct<SaveDataAttribute>();
  122. SaveDataCreationInfo creationInfo = context.RequestData.ReadStruct<SaveDataCreationInfo>();
  123. Result result = _baseFileSystemProxy.CreateSaveDataFileSystemBySystemSaveDataId(ref attribute, ref creationInfo);
  124. return (ResultCode)result.Value;
  125. }
  126. [CommandHipc(25)]
  127. public ResultCode DeleteSaveDataFileSystemBySaveDataSpaceId(ServiceCtx context)
  128. {
  129. SaveDataSpaceId spaceId = (SaveDataSpaceId)context.RequestData.ReadInt64();
  130. ulong saveDataId = context.RequestData.ReadUInt64();
  131. Result result = _baseFileSystemProxy.DeleteSaveDataFileSystemBySaveDataSpaceId(spaceId, saveDataId);
  132. return (ResultCode)result.Value;
  133. }
  134. [CommandHipc(28)]
  135. public ResultCode DeleteSaveDataFileSystemBySaveDataAttribute(ServiceCtx context)
  136. {
  137. SaveDataSpaceId spaceId = (SaveDataSpaceId)context.RequestData.ReadInt64();
  138. SaveDataAttribute attribute = context.RequestData.ReadStruct<SaveDataAttribute>();
  139. Result result = _baseFileSystemProxy.DeleteSaveDataFileSystemBySaveDataAttribute(spaceId, ref attribute);
  140. return (ResultCode)result.Value;
  141. }
  142. [CommandHipc(30)]
  143. // OpenGameCardStorage(u32, u32) -> object<nn::fssrv::sf::IStorage>
  144. public ResultCode OpenGameCardStorage(ServiceCtx context)
  145. {
  146. GameCardHandle handle = new GameCardHandle(context.RequestData.ReadInt32());
  147. GameCardPartitionRaw partitionId = (GameCardPartitionRaw)context.RequestData.ReadInt32();
  148. Result result = _baseFileSystemProxy.OpenGameCardStorage(out LibHac.Fs.IStorage storage, handle, partitionId);
  149. if (result.IsSuccess())
  150. {
  151. MakeObject(context, new FileSystemProxy.IStorage(storage));
  152. }
  153. return (ResultCode)result.Value;
  154. }
  155. [CommandHipc(35)]
  156. public ResultCode CreateSaveDataFileSystemWithHashSalt(ServiceCtx context)
  157. {
  158. SaveDataAttribute attribute = context.RequestData.ReadStruct<SaveDataAttribute>();
  159. SaveDataCreationInfo creationInfo = context.RequestData.ReadStruct<SaveDataCreationInfo>();
  160. SaveMetaCreateInfo metaCreateInfo = context.RequestData.ReadStruct<SaveMetaCreateInfo>();
  161. HashSalt hashSalt = context.RequestData.ReadStruct<HashSalt>();
  162. // TODO: There's currently no program registry for FS to reference.
  163. // Workaround that by setting the application ID and owner ID if they're not already set
  164. if (attribute.ProgramId == ProgramId.InvalidId)
  165. {
  166. attribute.ProgramId = new ProgramId(context.Device.Application.TitleId);
  167. }
  168. Result result = _baseFileSystemProxy.CreateSaveDataFileSystemWithHashSalt(ref attribute, ref creationInfo, ref metaCreateInfo, ref hashSalt);
  169. return (ResultCode)result.Value;
  170. }
  171. [CommandHipc(51)]
  172. // OpenSaveDataFileSystem(u8 save_data_space_id, nn::fssrv::sf::SaveStruct saveStruct) -> object<nn::fssrv::sf::IFileSystem> saveDataFs
  173. public ResultCode OpenSaveDataFileSystem(ServiceCtx context)
  174. {
  175. SaveDataSpaceId spaceId = (SaveDataSpaceId)context.RequestData.ReadInt64();
  176. SaveDataAttribute attribute = context.RequestData.ReadStruct<SaveDataAttribute>();
  177. // TODO: There's currently no program registry for FS to reference.
  178. // Workaround that by setting the application ID if it's not already set
  179. if (attribute.ProgramId == ProgramId.InvalidId)
  180. {
  181. attribute.ProgramId = new ProgramId(context.Device.Application.TitleId);
  182. }
  183. Result result = _baseFileSystemProxy.OpenSaveDataFileSystem(out LibHac.Fs.Fsa.IFileSystem fileSystem, spaceId, ref attribute);
  184. if (result.IsSuccess())
  185. {
  186. MakeObject(context, new FileSystemProxy.IFileSystem(fileSystem));
  187. }
  188. return (ResultCode)result.Value;
  189. }
  190. [CommandHipc(52)]
  191. // OpenSaveDataFileSystemBySystemSaveDataId(u8 save_data_space_id, nn::fssrv::sf::SaveStruct saveStruct) -> object<nn::fssrv::sf::IFileSystem> systemSaveDataFs
  192. public ResultCode OpenSaveDataFileSystemBySystemSaveDataId(ServiceCtx context)
  193. {
  194. SaveDataSpaceId spaceId = (SaveDataSpaceId)context.RequestData.ReadInt64();
  195. SaveDataAttribute attribute = context.RequestData.ReadStruct<SaveDataAttribute>();
  196. Result result = _baseFileSystemProxy.OpenSaveDataFileSystemBySystemSaveDataId(out LibHac.Fs.Fsa.IFileSystem fileSystem, spaceId, ref attribute);
  197. if (result.IsSuccess())
  198. {
  199. MakeObject(context, new FileSystemProxy.IFileSystem(fileSystem));
  200. }
  201. return (ResultCode)result.Value;
  202. }
  203. [CommandHipc(53)]
  204. // OpenReadOnlySaveDataFileSystem(u8 save_data_space_id, nn::fssrv::sf::SaveStruct save_struct) -> object<nn::fssrv::sf::IFileSystem>
  205. public ResultCode OpenReadOnlySaveDataFileSystem(ServiceCtx context)
  206. {
  207. SaveDataSpaceId spaceId = (SaveDataSpaceId)context.RequestData.ReadInt64();
  208. SaveDataAttribute attribute = context.RequestData.ReadStruct<SaveDataAttribute>();
  209. // TODO: There's currently no program registry for FS to reference.
  210. // Workaround that by setting the application ID if it's not already set
  211. if (attribute.ProgramId == ProgramId.InvalidId)
  212. {
  213. attribute.ProgramId = new ProgramId(context.Device.Application.TitleId);
  214. }
  215. Result result = _baseFileSystemProxy.OpenReadOnlySaveDataFileSystem(out LibHac.Fs.Fsa.IFileSystem fileSystem, spaceId, ref attribute);
  216. if (result.IsSuccess())
  217. {
  218. MakeObject(context, new FileSystemProxy.IFileSystem(fileSystem));
  219. }
  220. return (ResultCode)result.Value;
  221. }
  222. [CommandHipc(60)]
  223. public ResultCode OpenSaveDataInfoReader(ServiceCtx context)
  224. {
  225. Result result = _baseFileSystemProxy.OpenSaveDataInfoReader(out ReferenceCountedDisposable<LibHac.FsSrv.ISaveDataInfoReader> infoReader);
  226. if (result.IsSuccess())
  227. {
  228. MakeObject(context, new ISaveDataInfoReader(infoReader));
  229. }
  230. return (ResultCode)result.Value;
  231. }
  232. [CommandHipc(61)]
  233. public ResultCode OpenSaveDataInfoReaderBySaveDataSpaceId(ServiceCtx context)
  234. {
  235. SaveDataSpaceId spaceId = (SaveDataSpaceId)context.RequestData.ReadByte();
  236. Result result = _baseFileSystemProxy.OpenSaveDataInfoReaderBySaveDataSpaceId(out ReferenceCountedDisposable<LibHac.FsSrv.ISaveDataInfoReader> infoReader, spaceId);
  237. if (result.IsSuccess())
  238. {
  239. MakeObject(context, new ISaveDataInfoReader(infoReader));
  240. }
  241. return (ResultCode)result.Value;
  242. }
  243. [CommandHipc(62)]
  244. public ResultCode OpenSaveDataInfoReaderOnlyCacheStorage(ServiceCtx context)
  245. {
  246. SaveDataFilter filter = new SaveDataFilter();
  247. filter.SetSaveDataType(SaveDataType.Cache);
  248. filter.SetProgramId(new ProgramId(context.Process.TitleId));
  249. // FS would query the User and SdCache space IDs to find where the existing cache is (if any).
  250. // We always have the SD card inserted, so we can always use SdCache for now.
  251. Result result = _baseFileSystemProxy.OpenSaveDataInfoReaderBySaveDataSpaceId(
  252. out ReferenceCountedDisposable<LibHac.FsSrv.ISaveDataInfoReader> infoReader, SaveDataSpaceId.SdCache);
  253. if (result.IsSuccess())
  254. {
  255. MakeObject(context, new ISaveDataInfoReader(infoReader));
  256. }
  257. return (ResultCode)result.Value;
  258. }
  259. [CommandHipc(67)]
  260. public ResultCode FindSaveDataWithFilter(ServiceCtx context)
  261. {
  262. SaveDataSpaceId spaceId = (SaveDataSpaceId)context.RequestData.ReadInt64();
  263. SaveDataFilter filter = context.RequestData.ReadStruct<SaveDataFilter>();
  264. ulong bufferPosition = context.Request.ReceiveBuff[0].Position;
  265. ulong bufferLen = context.Request.ReceiveBuff[0].Size;
  266. byte[] infoBuffer = new byte[bufferLen];
  267. Result result = _baseFileSystemProxy.FindSaveDataWithFilter(out long count, infoBuffer, spaceId, ref filter);
  268. context.Memory.Write(bufferPosition, infoBuffer);
  269. context.ResponseData.Write(count);
  270. return (ResultCode)result.Value;
  271. }
  272. [CommandHipc(68)]
  273. public ResultCode OpenSaveDataInfoReaderWithFilter(ServiceCtx context)
  274. {
  275. SaveDataSpaceId spaceId = (SaveDataSpaceId)context.RequestData.ReadInt64();
  276. SaveDataFilter filter = context.RequestData.ReadStruct<SaveDataFilter>();
  277. Result result = _baseFileSystemProxy.OpenSaveDataInfoReaderWithFilter(
  278. out ReferenceCountedDisposable<LibHac.FsSrv.ISaveDataInfoReader> infoReader, spaceId, ref filter);
  279. if (result.IsSuccess())
  280. {
  281. MakeObject(context, new ISaveDataInfoReader(infoReader));
  282. }
  283. return (ResultCode)result.Value;
  284. }
  285. [CommandHipc(71)]
  286. public ResultCode ReadSaveDataFileSystemExtraDataWithMaskBySaveDataAttribute(ServiceCtx context)
  287. {
  288. Logger.Stub?.PrintStub(LogClass.ServiceFs);
  289. MemoryHelper.FillWithZeros(context.Memory, context.Request.ReceiveBuff[0].Position, (int)context.Request.ReceiveBuff[0].Size);
  290. return ResultCode.Success;
  291. }
  292. [CommandHipc(200)]
  293. // OpenDataStorageByCurrentProcess() -> object<nn::fssrv::sf::IStorage> dataStorage
  294. public ResultCode OpenDataStorageByCurrentProcess(ServiceCtx context)
  295. {
  296. MakeObject(context, new FileSystemProxy.IStorage(context.Device.FileSystem.RomFs.AsStorage()));
  297. return 0;
  298. }
  299. [CommandHipc(202)]
  300. // OpenDataStorageByDataId(u8 storageId, nn::ApplicationId tid) -> object<nn::fssrv::sf::IStorage> dataStorage
  301. public ResultCode OpenDataStorageByDataId(ServiceCtx context)
  302. {
  303. StorageId storageId = (StorageId)context.RequestData.ReadByte();
  304. byte[] padding = context.RequestData.ReadBytes(7);
  305. ulong titleId = context.RequestData.ReadUInt64();
  306. // We do a mitm here to find if the request is for an AOC.
  307. // This is because AOC can be distributed over multiple containers in the emulator.
  308. if (context.Device.System.ContentManager.GetAocDataStorage((ulong)titleId, out LibHac.Fs.IStorage aocStorage, context.Device.Configuration.FsIntegrityCheckLevel))
  309. {
  310. Logger.Info?.Print(LogClass.Loader, $"Opened AddOnContent Data TitleID={titleId:X16}");
  311. MakeObject(context, new FileSystemProxy.IStorage(context.Device.FileSystem.ModLoader.ApplyRomFsMods((ulong)titleId, aocStorage)));
  312. return ResultCode.Success;
  313. }
  314. NcaContentType contentType = NcaContentType.Data;
  315. StorageId installedStorage = context.Device.System.ContentManager.GetInstalledStorage(titleId, contentType, storageId);
  316. if (installedStorage == StorageId.None)
  317. {
  318. contentType = NcaContentType.PublicData;
  319. installedStorage = context.Device.System.ContentManager.GetInstalledStorage(titleId, contentType, storageId);
  320. }
  321. if (installedStorage != StorageId.None)
  322. {
  323. string contentPath = context.Device.System.ContentManager.GetInstalledContentPath(titleId, storageId, contentType);
  324. string installPath = context.Device.FileSystem.SwitchPathToSystemPath(contentPath);
  325. if (!string.IsNullOrWhiteSpace(installPath))
  326. {
  327. string ncaPath = installPath;
  328. if (File.Exists(ncaPath))
  329. {
  330. try
  331. {
  332. LibHac.Fs.IStorage ncaStorage = new LocalStorage(ncaPath, FileAccess.Read, FileMode.Open);
  333. Nca nca = new Nca(context.Device.System.KeySet, ncaStorage);
  334. LibHac.Fs.IStorage romfsStorage = nca.OpenStorage(NcaSectionType.Data, context.Device.System.FsIntegrityCheckLevel);
  335. MakeObject(context, new FileSystemProxy.IStorage(romfsStorage));
  336. }
  337. catch (HorizonResultException ex)
  338. {
  339. return (ResultCode)ex.ResultValue.Value;
  340. }
  341. return ResultCode.Success;
  342. }
  343. else
  344. {
  345. throw new FileNotFoundException($"No Nca found in Path `{ncaPath}`.");
  346. }
  347. }
  348. else
  349. {
  350. throw new DirectoryNotFoundException($"Path for title id {titleId:x16} on Storage {storageId} was not found in Path {installPath}.");
  351. }
  352. }
  353. throw new FileNotFoundException($"System archive with titleid {titleId:x16} was not found on Storage {storageId}. Found in {installedStorage}.");
  354. }
  355. [CommandHipc(203)]
  356. // OpenPatchDataStorageByCurrentProcess() -> object<nn::fssrv::sf::IStorage>
  357. public ResultCode OpenPatchDataStorageByCurrentProcess(ServiceCtx context)
  358. {
  359. MakeObject(context, new FileSystemProxy.IStorage(context.Device.FileSystem.RomFs.AsStorage()));
  360. return ResultCode.Success;
  361. }
  362. [CommandHipc(400)]
  363. // OpenDataStorageByCurrentProcess() -> object<nn::fssrv::sf::IStorage> dataStorage
  364. public ResultCode OpenDeviceOperator(ServiceCtx context)
  365. {
  366. Result result = _baseFileSystemProxy.OpenDeviceOperator(out LibHac.FsSrv.IDeviceOperator deviceOperator);
  367. if (result.IsSuccess())
  368. {
  369. MakeObject(context, new IDeviceOperator(deviceOperator));
  370. }
  371. return (ResultCode)result.Value;
  372. }
  373. [CommandHipc(630)]
  374. // SetSdCardAccessibility(u8)
  375. public ResultCode SetSdCardAccessibility(ServiceCtx context)
  376. {
  377. bool isAccessible = context.RequestData.ReadBoolean();
  378. return (ResultCode)_baseFileSystemProxy.SetSdCardAccessibility(isAccessible).Value;
  379. }
  380. [CommandHipc(631)]
  381. // IsSdCardAccessible() -> u8
  382. public ResultCode IsSdCardAccessible(ServiceCtx context)
  383. {
  384. Result result = _baseFileSystemProxy.IsSdCardAccessible(out bool isAccessible);
  385. context.ResponseData.Write(isAccessible);
  386. return (ResultCode)result.Value;
  387. }
  388. [CommandHipc(1004)]
  389. // SetGlobalAccessLogMode(u32 mode)
  390. public ResultCode SetGlobalAccessLogMode(ServiceCtx context)
  391. {
  392. int mode = context.RequestData.ReadInt32();
  393. context.Device.System.GlobalAccessLogMode = mode;
  394. return ResultCode.Success;
  395. }
  396. [CommandHipc(1005)]
  397. // GetGlobalAccessLogMode() -> u32 logMode
  398. public ResultCode GetGlobalAccessLogMode(ServiceCtx context)
  399. {
  400. int mode = context.Device.System.GlobalAccessLogMode;
  401. context.ResponseData.Write(mode);
  402. return ResultCode.Success;
  403. }
  404. [CommandHipc(1006)]
  405. // OutputAccessLogToSdCard(buffer<bytes, 5> log_text)
  406. public ResultCode OutputAccessLogToSdCard(ServiceCtx context)
  407. {
  408. string message = ReadUtf8StringSend(context);
  409. // FS ends each line with a newline. Remove it because Ryujinx logging adds its own newline
  410. Logger.AccessLog?.PrintMsg(LogClass.ServiceFs, message.TrimEnd('\n'));
  411. return ResultCode.Success;
  412. }
  413. [CommandHipc(1011)]
  414. public ResultCode GetProgramIndexForAccessLog(ServiceCtx context)
  415. {
  416. int programIndex = 0;
  417. int programCount = 1;
  418. context.ResponseData.Write(programIndex);
  419. context.ResponseData.Write(programCount);
  420. return ResultCode.Success;
  421. }
  422. [CommandHipc(1200)] // 6.0.0+
  423. // OpenMultiCommitManager() -> object<nn::fssrv::sf::IMultiCommitManager>
  424. public ResultCode OpenMultiCommitManager(ServiceCtx context)
  425. {
  426. Result result = _baseFileSystemProxy.OpenMultiCommitManager(out LibHac.FsSrv.IMultiCommitManager commitManager);
  427. if (result.IsSuccess())
  428. {
  429. MakeObject(context, new IMultiCommitManager(commitManager));
  430. }
  431. return (ResultCode)result.Value;
  432. }
  433. }
  434. }