mirror of
https://github.com/switchbrew/libnx.git
synced 2025-06-21 12:32:40 +02:00
fs: Use new IPC interface + fixes, see details:
- Argument types corrected to better reflect their actual types (mostly several incorrect instances of size_t were changed to u64) - Const correctness fixes - fsEventNotifierGetEventHandle changed to output an Event (with user configurable autoclear) instead of a raw Handle
This commit is contained in:
parent
21d15b5a8e
commit
77888f8b1f
@ -49,7 +49,7 @@ int fsdevTranslatePath(const char *path, FsFileSystem** device, char *outpath);
|
|||||||
Result fsdevSetArchiveBit(const char *path);
|
Result fsdevSetArchiveBit(const char *path);
|
||||||
|
|
||||||
/// This calls fsFsCreateFile on the filesystem specified by the input path (as used in stdio).
|
/// This calls fsFsCreateFile on the filesystem specified by the input path (as used in stdio).
|
||||||
Result fsdevCreateFile(const char* path, size_t size, int flags);
|
Result fsdevCreateFile(const char* path, size_t size, u32 flags);
|
||||||
|
|
||||||
/// Recursively deletes the directory specified by the input path (as used in stdio).
|
/// Recursively deletes the directory specified by the input path (as used in stdio).
|
||||||
Result fsdevDeleteDirectoryRecursively(const char *path);
|
Result fsdevDeleteDirectoryRecursively(const char *path);
|
||||||
|
@ -8,6 +8,7 @@
|
|||||||
*/
|
*/
|
||||||
#pragma once
|
#pragma once
|
||||||
#include "../types.h"
|
#include "../types.h"
|
||||||
|
#include "../kernel/event.h"
|
||||||
#include "../services/sm.h"
|
#include "../services/sm.h"
|
||||||
|
|
||||||
// We use wrapped handles for type safety.
|
// We use wrapped handles for type safety.
|
||||||
@ -292,9 +293,9 @@ Result fsExtendSaveDataFileSystem(FsSaveDataSpaceId saveDataSpaceId, u64 saveID,
|
|||||||
/// Do not call this directly, see fs_dev.h.
|
/// Do not call this directly, see fs_dev.h.
|
||||||
Result fsMountSdcard(FsFileSystem* out);
|
Result fsMountSdcard(FsFileSystem* out);
|
||||||
|
|
||||||
Result fsMountSaveData(FsFileSystem* out, u8 inval, FsSave *save);
|
Result fsMountSaveData(FsFileSystem* out, u8 inval, const FsSave *save);
|
||||||
Result fsMountSystemSaveData(FsFileSystem* out, u8 inval, FsSave *save);
|
Result fsMountSystemSaveData(FsFileSystem* out, u8 inval, const FsSave *save);
|
||||||
Result fsOpenSaveDataIterator(FsSaveDataIterator* out, s32 saveDataSpaceId);
|
Result fsOpenSaveDataIterator(FsSaveDataIterator* out, FsSaveDataSpaceId saveDataSpaceId);
|
||||||
Result fsOpenContentStorageFileSystem(FsFileSystem* out, FsContentStorageId content_storage_id);
|
Result fsOpenContentStorageFileSystem(FsFileSystem* out, FsContentStorageId content_storage_id);
|
||||||
Result fsOpenCustomStorageFileSystem(FsFileSystem* out, FsCustomStorageId custom_storage_id); /// [7.0.0+]
|
Result fsOpenCustomStorageFileSystem(FsFileSystem* out, FsCustomStorageId custom_storage_id); /// [7.0.0+]
|
||||||
Result fsOpenDataStorageByCurrentProcess(FsStorage* out);
|
Result fsOpenDataStorageByCurrentProcess(FsStorage* out);
|
||||||
@ -349,7 +350,7 @@ Result fsOpenFileSystemWithId(FsFileSystem* out, u64 titleId, FsFileSystemType f
|
|||||||
Result fsOpenFileSystemWithPatch(FsFileSystem* out, u64 titleId, FsFileSystemType fsType); /// [2.0.0+], like OpenFileSystemWithId but without content path.
|
Result fsOpenFileSystemWithPatch(FsFileSystem* out, u64 titleId, FsFileSystemType fsType); /// [2.0.0+], like OpenFileSystemWithId but without content path.
|
||||||
|
|
||||||
// IFileSystem
|
// IFileSystem
|
||||||
Result fsFsCreateFile(FsFileSystem* fs, const char* path, size_t size, int flags);
|
Result fsFsCreateFile(FsFileSystem* fs, const char* path, u64 size, u32 flags);
|
||||||
Result fsFsDeleteFile(FsFileSystem* fs, const char* path);
|
Result fsFsDeleteFile(FsFileSystem* fs, const char* path);
|
||||||
Result fsFsCreateDirectory(FsFileSystem* fs, const char* path);
|
Result fsFsCreateDirectory(FsFileSystem* fs, const char* path);
|
||||||
Result fsFsDeleteDirectory(FsFileSystem* fs, const char* path);
|
Result fsFsDeleteDirectory(FsFileSystem* fs, const char* path);
|
||||||
@ -357,8 +358,8 @@ Result fsFsDeleteDirectoryRecursively(FsFileSystem* fs, const char* path);
|
|||||||
Result fsFsRenameFile(FsFileSystem* fs, const char* cur_path, const char* new_path);
|
Result fsFsRenameFile(FsFileSystem* fs, const char* cur_path, const char* new_path);
|
||||||
Result fsFsRenameDirectory(FsFileSystem* fs, const char* cur_path, const char* new_path);
|
Result fsFsRenameDirectory(FsFileSystem* fs, const char* cur_path, const char* new_path);
|
||||||
Result fsFsGetEntryType(FsFileSystem* fs, const char* path, FsEntryType* out);
|
Result fsFsGetEntryType(FsFileSystem* fs, const char* path, FsEntryType* out);
|
||||||
Result fsFsOpenFile(FsFileSystem* fs, const char* path, int flags, FsFile* out);
|
Result fsFsOpenFile(FsFileSystem* fs, const char* path, u32 flags, FsFile* out);
|
||||||
Result fsFsOpenDirectory(FsFileSystem* fs, const char* path, int flags, FsDir* out);
|
Result fsFsOpenDirectory(FsFileSystem* fs, const char* path, u32 flags, FsDir* out);
|
||||||
Result fsFsCommit(FsFileSystem* fs);
|
Result fsFsCommit(FsFileSystem* fs);
|
||||||
Result fsFsGetFreeSpace(FsFileSystem* fs, const char* path, u64* out);
|
Result fsFsGetFreeSpace(FsFileSystem* fs, const char* path, u64* out);
|
||||||
Result fsFsGetTotalSpace(FsFileSystem* fs, const char* path, u64* out);
|
Result fsFsGetTotalSpace(FsFileSystem* fs, const char* path, u64* out);
|
||||||
@ -372,36 +373,36 @@ void fsFsClose(FsFileSystem* fs);
|
|||||||
Result fsFsSetArchiveBit(FsFileSystem* fs, const char *path);
|
Result fsFsSetArchiveBit(FsFileSystem* fs, const char *path);
|
||||||
|
|
||||||
// IFile
|
// IFile
|
||||||
Result fsFileRead(FsFile* f, u64 off, void* buf, size_t len, u32 option, size_t* out);
|
Result fsFileRead(FsFile* f, u64 off, void* buf, u64 read_size, u32 option, u64* bytes_read);
|
||||||
Result fsFileWrite(FsFile* f, u64 off, const void* buf, size_t len, u32 option);
|
Result fsFileWrite(FsFile* f, u64 off, const void* buf, u64 write_size, u32 option);
|
||||||
Result fsFileFlush(FsFile* f);
|
Result fsFileFlush(FsFile* f);
|
||||||
Result fsFileSetSize(FsFile* f, u64 sz);
|
Result fsFileSetSize(FsFile* f, u64 sz);
|
||||||
Result fsFileGetSize(FsFile* f, u64* out);
|
Result fsFileGetSize(FsFile* f, u64* out);
|
||||||
Result fsFileOperateRange(FsFile* f, FsOperationId op_id, u64 off, size_t len, FsRangeInfo* out); /// [4.0.0+]
|
Result fsFileOperateRange(FsFile* f, FsOperationId op_id, u64 off, u64 len, FsRangeInfo* out); /// [4.0.0+]
|
||||||
void fsFileClose(FsFile* f);
|
void fsFileClose(FsFile* f);
|
||||||
|
|
||||||
// IDirectory
|
// IDirectory
|
||||||
Result fsDirRead(FsDir* d, u64 inval, size_t* total_entries, size_t max_entries, FsDirectoryEntry *buf);
|
Result fsDirRead(FsDir* d, u64 inval, u64* total_entries, size_t max_entries, FsDirectoryEntry *buf);
|
||||||
Result fsDirGetEntryCount(FsDir* d, u64* count);
|
Result fsDirGetEntryCount(FsDir* d, u64* count);
|
||||||
void fsDirClose(FsDir* d);
|
void fsDirClose(FsDir* d);
|
||||||
|
|
||||||
// IStorage
|
// IStorage
|
||||||
Result fsStorageRead(FsStorage* s, u64 off, void* buf, size_t len);
|
Result fsStorageRead(FsStorage* s, u64 off, void* buf, u64 read_size);
|
||||||
Result fsStorageWrite(FsStorage* s, u64 off, const void* buf, size_t len);
|
Result fsStorageWrite(FsStorage* s, u64 off, const void* buf, u64 write_size);
|
||||||
Result fsStorageFlush(FsStorage* s);
|
Result fsStorageFlush(FsStorage* s);
|
||||||
Result fsStorageSetSize(FsStorage* s, u64 sz);
|
Result fsStorageSetSize(FsStorage* s, u64 sz);
|
||||||
Result fsStorageGetSize(FsStorage* s, u64* out);
|
Result fsStorageGetSize(FsStorage* s, u64* out);
|
||||||
Result fsStorageOperateRange(FsStorage* s, FsOperationId op_id, u64 off, size_t len, FsRangeInfo* out); /// [4.0.0+]
|
Result fsStorageOperateRange(FsStorage* s, FsOperationId op_id, u64 off, u64 len, FsRangeInfo* out); /// [4.0.0+]
|
||||||
void fsStorageClose(FsStorage* s);
|
void fsStorageClose(FsStorage* s);
|
||||||
|
|
||||||
// ISaveDataInfoReader
|
// ISaveDataInfoReader
|
||||||
|
|
||||||
/// Read FsSaveDataInfo data into the buf array.
|
/// Read FsSaveDataInfo data into the buf array.
|
||||||
Result fsSaveDataIteratorRead(FsSaveDataIterator *s, FsSaveDataInfo* buf, size_t max_entries, size_t* total_entries);
|
Result fsSaveDataIteratorRead(FsSaveDataIterator *s, FsSaveDataInfo* buf, size_t max_entries, u64* total_entries);
|
||||||
void fsSaveDataIteratorClose(FsSaveDataIterator *s);
|
void fsSaveDataIteratorClose(FsSaveDataIterator *s);
|
||||||
|
|
||||||
// IEventNotifier
|
// IEventNotifier
|
||||||
Result fsEventNotifierGetEventHandle(FsEventNotifier* e, Handle* out);
|
Result fsEventNotifierGetEventHandle(FsEventNotifier* e, Event* out, bool autoclear);
|
||||||
void fsEventNotifierClose(FsEventNotifier* e);
|
void fsEventNotifierClose(FsEventNotifier* e);
|
||||||
|
|
||||||
// IDeviceOperator
|
// IDeviceOperator
|
||||||
|
@ -158,7 +158,7 @@ NX_CONSTEXPR void serviceCreateDomainSubservice(Service* s, Service* parent, u32
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Hints the compiler that a service will always contain a domain object.
|
* @brief Hints the compiler that a service will always contain a domain object.
|
||||||
* @param[in] s Service object.
|
* @param[in] _s Service object.
|
||||||
*/
|
*/
|
||||||
#define serviceAssumeDomain(_s) do { \
|
#define serviceAssumeDomain(_s) do { \
|
||||||
if (!(_s)->object_id) \
|
if (!(_s)->object_id) \
|
||||||
|
@ -381,7 +381,7 @@ Result fsdevSetArchiveBit(const char *path) {
|
|||||||
return fsFsSetArchiveBit(&device->fs, fs_path);
|
return fsFsSetArchiveBit(&device->fs, fs_path);
|
||||||
}
|
}
|
||||||
|
|
||||||
Result fsdevCreateFile(const char* path, size_t size, int flags) {
|
Result fsdevCreateFile(const char* path, size_t size, u32 flags) {
|
||||||
char fs_path[FS_MAX_PATH];
|
char fs_path[FS_MAX_PATH];
|
||||||
fsdev_fsdevice *device = NULL;
|
fsdev_fsdevice *device = NULL;
|
||||||
|
|
||||||
@ -786,7 +786,7 @@ fsdev_read(struct _reent *r,
|
|||||||
size_t len)
|
size_t len)
|
||||||
{
|
{
|
||||||
Result rc;
|
Result rc;
|
||||||
size_t bytes;
|
u64 bytes;
|
||||||
|
|
||||||
/* get pointer to our data */
|
/* get pointer to our data */
|
||||||
fsdev_file_t *file = (fsdev_file_t*)fd;
|
fsdev_file_t *file = (fsdev_file_t*)fd;
|
||||||
@ -830,7 +830,7 @@ fsdev_read_safe(struct _reent *r,
|
|||||||
size_t len)
|
size_t len)
|
||||||
{
|
{
|
||||||
Result rc;
|
Result rc;
|
||||||
size_t bytesRead = 0, bytes = 0;
|
u64 bytesRead = 0, bytes = 0;
|
||||||
|
|
||||||
/* get pointer to our data */
|
/* get pointer to our data */
|
||||||
fsdev_file_t *file = (fsdev_file_t*)fd;
|
fsdev_file_t *file = (fsdev_file_t*)fd;
|
||||||
@ -841,7 +841,7 @@ fsdev_read_safe(struct _reent *r,
|
|||||||
static __thread char tmp_buffer[8192];
|
static __thread char tmp_buffer[8192];
|
||||||
while(len > 0)
|
while(len > 0)
|
||||||
{
|
{
|
||||||
size_t toRead = len;
|
u64 toRead = len;
|
||||||
if(toRead > sizeof(tmp_buffer))
|
if(toRead > sizeof(tmp_buffer))
|
||||||
toRead = sizeof(tmp_buffer);
|
toRead = sizeof(tmp_buffer);
|
||||||
|
|
||||||
@ -1299,7 +1299,7 @@ fsdev_dirnext(struct _reent *r,
|
|||||||
struct stat *filestat)
|
struct stat *filestat)
|
||||||
{
|
{
|
||||||
Result rc;
|
Result rc;
|
||||||
size_t entries;
|
u64 entries;
|
||||||
ssize_t units;
|
ssize_t units;
|
||||||
FsDirectoryEntry *entry;
|
FsDirectoryEntry *entry;
|
||||||
|
|
||||||
|
@ -52,7 +52,7 @@ static char __thread __component[PATH_MAX+1];
|
|||||||
static ssize_t _romfs_read(romfs_mount *mount, u64 offset, void* buffer, u64 size)
|
static ssize_t _romfs_read(romfs_mount *mount, u64 offset, void* buffer, u64 size)
|
||||||
{
|
{
|
||||||
u64 pos = mount->offset + offset;
|
u64 pos = mount->offset + offset;
|
||||||
size_t read = 0;
|
u64 read = 0;
|
||||||
Result rc = 0;
|
Result rc = 0;
|
||||||
if(mount->fd_type == RomfsSource_FsFile)
|
if(mount->fd_type == RomfsSource_FsFile)
|
||||||
{
|
{
|
||||||
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user