const char *to;
} path_map[] = {
{ "/mnt/tmp", "./tmp" },
+ { "/mnt/sd", "./mntsd" },
};
-static const char *wrap_path(const char *path)
+const char *emu_wrap_path(const char *path)
{
char *buff, *p;
size_t size;
int i, len;
+ long ret;
// do only path mapping for now
for (i = 0; i < ARRAY_SIZE(path_map); i++) {
snprintf(buff + len, size - len, "%s%s", path_map[i].to,
path + len + strlen(path_map[i].from));
dbg("mapped path \"%s\" -> \"%s\"\n", path, buff);
+
+ ret = g_mkdir_raw(path_map[i].to, 0666);
+ if (ret != 0 && ret != -EEXIST)
+ err("mkdir(%s): %ld\n", path_map[i].to, ret);
+
return buff;
}
}
return path;
}
-static void wrap_path_free(const char *w_path, const char *old_path)
+void emu_wrap_path_free(const char *w_path, const char *old_path)
{
if (w_path != old_path)
free((void *)w_path);
const char *w_path;
FILE *ret;
- w_path = wrap_path(path);
+ w_path = emu_wrap_path(path);
ret = fopen(w_path, mode);
- wrap_path_free(w_path, path);
+ emu_wrap_path_free(w_path, path);
return ret;
}
// absolute path, but not a system command
need_ginge = 1;
- p2 = wrap_path(command);
+ p2 = emu_wrap_path(command);
if (need_ginge) {
make_local_path(tmp_path, sizeof(tmp_path), "ginge_prep");
p = tmp_path + strlen(tmp_path);
}
else
snprintf(tmp_path, sizeof(tmp_path), "%s", p2);
- wrap_path_free(p2, command);
+ emu_wrap_path_free(p2, command);
dbg("system: \"%s\"\n", tmp_path);
make_local_path(prep_path, 512, "ginge_prep");
new_argv[0] = prep_path;
new_argv[1] = "--nomenu";
- new_argv[2] = wrap_path(filename);
+ new_argv[2] = emu_wrap_path(filename);
if (argv[0] != NULL)
for (i = 1; argv[i] != NULL; i++)
void *emu_do_fopen(const char *path, const char *mode);
int emu_do_system(const char *command);
long emu_do_execve(const char *filename, char *const argv[], char *const envp[]);
+const char *emu_wrap_path(const char *path);
+void emu_wrap_path_free(const char *w_path, const char *old_path);
int host_init(void);
int host_read_btns(void);
#endif
};
-static long w_open_raw(const char *pathname, int flags, mode_t mode)
+long w_open_raw(const char *pathname, int flags, mode_t mode)
{
long ret;
int i;
}
}
- if (i == ARRAY_SIZE(takeover_devs))
- ret = g_open_raw(pathname, flags, mode);
+ if (i == ARRAY_SIZE(takeover_devs)) {
+ const char *w_path = emu_wrap_path(pathname);
+ ret = g_open_raw(w_path, flags, mode);
+ emu_wrap_path_free(w_path, pathname);
+ }
if (ret >= 0) {
for (i = 0; emu_interesting_fds[i].name != NULL; i++) {
};
#define sig_mask_open_a1 sig_mask_all
+static const unsigned int sig_hw_open[] = {
+ 0xef900005, // svc 0x900005
+ 0xe3700a01, // cmn r0, #0x1000
+ 0xe1a04000, // mov r4, r0
+};
+#define sig_mask_hw_open sig_mask_all
+
static const unsigned int sig_mmap[] = {
0xe92d000f, // push {r0, r1, r2, r3}
0xe1a0000d, // mov r0, sp
" ldmfd sp!, {r1-r3,r12,lr,pc}\n" \
);
+SVC_CMN_R0_MOV_R4_WRAPPER(hw_open, w_open_raw)
SVC_CMN_R0_MOV_R4_WRAPPER(hw_read, w_read_raw)
SVC_CMN_R0_MOV_R4_WRAPPER(hw_ioctl, w_ioctl_raw)
SVC_CMN_R0_MOV_R4_WRAPPER(hw_execve, w_execve_raw)
} patches[] = {
PATCH (open),
PATCH_(open_a1, w_open, 0),
+ PATCH_(hw_open, hw_open, 1),
PATCH (mmap),
PATCH (mmap2), // mmap2 syscall
PATCH (munmap),
raw_syscall_easy g_ioctl_raw, __NR_ioctl
raw_syscall_easy g_close_raw, __NR_close
raw_syscall_easy g_chdir_raw, __NR_chdir
+raw_syscall_easy g_mkdir_raw, __NR_mkdir
raw_syscall_easy g_futex_raw, __NR_futex
raw_syscall_easy g_nanosleep_raw, __NR_nanosleep
raw_syscall_easy g_readlink_raw, __NR_readlink
long g_ioctl_raw(int fd, unsigned long request, ...);
long g_close_raw(int fd);
long g_chdir_raw(const char *path);
+long g_mkdir_raw(const char *pathname, unsigned int mode);
long g_futex_raw(int *uaddr, int op, int val,
const struct timespec *timeout);
long g_nanosleep_raw(const struct timespec *req, struct timespec *rem);