-static int w_open(const char *pathname, int flags, mode_t mode)
-{
- int i, ret;
-
- for (i = 0; i < ARRAY_SIZE(takeover_devs); i++) {
- if (strcmp(pathname, takeover_devs[i].name) == 0) {
- ret = takeover_devs[i].fd;
- break;
- }
- }
-
- if (i == ARRAY_SIZE(takeover_devs))
- ret = open(pathname, flags, mode);
-
- strace("open(%s) = %d\n", pathname, ret);
- return ret;
-}
-
-static void *w_mmap(void *addr, size_t length, int prot, int flags, int fd, off_t offset)
-{
- void *ret;
- if (fd != FAKEDEV_MEM)
- ret = mmap(addr, length, prot, flags, fd, offset);
- else
- ret = emu_mmap_dev(length, prot, flags, offset);
-
- // threads are using heap before they mmap their stack
- // printf needs valid stack for pthtead/errno
- if (((long)&ret & 0xf0000000) == 0xb0000000)
- strace("mmap(%p, %x, %x, %x, %d, %lx) = %p\n", addr, length, prot, flags, fd, (long)offset, ret);
- return ret;
-}
-#define w_mmap_ w_mmap
-
-ssize_t w_read(int fd, void *buf, size_t count)
-{
- ssize_t ret;
- if (fd != FAKEDEV_GPIO)
- return read(fd, buf, count);
-
- ret = emu_read_gpiodev(buf, count);
- //printf("read(%d, %p, %d) = %d\n", fd, buf, count, ret);
- return ret;
-}