Skip to content

Commit f02b5ca

Browse files
committed
add basic support for custom devices.
1 parent 14c4b41 commit f02b5ca

File tree

4 files changed

+20
-5
lines changed

4 files changed

+20
-5
lines changed

src/platform/nx/main.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ int main(int argc, char** argv) {
186186
return error_loop("failed to get current ip address");
187187
}
188188

189-
vfs_nx_init(mount_devices, save_writable, mount_bis);
189+
vfs_nx_init(NULL, mount_devices, save_writable, mount_bis);
190190

191191
const struct in_addr addr = {ip};
192192
printf(TEXT_YELLOW "ip: %s\n", inet_ntoa(addr));

src/platform/nx/main_sysmod.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ int main(void) {
7070
return EXIT_FAILURE;
7171
}
7272

73-
vfs_nx_init(mount_devices, save_writable, mount_bis);
73+
vfs_nx_init(NULL, mount_devices, save_writable, mount_bis);
7474

7575
int timeout = -1;
7676
if (g_ftpsrv_config.timeout) {

src/platform/nx/vfs_nx.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ static const FtpVfs* g_vfs[] = {
3939
[VFS_TYPE_STDIO] = &g_vfs_stdio,
4040
[VFS_TYPE_HDD] = &g_vfs_hdd,
4141
#endif
42+
[VFS_TYPE_USER] = NULL,
4243
};
4344

4445
static bool is_path(const char* path, const char* name) {
@@ -275,10 +276,9 @@ static const struct MountEntry BIS_NAMES[] = {
275276
{ "bis_system", FsBisPartitionId_System },
276277
};
277278

278-
void vfs_nx_init(bool enable_devices, bool save_writable, bool mount_bis) {
279+
void vfs_nx_init(const struct VfsNxCustomPath* custom, bool enable_devices, bool save_writable, bool mount_bis) {
279280
g_enabled_devices = enable_devices;
280281
if (g_enabled_devices) {
281-
282282
// sorted based on most common
283283
const NcmStorageId ids[NCM_SIZE] = {
284284
NcmStorageId_SdCard,
@@ -383,6 +383,11 @@ void vfs_nx_init(bool enable_devices, bool save_writable, bool mount_bis) {
383383
vfs_nx_add_device("hdd", VFS_TYPE_HDD);
384384
}
385385
#endif
386+
if (custom) {
387+
vfs_nx_add_device(custom->name, VFS_TYPE_USER);
388+
g_vfs[VFS_TYPE_USER] = custom->func;
389+
}
390+
386391
vfs_root_init(g_device, &g_device_count);
387392

388393
u64 LanguageCode;

src/platform/nx/vfs_nx.h

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ enum VFS_TYPE {
4646
VFS_TYPE_STDIO, // used for romfs and hdd
4747
VFS_TYPE_HDD, // list hdd, uses unistd
4848
#endif
49+
VFS_TYPE_USER,
4950
};
5051

5152
struct FtpVfsFile {
@@ -66,6 +67,7 @@ struct FtpVfsFile {
6667
struct VfsStdioFile stdio;
6768
struct VfsHddFile usbhsfs;
6869
#endif
70+
void* user;
6971
};
7072
};
7173

@@ -87,6 +89,7 @@ struct FtpVfsDir {
8789
struct VfsStdioDir stdio;
8890
struct VfsHddDir usbhsfs;
8991
#endif
92+
void* user;
9093
};
9194
};
9295

@@ -140,7 +143,14 @@ typedef struct FtpVfs {
140143
int (*rename)(const char* src, const char* dst);
141144
} FtpVfs;
142145

143-
void vfs_nx_init(bool enable_devices, bool save_writable, bool mount_bis);
146+
147+
struct VfsNxCustomPath {
148+
const char* name;
149+
void* user;
150+
FtpVfs* func;
151+
};
152+
153+
void vfs_nx_init(const struct VfsNxCustomPath* custom, bool enable_devices, bool save_writable, bool mount_bis);
144154
void vfs_nx_exit(void);
145155
void vfs_nx_add_device(const char* name, enum VFS_TYPE type);
146156

0 commit comments

Comments
 (0)