Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fs: add GetFileSystemAttribute cmd #642

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions nx/include/switch/services/fs.h
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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.
Expand Down
11 changes: 9 additions & 2 deletions nx/source/services/fs.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down Expand Up @@ -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 } });
Expand All @@ -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,
Expand Down
Loading