From b69d2fa95e5827f4d54aa21f9df5770faf92a16c Mon Sep 17 00:00:00 2001 From: Pablo Curiel Date: Sun, 31 Mar 2024 14:43:57 +0200 Subject: [PATCH] fs: add GetFileSystemAttribute cmd --- nx/include/switch/services/fs.h | 33 +++++++++++++++++++++++++++++++++ nx/source/services/fs.c | 11 +++++++++-- 2 files changed, 42 insertions(+), 2 deletions(-) diff --git a/nx/include/switch/services/fs.h b/nx/include/switch/services/fs.h index 0cc7d60f7..4e78e0f4b 100644 --- a/nx/include/switch/services/fs.h +++ b/nx/include/switch/services/fs.h @@ -326,6 +326,38 @@ typedef enum { FsFileSystemQueryId_IsValidSignedSystemPartitionOnSdCard = 2, ///< [8.0.0+] } FsFileSystemQueryId; +/// FileSystemAttribute +typedef struct { + bool directory_name_length_max_has_value; + bool file_name_length_max_has_value; + bool directory_path_length_max_has_value; + bool file_path_length_max_has_value; + bool utf16_create_directory_path_length_max_has_value; + bool utf16_delete_directory_path_length_max_has_value; + bool utf16_rename_source_directory_path_length_max_has_value; + bool utf16_rename_destination_directory_path_length_max_has_value; + bool utf16_open_directory_path_length_max_has_value; + bool utf16_directory_name_length_max_has_value; + bool utf16_file_name_length_max_has_value; + bool utf16_directory_path_length_max_has_value; + bool utf16_file_path_length_max_has_value; + u8 reserved1[0x1B]; + s32 directory_name_length_max; + s32 file_name_length_max; + s32 directory_path_length_max; + s32 file_path_length_max; + s32 utf16_create_directory_path_length_max; + s32 utf16_delete_directory_path_length_max; + s32 utf16_rename_source_directory_path_length_max; + s32 utf16_rename_destination_directory_path_length_max; + s32 utf16_open_directory_path_length_max; + s32 utf16_directory_name_length_max; + s32 utf16_file_name_length_max; + s32 utf16_directory_path_length_max; + s32 utf16_file_path_length_max; + u8 reserved2[0x64]; +} FsFileSystemAttribute; + /// FsPriority typedef enum { FsPriority_Normal = 0, @@ -591,6 +623,7 @@ Result fsFsGetTotalSpace(FsFileSystem* fs, const char* path, s64* out); Result fsFsGetFileTimeStampRaw(FsFileSystem* fs, const char* path, FsTimeStampRaw *out); ///< [3.0.0+] Result fsFsCleanDirectoryRecursively(FsFileSystem* fs, const char* path); ///< [3.0.0+] Result fsFsQueryEntry(FsFileSystem* fs, void *out, size_t out_size, const void *in, size_t in_size, const char* path, FsFileSystemQueryId query_id); ///< [4.0.0+] +Result fsFsGetFileSystemAttribute(FsFileSystem* fs, FsFileSystemAttribute *out); ///< [15.0.0+] void fsFsClose(FsFileSystem* fs); /// Uses \ref fsFsQueryEntry to set the archive bit on the specified absolute directory path. diff --git a/nx/source/services/fs.c b/nx/source/services/fs.c index f4d5612c1..d11bbb174 100644 --- a/nx/source/services/fs.c +++ b/nx/source/services/fs.c @@ -937,6 +937,13 @@ Result fsFsQueryEntry(FsFileSystem* fs, void *out, size_t out_size, const void * ); } +Result fsFsGetFileSystemAttribute(FsFileSystem* fs, FsFileSystemAttribute *out) { + if (hosversionBefore(15,0,0)) + return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer); + + return _fsObjectDispatchOut(&fs->s, 16, *out); +} + Result fsFsSetConcatenationFileAttribute(FsFileSystem* fs, const char *path) { return fsFsQueryEntry(fs, NULL, 0, NULL, 0, path, FsFileSystemQueryId_SetConcatenationFileAttribute); } @@ -1231,7 +1238,7 @@ Result fsDeviceOperatorGetGameCardDeviceCertificate(FsDeviceOperator* d, const F FsGameCardHandle handle; s64 buffer_size; } in = { *handle, size }; - + return _fsObjectDispatchIn(&d->s, 206, in, .buffer_attrs = { SfBufferAttr_HipcMapAlias | SfBufferAttr_Out }, .buffers = { { dst, dst_size } }); @@ -1256,7 +1263,7 @@ Result fsDeviceOperatorGetGameCardDeviceId(FsDeviceOperator* d, void* dst, size_ Result fsDeviceOperatorChallengeCardExistence(FsDeviceOperator* d, const FsGameCardHandle* handle, void* dst, size_t dst_size, void* seed, size_t seed_size, void* value, size_t value_size) { if (hosversionBefore(8,0,0)) return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer); - + return _fsObjectDispatchIn(&d->s, 219, *handle, .buffer_attrs = { SfBufferAttr_HipcMapAlias | SfBufferAttr_Out,