Skip to content
This repository has been archived by the owner on Sep 21, 2021. It is now read-only.

sdcardfs #109

Merged
merged 66 commits into from Mar 5, 2018
Merged
Show file tree
Hide file tree
Changes from 47 commits
Commits
Show all changes
66 commits
Select commit Hold shift + click to select a range
e3b04bb
Add IPC bindings
roblabla Feb 21, 2018
2fd53f1
Regenerate the IPC bindings
roblabla Feb 21, 2018
bf93e61
Implement rootfs
roblabla Feb 22, 2018
7441be5
fixup! Add IPC bindings
roblabla Feb 22, 2018
00bf559
Remove inode api in dirent. It's not usable
roblabla Feb 22, 2018
d910fd1
Make ifile.h includable standalone
roblabla Feb 22, 2018
127e1f9
WIP fspfs, doesn't read files yet. Automount sdcard in /sd.
roblabla Feb 22, 2018
fd569cc
Implement file reading
roblabla Feb 23, 2018
1d4dc46
Fix extra / in fspfs
roblabla Feb 23, 2018
8e04cc9
Fix dangling pointer in rootfs
roblabla Feb 23, 2018
a53b339
Regression test for dangling pointer
roblabla Feb 23, 2018
24c26d0
lots of debug printing
roblabla Feb 23, 2018
b13df47
rq.raw_data is an uint32_t...
roblabla Feb 24, 2018
423334d
ifile_read takes three uint64_t. SwIPC is wrong.
roblabla Feb 24, 2018
9098b2e
Implement llseek with SEEK_END
roblabla Feb 24, 2018
eae55f9
Add test to read a file
roblabla Feb 24, 2018
d6faf31
Implement file writing
roblabla Feb 24, 2018
28ac600
Allow creating files
roblabla Feb 24, 2018
05c62ab
Fix errno, they should be positive
roblabla Feb 24, 2018
d81b6a0
elf2nxo is drunk. Also, adding a stress-test for the fs stuff
roblabla Feb 25, 2018
bb7970d
Revert "lots of debug printing"
roblabla Feb 25, 2018
cc49ac8
Enforce null-terminated name in readdir dirent
roblabla Feb 25, 2018
b794010
fixup! elf2nxo is drunk. Also, adding a stress-test for the fs stuff
roblabla Feb 25, 2018
e404638
Remove more debug log
roblabla Feb 25, 2018
7e00acb
Let fspfs clean the ifilesystem_t
roblabla Feb 25, 2018
8d5ef5e
Have rootfs clean up the filesystems on release
roblabla Feb 25, 2018
9c35ae9
Close the bsd stuff after fini_array. Maybe we should do it before ?
roblabla Feb 25, 2018
861deea
Remove logging to my server
roblabla Feb 26, 2018
26a3d99
Writing works
roblabla Feb 27, 2018
00d5801
Implement directory creation
roblabla Feb 28, 2018
2a92fca
Fix small bug in traverse with max_len
roblabla Feb 28, 2018
e99fc65
Add error logging in fspfs.c
roblabla Feb 28, 2018
e162ad5
The in_size is an uint64_t
roblabla Feb 28, 2018
355654b
Revert "Remove logging to my server"
roblabla Feb 28, 2018
1aa72f6
fixup! Writing works
roblabla Feb 28, 2018
0dfce7e
Add module enum to error header
roblabla Feb 28, 2018
e652a67
Add FSP-SRV errors
roblabla Feb 28, 2018
5534a96
Add PATH_EXIST error
roblabla Feb 28, 2018
00cec3d
CreateFile takes an u32, u64
roblabla Feb 28, 2018
4c9e9ce
WIP remove
roblabla Mar 1, 2018
15bce5a
Implement better error handling
roblabla Mar 2, 2018
8683b01
Implement directory and file removal
roblabla Mar 2, 2018
b46797b
implement open with O_EXCL
roblabla Mar 2, 2018
473fbc9
Add some more documentation on filesystem
roblabla Mar 2, 2018
48510e0
Implement rename
roblabla Mar 2, 2018
d24ac8a
Further documentation of fspfs and fs
roblabla Mar 2, 2018
002bae6
Add documentation for rootfs
roblabla Mar 2, 2018
78b4542
move module definitions to err/modules.h
misson20000 Mar 5, 2018
f2c40ff
move fsp-srv error codes to their own header file
misson20000 Mar 5, 2018
ce15f29
rootfs -> mountfs
misson20000 Mar 5, 2018
ed1e171
several fs changes:
misson20000 Mar 5, 2018
9bb4756
clarify trn_mountfs_mount ownership, cleanup resource handling in trn…
misson20000 Mar 5, 2018
f9105c6
Revert "Revert "Remove logging to my server""
misson20000 Mar 5, 2018
883a46d
remove more roblabla socket
misson20000 Mar 5, 2018
23bf037
TRN_FS_DEBUG and make get_path_parent_child static
misson20000 Mar 5, 2018
78a9072
fspfs: inode.name -> inode.path, root_name -> base_path, and root ino…
misson20000 Mar 5, 2018
f4eb772
fspfs: only close ifilesystem when root inode closes
misson20000 Mar 5, 2018
e8abe9e
use FS_READ_ONLY error
misson20000 Mar 5, 2018
7b833d4
Merge branch 'development' into fs-sdcardfs
misson20000 Mar 5, 2018
72d5c22
move sha256 out of test_fs_stress
misson20000 Mar 5, 2018
e0eacee
crt0_common: include ipc/fs.h
misson20000 Mar 5, 2018
9a2001d
crt0_common: clean up fs before unmapping heap
misson20000 Mar 5, 2018
f72ac25
fix makefiles for sdcardfs merge
misson20000 Mar 5, 2018
4df7ab7
test_fs_stress should return non-zero exit code on failure
misson20000 Mar 5, 2018
b1cff89
fspfs: paths needs to start with /
misson20000 Mar 5, 2018
0fb9b11
test_ipc_fs: fix if statement bug and show error code we're returning…
misson20000 Mar 5, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
74 changes: 72 additions & 2 deletions include/libtransistor/err.h
Expand Up @@ -6,7 +6,70 @@
#pragma once

#define MAKE_RESULT(module, code) (((code) << 9) | (module))
#define LIBTRANSISTOR_RESULT(code) MAKE_RESULT(0xDD, code)

enum modules {
MODULE_KERNEL = 1,
MODULE_FS = 2,
MODULE_NVIDIA = 3,
MODULE_NCM = 5,
MODULE_DD = 6,
MODULE_LR = 8,
MODULE_LOADER = 9,
MODULE_CMIF = 10,
MODULE_HIPC = 11,
MODULE_PM = 15,
MODULE_NS = 16,
MODULE_HTC = 18,
MODULE_SM = 21,
MODULE_RO = 22,
MODULE_SDMMC = 24,
MODULE_SPL = 26,
MODULE_ETHC = 100,
MODULE_I2C = 101,
MODULE_SETTINGS = 105,
MODULE_NIFM = 110,
MODULE_HWOPUS = 111,
MODULE_DISPLAY = 114,
MODULE_NTC = 116,
MODULE_FGM = 117,
MODULE_PCIE = 120,
MODULE_FRIENDS = 121,
MODULE_SSL = 123,
MODULE_ACCOUNT = 124,
MODULE_MII = 126,
MODULE_AM = 128,
MODULE_PLAYREPORT = 129,
MODULE_PCV = 133,
MODULE_OMM = 134,
MODULE_NIM = 137,
MODULE_PSC = 138,
MODULE_USB = 140,
MODULE_NSD = 141,
MODULE_BTM = 143,
MODULE_ERPT = 147,
MODULE_APM = 148,
MODULE_AUDIO = 153,
MODULE_NPNS = 154,
MODULE_ARP = 157,
MODULE_BOOT = 158,
MODULE_NFC = 161,
MODULE_USERLAND_ASSERT = 162,
MODULE_USERLAND_CRASH = 168,
MODULE_HID = 203,
MODULE_CAPTURE = 206,
MODULE_LIBTRANSISTOR = 221,
MODULE_LIBNX = 345,
MODULE_HOMEBREW_ABI = 346,
MODULE_HOMEBREW_LOADER = 347,
MODULE_LIBNX_NVIDIA = 348,
MODULE_TC = 651,
MODULE_WEBAPPLET = 800,
MODULE_WEBAPPLET_WIFIAUTH = 809,
MODULE_APPLET_WHITELISTED = 810,
MODULE_SHOPN = 811,
};
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

takes up a lot of space, err_modules.h maybe?


#define LIBTRANSISTOR_RESULT(code) MAKE_RESULT(MODULE_LIBTRANSISTOR, code)

// Misc
#define LIBTRANSISTOR_ERR_UNSPECIFIED LIBTRANSISTOR_RESULT(1)
Expand Down Expand Up @@ -84,6 +147,7 @@
#define LIBTRANSISTOR_ERR_FS_NOT_FOUND LIBTRANSISTOR_RESULT(8006)
#define LIBTRANSISTOR_ERR_FS_INVALID_PATH LIBTRANSISTOR_RESULT(8007)
#define LIBTRANSISTOR_ERR_FS_PATH_TOO_DEEP LIBTRANSISTOR_RESULT(8008)
#define LIBTRANSISTOR_ERR_FS_PATH_EXISTS LIBTRANSISTOR_RESULT(8009)

// AM
#define LIBTRANSISTOR_ERR_AM_WORKAROUND_ACTIVE LIBTRANSISTOR_RESULT(9001)
Expand All @@ -98,7 +162,13 @@
#define LIBTRANSISTOR_ERR_IPCSERVER_NO_SUCH_COMMAND LIBTRANSISTOR_RESULT(10007)

// Homebrew ABI
#define HOMEBREW_ABI_RESULT(code) MAKE_RESULT(346, code)
#define HOMEBREW_ABI_RESULT(code) MAKE_RESULT(MODULE_HOMEBREW_ABI, code)
#define HOMEBREW_ABI_UNRECOGNIZED_KEY(key) HOMEBREW_ABI_RESULT(100 + key)
#define HOMEBREW_ABI_KEY_NOT_PRESENT(key) HOMEBREW_ABI_RESULT(200 + key)
#define HOMEBREW_ABI_KEY_INVALID(key) HOMEBREW_ABI_RESULT(300 + key)

// FSP-SRV
#define FSPSRV_RESULT(code) MAKE_RESULT(MODULE_FS, code)
#define FSPSRV_ERR_NOT_FOUND FSPSRV_RESULT(1)
#define FSPSRV_ERR_EXISTS FSPSRV_RESULT(2)
#define FSPSRV_ERR_DIRECTORY_NOT_EMPTY FSPSRV_RESULT(8)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

probably move to fs/err.h or ipc/fs/err.h or something

80 changes: 79 additions & 1 deletion include/libtransistor/fs/fs.h
@@ -1,13 +1,91 @@
/**
* @file libtransistor/fs/fs.h
* @brief Functions to setup filesystem
*
* Libtransistor sports a virtual filesystem allowing to mount multiple kinds of
* filesystem (such as a squashfs, a networked filesystem, or an fsp-srv
* filesystem).
*
* The filesystem root is purely virtual: you may not create
* files or directories directly under `/`. Instead, filesystems are mounted as
* direct descendants to it (through the `trn_fs_mount_fs` function). For
* instance, the canonical place to mount the SD card is `/sd`, which is done
* by calling `trn_fs_mount_fs("/sd", sdcardfs)`.
*
* Anyone can create his own filesystem: they simply needs to create a struct of
* type `trn_inode_t`. Libtransistor sports various filesystem implementations,
* mainly one backed by the FSP-SRV server of the switch, allowing mounting the
* sdcard, among other things.
*
* Note that while functions like `trn_fs_open` are defined, those should
* probably *not* be used. Users should prefer instead to use the POSIX
* functions of the same name. This is because the error values, result_t,
* are not guaranteed to stay the same across filesystems.
*/

#pragma once

#include<libtransistor/types.h>
#include<libtransistor/fs/inode.h>

#include<sys/stat.h>

result_t trn_fs_set_root(trn_inode_t *root);
/**
* @brief Change filesystem root.
*
* In libtransistor, the default root filesystem is rootfs. That filesystem is
* not very special: it's a filesystem containing only directories, each being
* a mountpoint. However, this behavior might not fit what all application's
* needs. For instance, when porting software, you might need to place some
* files in certain locations, or just need more leeway in how the root fs
* works. In these cases, you can use `trn_fs_set_root` to change what the root
* filesystem implementation is.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's a little confusing that the concept of a "root filesystem" is not necessarily the same thing as "rootfs". I'd suggest either making that very clear in the documentation or renaming rootfs.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I want to rename rootfs to mountfs. Will do.

*
* For instance, the following code will mount the sdcard at the root:
*
* @code{.c}
* ifilesystem_t sdcard_ifs;
* trn_inode_t sdcard_inode;
*
* fsp_srv_mount_sd_card(&sdcard_ifs);
* trn_fspfs_create(&sdcard_inode, sdcard_ifs);
* trn_fs_set_root(&sdcard_inode);
* @endcode
*/
result_t trn_fs_set_root(trn_inode_t *new_root);

/**
* @brief Mount a filesystem.
*
* Allows a user to mount a filesystem to the specified location. The location
* should be a full path.
*
* Note that the current implementation is relatively simple: it forwards the
* call to mount to the root filesystem - if it is a rootfs. If you have swapped
* out the root filesystem with `trn_fs_set_root`, this will not work.
*
* You could mount the game card partition (assuming correct privilege) like so:
*
* @code{.c}
* ifilesystem_t gamecard_ifs;
* trn_inode_t gamecard_inode;
*
* fsp_srv_mount_game_card_partition(&gamecard_inode, 0, 0);
* trn_fspfs_create(&gamecard_inode, gamecard_ifs);
* trn_fs_mount("/gamecard", &gamecard_inode);
* @endcode
*/
result_t trn_fs_mount(const char *name, trn_inode_t *root);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this will break if you trn_fs_set_root, should we maybe remove this and add a function to grab the default rootfs and use trn_rootfs_mount_fs?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The idea was that if we end up changing how mounts work (say, we end up wanting to do mounting in arbitrary location and getting rid of rootfs), we can do that without breaking userspace applications.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, alright.


// The rest of those functions should probably not be directly used. Instead,
// use the standard posix calls of the same name...
// Maybe we should still men
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

men <- is this a typo?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wow. That said document them at one point. Probably did something weird in vim :P

result_t trn_fs_realpath(const char *path, char **resolved_path);
result_t trn_fs_open(int *fd, const char *path, int flags);
result_t trn_fs_opendir(trn_dir_t *dir, const char *path);
result_t trn_fs_mkdir(const char *path);
result_t trn_fs_rename(const char *oldpath, const char *newpath);
result_t trn_fs_unlink(const char *path);
result_t trn_fs_rmdir(const char *path);
result_t trn_fs_chdir(const char *path);
result_t trn_fs_stat(const char *path, struct stat *st);
32 changes: 32 additions & 0 deletions include/libtransistor/fs/fspfs.h
@@ -0,0 +1,32 @@
/**
* @file libtransistor/fs/fspfs.h
* @brief FSP-SRV based filesystem
*
* The Nintendo Switch has a service called `fsp-srv` which is in charge of
* providing apps with whatever filesystem they might need. For instance, you
* might ask fsp-srv to give you a filesystem for the SD Card, or for the Game
* Cartridge, etc...
*
* All those filesystem implement the same IPC interface: IFilesystem. FSPFS is
* then responsible for wrapping this IPC Interface and providing a
* libtransistor mountpoint to access it. This is the mechanism used by
* libtransistor to mount the SDCard filesystem in /sd by default.
*/

#pragma once

#include<libtransistor/types.h>
#include<libtransistor/fs/inode.h>
#include<libtransistor/ipc/fs/ifilesystem.h>

/**
* @brief Create an FSPFS filesystem
*
* This takes an `ifilesystem_t` (that you'll need to have initialized
* beforehand), and wraps it in a libtransistor filesystem.
*
* Note that the ownership of the ifilesystem_t is transfered to the fspfs!
* When the filesystem is released, it will automatically close the
* ifilesystem_t handle.
*/
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add @param tags, make it clear that this initializes out (if it wasn't already clear from the name)

result_t trn_fspfs_create(trn_inode_t *out, ifilesystem_t fs);
6 changes: 5 additions & 1 deletion include/libtransistor/fs/inode.h
Expand Up @@ -11,7 +11,6 @@ typedef struct {
} trn_inode_t; // libTRaNsistor INODE

typedef struct {
trn_inode_t inode;
char name[256];
size_t name_size;
} trn_dirent_t;
Expand All @@ -31,6 +30,11 @@ typedef struct trn_inode_ops_t {
result_t (*is_dir)(void *inode, bool *out);
result_t (*lookup)(void *inode, trn_inode_t *out, const char *name, size_t name_length);
result_t (*release)(void *inode);
result_t (*create_file)(void *inode, const char *name);
result_t (*create_directory)(void *inode, const char *name);
result_t (*remove_file)(void *inode);
result_t (*remove_empty_directory)(void *inode);
result_t (*rename)(void *inode, const char *newname);

/*
Objects returned from these functions must not be invalidated if the inode is closed
Expand Down
32 changes: 32 additions & 0 deletions include/libtransistor/fs/rootfs.h
@@ -0,0 +1,32 @@
/**
* @file libtransistor/fs/rootfs.h
* @brief Root Filesystem
*
* A RootFS is a pseudo-filesystem capable of mounting other filesystems in it.
* In libtransistor, this is the default filesystem for the root directory. The
* RootFS is organized as a single folder containing one subfolder for each
* mounted filesystem.
*/
#pragma once

#include<libtransistor/fs/inode.h>

// TODO: Rename mountfs I guess.

/**
* @brief Create a rootfs filesystem
*/
result_t trn_rootfs_create(trn_inode_t *out);


/**
* @brief Mount a filesystem in the RootFS
*
* The given filesystem will then be made available in a folder of the given
* name. Note that it is *not* possible to have hierarchies in the rootfs: all
* filesystems have to be mounted directly at the root of the RootFS.
*
* This takes ownership of the passed trn_inode_t: it will call the close
* release method automatically when the rootfs itself is released.
*/
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does the lifetime on name have to be?

result_t trn_rootfs_mount_fs(trn_inode_t *fs, const char *name, trn_inode_t *mountpoint);
76 changes: 76 additions & 0 deletions include/libtransistor/ipc/fs.h
@@ -0,0 +1,76 @@
/**
* @file libtransistor/ipc/fs.h
* @brief File System
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

change this to "Auto-generated nn::fssrv::sf::IFileSystemProxy bindings"

*/

#pragma once

#include <libtransistor/types.h>
#include <libtransistor/ipc/fs/ifilesystem.h>
#include <libtransistor/ipc/fs/ifile.h>
#include <libtransistor/ipc/fs/idirectory.h>

// TODO: Codegen structs


result_t fsp_srv_init(uint64_t in_unk0);
void fsp_srv_finalize();
// result_t fsp_srv_mount_content(ifilesystem_t *out_contentFs, applicationid in_tid, uint32_t in_flag, const int8_t * in_path);
result_t fsp_srv_open_data_file_system_by_current_process(ifilesystem_t *out_unk0);
// result_t fsp_srv_mount_content7(ifilesystem_t *out_unk2, applicationid in_tid, uint32_t in_ncaType);
// result_t fsp_srv_mount_content(ifilesystem_t *out_contentFs, applicationid in_tid, uint32_t in_flag, const uint8_t in_path[0x301]);
// result_t fsp_srv_open_data_file_system_by_application_id(ifilesystem_t *out_dataFiles, applicationid in_tid);
// result_t fsp_srv_mount_bis(ifilesystem_t *out_Bis, partition in_partitionID, const uint8_t in_path[0x301]);
// result_t fsp_srv_open_bis_partition(ipc_object_t *out_BisPartition, partition in_partitionID);
result_t fsp_srv_invalidate_bis_cache();
result_t fsp_srv_open_host_file_system_impl(ifilesystem_t *out_unk1, const uint8_t in_path[0x301]);
result_t fsp_srv_mount_sd_card(ifilesystem_t *out_sdCard);
result_t fsp_srv_format_sd_card();
// result_t fsp_srv_delete_save_data(applicationid in_tid);
// result_t fsp_srv_create_save_data(savestruct in_saveStruct, savecreatestruct in_saveCreate, u128 in_input);
// result_t fsp_srv_create_system_save_data(savestruct in_saveStruct, savecreatestruct in_saveCreate);
// result_t fsp_srv_register_save_data_atomic_deletion(unknown in_unk0);
result_t fsp_srv_delete_save_data_with_space_id(uint8_t in_unk0, uint64_t in_unk1);
result_t fsp_srv_format_sd_card_dry_run();
result_t fsp_srv_is_ex_fat_supported(uint8_t *out_isSupported);
// result_t fsp_srv_open_game_card_partition(ipc_object_t *out_gameCardFs, partition in_partitionID, uint32_t in_unk1);
result_t fsp_srv_mount_game_card_partition(ifilesystem_t *out_gameCardPartitionFs, uint32_t in_unk0, uint32_t in_unk1);
result_t fsp_srv_extend_save_data(uint8_t in_unk0, uint64_t in_unk1, uint64_t in_unk2, uint64_t in_unk3);
// result_t fsp_srv_mount_save_data(ifilesystem_t *out_saveDataFs, uint8_t in_input, savestruct in_saveStruct);
// result_t fsp_srv_mount_system_save_data(ifilesystem_t *out_systemSaveDataFs, uint8_t in_input, savestruct in_saveStruct);
// result_t fsp_srv_mount_save_data_read_only(ifilesystem_t *out_saveDataFs, uint8_t in_input, savestruct in_saveStruct);
// result_t fsp_srv_read_save_data_file_system_extra_data_with_space_id(unknown *out_unk2, uint8_t in_unk0, uint64_t in_unk1);
// result_t fsp_srv_read_save_data_file_system_extra_data(unknown *out_unk1, uint64_t in_unk0);
// result_t fsp_srv_write_save_data_file_system_extra_data(uint64_t in_unk0, uint8_t in_unk1, unknown in_unk2);
// result_t fsp_srv_open_save_data_info_reader(ipc_object_t *out_unk0);
// result_t fsp_srv_open_save_data_iterator(ipc_object_t *out_unk1, uint8_t in_unk0);
result_t fsp_srv_open_save_data_thumbnail_file(ifile_t *out_thumbnail, uint8_t in_unk0, const uint8_t in_unk1[0x40], uint32_t in_unk2);
result_t fsp_srv_mount_image_directory(ifilesystem_t *out_imageFs, uint32_t in_unk0);
result_t fsp_srv_mount_content_storage(ifilesystem_t *out_contentFs, uint32_t in_contentStorageID);
// result_t fsp_srv_open_data_storage_by_current_process(ipc_object_t *out_dataStorage);
// result_t fsp_srv_open_data_storage_by_application_id(ipc_object_t *out_dataStorage, applicationid in_tid);
// result_t fsp_srv_open_data_storage_by_data_id(ipc_object_t *out_dataStorage, applicationid in_tid, uint8_t in_storageId);
// result_t fsp_srv_open_rom_storage(ipc_object_t *out_unk0);
// result_t fsp_srv_open_device_operator(ipc_object_t *out_unk0);
// result_t fsp_srv_open_sd_card_detection_event_notifier(ipc_object_t *out_SdEventNotify);
// result_t fsp_srv_open_game_card_detection_event_notifier(ipc_object_t *out_GameCardEventNotify);
result_t fsp_srv_set_current_posix_time(uint64_t in_time);
result_t fsp_srv_query_save_data_total_size(uint64_t *out_saveDataSize, uint64_t in_unk0, uint64_t in_unk1);
// result_t fsp_srv_verify_save_data(unknown *out_unk1, applicationid in_tid);
// result_t fsp_srv_corrupt_save_data_for_debug(applicationid in_tid);
result_t fsp_srv_create_padding_file(uint64_t in_size);
result_t fsp_srv_delete_all_padding_files();
// result_t fsp_srv_get_rights_id(u128 *out_rights, uint64_t in_unk0, uint8_t in_unk1);
// result_t fsp_srv_register_external_key(u128 in_unk0, u128 in_unk1);
result_t fsp_srv_unregister_external_key();
// result_t fsp_srv_get_rights_id_by_path(u128 *out_rights, const uint8_t in_path[0x301]);
// result_t fsp_srv_get_rights_id_by_path2(u128 *out_rights, uint8_t *out_unk2, const uint8_t in_path[0x301]);
// result_t fsp_srv_set_sd_card_encryption_seed(u128 in_seedmaybe);
result_t fsp_srv_get_and_clear_file_system_proxy_error_info(uint8_t out_errorInfo[0x80]);
result_t fsp_srv_set_bis_root_for_host(uint32_t in_unk0, const uint8_t in_path[0x301]);
result_t fsp_srv_set_save_data_size(uint64_t in_unk0, uint64_t in_unk1);
result_t fsp_srv_set_save_data_root_path(const uint8_t in_path[0x301]);
result_t fsp_srv_disable_auto_save_data_creation();
result_t fsp_srv_set_global_access_log_mode(uint32_t in_mode);
result_t fsp_srv_get_global_access_log_mode(uint32_t *out_logMode);
// result_t fsp_srv_output_access_log_to_sd_card(unknown in_logText);
23 changes: 23 additions & 0 deletions include/libtransistor/ipc/fs/idirectory.h
@@ -0,0 +1,23 @@
/**
* @file libtransistor/ipc/fs/idirectory.h
* @brief Directory
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"Auto-generated nn::fssrv::sf::IDirectory bindings"

*/

#pragma once

#include <libtransistor/types.h>
#include <assert.h>

typedef ipc_object_t idirectory_t;

typedef struct idirectoryentry {
char path[0x300];
uint32_t unk1;
uint8_t entry_type;
// TODO: Padding
uint64_t size;
} idirectoryentry_t;
static_assert(sizeof(idirectoryentry_t) == 0x310, "Wrong idirectoryentry_t size");

result_t idirectory_read(idirectory_t obj, uint64_t *out_unk0, idirectoryentry_t * out_unk1, size_t out_unk1_size);
result_t idirectory_get_entry_count(idirectory_t obj, uint64_t *out_unk0);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can these arguments have better names?

19 changes: 19 additions & 0 deletions include/libtransistor/ipc/fs/ifile.h
@@ -0,0 +1,19 @@
/**
* @file libtransistor/ipc/fs/ifile.h
* @brief File
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"Auto-generated nn::fssrv::sf::IFile bindings"

*/

#pragma once

#include <libtransistor/types.h>
#include <libtransistor/ipc.h>

typedef ipc_object_t ifile_t;

// TODO: Codegen structs

result_t ifile_read(ifile_t obj, uint64_t *out_out_size, int8_t * out_out_buf, size_t out_out_buf_size, uint64_t in_unk0, uint64_t in_offset, uint64_t in_size);
result_t ifile_write(ifile_t obj, uint32_t in_unk0, uint64_t in_offset, uint64_t in_size, const int8_t * in_buf, size_t in_buf_size);
result_t ifile_flush(ifile_t obj);
result_t ifile_set_size(ifile_t obj, uint64_t in_size);
result_t ifile_get_size(ifile_t obj, uint64_t *out_fileSize);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

argument names