forked from iH8sn0w/iDove
-
Notifications
You must be signed in to change notification settings - Fork 0
/
filesystem.c
executable file
·102 lines (85 loc) · 2.58 KB
/
filesystem.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
/**
* GreenPois0n Cynanide - filesystem.c
* Copyright (C) 2010 Chronic-Dev Team
* Copyright (C) 2010 Joshua Hill
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
**/
#include <stdio.h>
#include "filesystem.h"
int(*fs_load_file)(const char *path, void* address, unsigned int* size) = SELF_FS_LOAD_FILE;
void(*fs_mount)(const char *partition, const char *type, const char *path) = SELF_FS_MOUNT;
void(*fs_unmount)(const char *path) = SELF_FS_UNMOUNT;
void* find_fs_mount() {
return find_function("fs_mount", TARGET_BASEADDR, TARGET_BASEADDR);
}
void* find_fs_unmount() {
return 0;
}
void* find_fs_load_file() {
return 0;
}
int fs_init() {
if(fs_mount == NULL) {
//If fs_mount wasn't defined... Lets find it.
fs_mount = find_fs_mount();
}
if(fs_mount == NULL) {
puts("Unable to find fs_mount\n");
}
//fs_unmount = find_fs_unmount();
if(fs_unmount == NULL) {
puts("Unable to find fs_unmount\n");
}
//fs_load_file = find_fs_load_file();
if(fs_load_file == NULL) {
puts("Unable to find fs_load_file\n");
}
if(fs_unmount && fs_load_file) {
cmd_add("fs", &fs_cmd, "perform operations on the filesystem");
}
return 0;
}
int fs_cmd(int argc, CmdArg* argv) {
char* path = NULL;
char* action = NULL;
char* device = NULL;
void* address = NULL;
unsigned int* size = 0;
if(argc < 3) {
puts("usage: fs <mount/unmount/load> [options]\n");
puts(" mount <device> <path> \tmount device to path\n");
puts(" unmount <path> \tunmount specified path\n");
puts(" load <path> <address> \tload file from path to address\n\n");
return 0;
}
action = argv[1].string;
if(argc == 3) {
if(strcmp(action, "umount")) {
path = argv[2].string;
fs_unmount(path);
}
} else if(argc == 4) {
if(!strcmp(action, "mount")) {
path = argv[3].string;
device = argv[2].string;
fs_mount(device, "hfs", path);
} else if(!strcmp(action, "load")) {
path = argv[2].string;
address = (void*) argv[3].uinteger;
fs_load_file(path, address, size);
}
}
return 0;
}