erpt: reimplement the sysmodule (#875)

* erpt: reimplement the sysmodule

* fatal: update for latest bindings

* erpt: amend logic for culling orphan attachments
This commit is contained in:
SciresM 2020-04-13 17:07:37 -07:00 committed by GitHub
parent eca5ac01b8
commit 79b9e07ee9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
117 changed files with 6716 additions and 59 deletions

View file

@ -20,6 +20,8 @@ namespace ams::fs {
namespace {
constexpr inline const char AtmosphereErrorReportDirectory[] = "/atmosphere/erpt_reports";
/* NOTE: Nintendo does not attach a generator to a mounted SD card filesystem. */
/* However, it is desirable for homebrew to be able to access SD via common path. */
class SdCardCommonMountNameGenerator : public fsa::ICommonMountNameGenerator, public impl::Newable {
@ -63,4 +65,27 @@ namespace ams::fs {
return fsa::Register(name, std::move(fsa), std::move(generator));
}
Result MountSdCardErrorReportDirectoryForAtmosphere(const char *name) {
/* Validate the mount name. */
R_TRY(impl::CheckMountName(name));
/* Open the SD card. This uses libnx bindings. */
FsFileSystem fs;
R_TRY(fsOpenSdCardFileSystem(std::addressof(fs)));
/* Allocate a new filesystem wrapper. */
std::unique_ptr<fsa::IFileSystem> fsa = std::make_unique<RemoteFileSystem>(fs);
R_UNLESS(fsa != nullptr, fs::ResultAllocationFailureInSdCardA());
/* Ensure that the error report directory exists. */
R_TRY(fssystem::EnsureDirectoryRecursively(fsa.get(), AtmosphereErrorReportDirectory));
/* Create a subdirectory filesystem. */
auto subdir_fs = std::make_unique<fssystem::SubDirectoryFileSystem>(std::move(fsa), AtmosphereErrorReportDirectory);
R_UNLESS(subdir_fs != nullptr, fs::ResultAllocationFailureInSdCardA());
/* Register. */
return fsa::Register(name, std::move(subdir_fs));
}
}