| | 1 | #include <stdio.h> |
| | 2 | #include <stdlib.h> |
| | 3 | #include <sys/types.h> |
| | 4 | #include <sys/stat.h> |
| | 5 | #include <fcntl.h> |
| | 6 | #include <sys/mman.h> |
| | 7 | #include <unistd.h> |
| | 8 | #include <sys/ioctl.h> |
| | 9 | #include <signal.h> |
| | 10 | #include <termios.h> |
| | 11 | |
| | 12 | #include "llibc.h" |
| | 13 | |
| | 14 | #define printf(fmt, ...) \ |
| | 15 | g_fprintf(1, fmt, ##__VA_ARGS__) |
| | 16 | |
| | 17 | int real_open(const char *pathname, int flags, ...); |
| | 18 | FILE *real_fopen(const char *path, const char *mode); |
| | 19 | void *real_mmap(void *addr, size_t length, int prot, int flags, int fd, off_t offset); |
| | 20 | int real_munmap(void *addr, size_t length); |
| | 21 | int real_read(int fd, void *buf, size_t count); |
| | 22 | int real_ioctl(int fd, int request, void *argp); |
| | 23 | int real_close(int fd); |
| | 24 | int real_sigaction(int signum, const struct sigaction *act, struct sigaction *oldact); |
| | 25 | typedef struct sigaction sigaction_t; |
| | 26 | int real_tcgetattr(int fd, struct termios *termios_p); |
| | 27 | int real_tcsetattr(int fd, int optional_actions, const struct termios *termios_p); |
| | 28 | int real_system(const char *command); |
| | 29 | // exec* - skipped |
| | 30 | int real_execve(const char *filename, char *const argv[], char *const envp[]); |
| | 31 | int real_chdir(const char *path); |
| | 32 | void real_sleep(unsigned int seconds); |
| | 33 | void real_usleep(unsigned int usec); |
| | 34 | void __attribute__((noreturn)) |
| | 35 | real_exit(int status); |
| | 36 | |
| | 37 | #define open real_open |
| | 38 | #define fopen real_fopen |
| | 39 | #define mmap real_mmap |
| | 40 | #define munmap real_munmap |
| | 41 | #define read real_read |
| | 42 | #define ioctl real_ioctl |
| | 43 | #define close real_close |
| | 44 | #define sigaction real_sigaction |
| | 45 | #define tcgetattr real_tcgetattr |
| | 46 | #define tcsetattr real_tcsetattr |
| | 47 | #define system real_system |
| | 48 | #define execl real_execl |
| | 49 | #define execlp real_execlp |
| | 50 | #define execle real_execle |
| | 51 | #define execv real_execv |
| | 52 | #define execvp real_execvp |
| | 53 | #define execve real_execve |
| | 54 | #define chdir real_chdir |
| | 55 | #define sleep real_sleep |
| | 56 | #define usleep real_usleep |
| | 57 | #define exit real_exit |
| | 58 | |