summaryrefslogtreecommitdiff
path: root/legacy/escape/src/lib/escape_mman.c
diff options
context:
space:
mode:
authorYouness Alaoui <kakaroto@kakaroto.homelinux.net>2011-09-07 07:18:07 +0000
committerYouness Alaoui <kakaroto@kakaroto.homelinux.net>2011-09-07 07:18:07 +0000
commitf26611c3de57b4a90232aed44535e80d3c855ea7 (patch)
tree9ed07ed608ba4a47b17d6b62af791ef6cb1033ef /legacy/escape/src/lib/escape_mman.c
parentdf91f38ffbbcbaa375e4f62d984d7ef1e3000d91 (diff)
Adding Escape: A compatibility library for jailbroken PS3s (PSL1GHT)
SVN revision: 63260
Diffstat (limited to 'legacy/escape/src/lib/escape_mman.c')
-rw-r--r--legacy/escape/src/lib/escape_mman.c67
1 files changed, 67 insertions, 0 deletions
diff --git a/legacy/escape/src/lib/escape_mman.c b/legacy/escape/src/lib/escape_mman.c
new file mode 100644
index 0000000000..7b52804328
--- /dev/null
+++ b/legacy/escape/src/lib/escape_mman.c
@@ -0,0 +1,67 @@
1#ifdef HAVE_CONFIG_H
2# include "config.h"
3#endif /* HAVE_CONFIG_H */
4
5#include <stdio.h>
6#include <stdlib.h>
7#include <sys/types.h>
8#include <unistd.h>
9
10#include "sys/mman.h"
11
12/***** API *****/
13
14
15void *
16mmap(void *addr __UNUSED__,
17 size_t len,
18 int prot,
19 int flags,
20 int fd,
21 off_t offset)
22{
23 void *data;
24 size_t size;
25
26 data = malloc(len);
27 if (!data)
28 {
29 fprintf (stderr, "[Escape] [mmap] malloc failed\n");
30 return MAP_FAILED;
31 }
32
33 size = read(fd, data, len);
34 if (size != len)
35 {
36 fprintf (stderr, "[Escape] [mmap] read failed\n");
37 free(data);
38 return MAP_FAILED;
39 }
40
41 if (lseek(fd, -len, SEEK_CUR) == -1)
42 {
43 fprintf (stderr, "[Escape] [mmap] lseek failed\n");
44 free(data);
45 return MAP_FAILED;
46 }
47
48 return data;
49}
50
51int
52munmap(void *addr,
53 size_t len __UNUSED__)
54{
55 if (addr && (addr != MAP_FAILED))
56 free(addr);
57
58 return 0;
59}
60
61
62int madvise(void *addr __UNUSED__,
63 size_t length __UNUSED__,
64 int advice __UNUSED__)
65{
66 return 0;
67}