#include #include #include #include // CODE FOR Stack Smashing Protector, TODO: MOVE / and do not duplicate // with kernel.c // http://wiki.osdev.org/Stack_Smashing_Protector #include #include #if UINT32_MAX == UINTPTR_MAX #define STACK_CHK_GUARD 0xe2dee396 #else #define STACK_CHK_GUARD 0x595e9fbd94fda766 #endif uintptr_t __stack_chk_guard = STACK_CHK_GUARD; __attribute__((noreturn)) void __stack_chk_fail(void) { write(1,"stack smashing!\n",16); exit(99); } /////////////////// // required by binutils! long sysconf(int name) { printf("SYSCONF CALLED WITH : %s",name); return 0; } // set file mode creation mask mode_t umask(mode_t mask) { return mask; } // chmod int chmod(const char * path, mode_t mode) { return -1; } // manipulating file descriptor int fcntl(int fd, int cmd, ...) { return -1; } // working directory char *getwd(char *buf) { static char wd[]="/"; buf=wd; return buf; } // check if access allowed int access(const char *pathname, int mode) { //TODO: at leas check if this file exists! return 0; } // update time int utime(const char *filename, const int *x) { return -1; } // rmdir int rmdir (const char *pathname) { return -1; } // chonw int chown(const char *path, uid_t owner, gid_t group) { return -1; } // termios / ncurses int tcgetattr(int fd, struct termios *termios_p) { return 0; } int tcsetattr(int fd, int optional_actions, const struct termios *termios_p){ return 0; } int mkdir(const char *pathname, mode_t mode) { return -1; } int chdir (const char *pathname) { return -1; } speed_t cfgetospeed(const struct termios *termios_p) { return 1; } char *ttyname(int fd) { return "foolterm"; } DIR *opendir(const char *name) { return 0; } int closedir(DIR *dirp) { return 0; } int tcflush(int fd, int queue_selector) { return -1; } long fpathconf(int fd, int name) { return -1; } unsigned int sleep(unsigned int seconds) { return 0; } char *getlogin(void) { return NULL; }