AcessNative - Spawn in libacess-native (with AN_GETPATH syscall)
[tpg/acess2.git] / AcessNative / libacess-native.so_src / exports.c
1 #include "common.h"
2
3 #define acess__SysSpawn _disabled_acess__SysSpawn
4 #include "../ld-acess_src/exports.c"
5
6 void    *_crt0_exit_handler;
7
8 int *libc_geterrno(void)
9 {
10         return &acess__errno;
11 }
12
13 #undef acess__SysSpawn
14
15 int acess__SysSpawn(const char *binary, const char **argv, const char **envp, int nfd, int fds[], struct s_sys_spawninfo *info)
16 {
17          int    argc = 0;
18         while( argv[argc++] )
19                 ;
20
21         Debug("_SysSpawn('%s', %p (%i), %p, %i, %p, %p)",
22                 binary, argv, argc, envp, nfd, fds, info);
23
24         char realpath[256];
25         realpath[255] = 0;
26
27         if( _Syscall(SYS_AN_GETPATH, "<d >s", sizeof(realpath)-1, realpath, binary) <= 0 ) {
28                 Warning("No translation for path '%s'", binary);
29                 acess__errno = -11;
30                 return -1;
31         }
32
33         Warning("TODO: Spawn '%s' = '%s'", binary, realpath);
34
35          int    emulated_tid;
36         int newID = _Syscall(SYS_AN_SPAWN, "<d >d >d",
37                 sizeof(emulated_tid), &emulated_tid,
38                 nfd*sizeof(int), fds,
39                 (info ? sizeof(*info) : 0), info
40                 );
41
42         if( newID <= 0 ) {
43                 return -1;
44         }
45
46         if( acessnative_spawn(realpath, newID, argv, envp) ) {
47         }
48
49         return emulated_tid;
50 }
51
52 void ldacess_DumpLoadedLibraries(void)
53 {
54         Debug("ldacess_DumpLoadedLibraries");
55 }
56

UCC git Repository :: git.ucc.asn.au