summaryrefslogtreecommitdiff
path: root/xxx/sys/sys.c
diff options
context:
space:
mode:
Diffstat (limited to 'xxx/sys/sys.c')
-rw-r--r--xxx/sys/sys.c188
1 files changed, 188 insertions, 0 deletions
diff --git a/xxx/sys/sys.c b/xxx/sys/sys.c
new file mode 100644
index 0000000..4ff77f3
--- /dev/null
+++ b/xxx/sys/sys.c
@@ -0,0 +1,188 @@
+#include <unistd.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <sys/termios.h>
+
+// CODE FOR Stack Smashing Protector, TODO: MOVE / and do not duplicate
+// with kernel.c
+// http://wiki.osdev.org/Stack_Smashing_Protector
+#include <stdint.h>
+#include <stdlib.h>
+
+#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("UNIMPL: sysconf\n");
+ printf("SYSCONF CALLED WITH : %s\n",name);
+ return 0;
+}
+
+// set file mode creation mask
+mode_t umask(mode_t mask)
+{
+ printf("UNIMPL: umask\n");
+ return mask;
+}
+
+// chmod
+int chmod(const char * path, mode_t mode)
+{
+ printf("UNIMPL: chmod\n");
+ return -1;
+}
+
+// manipulating file descriptor
+int fcntl(int fd, int cmd, ...)
+{
+ printf("UNIMPL: fcntl\n");
+ return -1;
+}
+
+// working directory
+char *getwd(char *buf)
+{
+ printf("UNIMPL: getwd\n");
+ static char wd[]="/";
+ buf=wd;
+ return buf;
+}
+
+// check if access allowed
+int access(const char *pathname, int mode)
+{
+ printf("UNIMPL: access\n");
+ //TODO: at leas check if this file exists!
+ return 0;
+}
+
+// update time
+int utime(const char *filename, const int *x)
+{
+ printf("UNIMPL: utime\n");
+ return -1;
+}
+
+// rmdir
+int rmdir (const char *pathname)
+{
+ printf("UNIMPL: rmdir\n");
+ return -1;
+}
+
+// chonw
+int chown(const char *path, uid_t owner, gid_t group)
+{
+ printf("UNIMPL: chown\n");
+ return -1;
+}
+
+// termios / ncurses
+int tcgetattr(int fd, struct termios *termios_p)
+{
+ printf("UNIMPL: tcgetattr\n");
+ return 0;
+}
+int tcsetattr(int fd, int optional_actions, const struct termios *termios_p){
+ printf("UNIMPL: tsetattr\n");
+ return 0;
+}
+int mkdir(const char *pathname, mode_t mode)
+{
+ printf("UNIMPL: mkdir\n");
+ return -1;
+}
+int chdir (const char *pathname)
+{
+ printf("UNIMPL: chdir\n");
+ return -1;
+}
+
+// TODO; check if this is allright for not-real serial line!?
+// http://www.chemie.fu-berlin.de/chemnet/use/info/libc/libc_12.html#SEC242
+// here they write something about padding may be affected? experiment.
+speed_t cfgetospeed(const struct termios *termios_p)
+{
+// printf("UNIMPL: cfgetospeed\n");
+ return 9600;
+}
+
+char *ttyname(int fd)
+{
+ printf("UNIMPL: ttyname\n");
+ return "foolterm";
+}
+
+
+DIR *opendir(const char *name)
+{
+ printf("UNIMPL: opendir\n");
+ return 0;
+}
+int closedir(DIR *dirp)
+{
+ printf("UNIMPL: closedir\n");
+ return 0;
+}
+
+
+int tcflush(int fd, int queue_selector)
+{
+ printf("UNIMPL: tcflush\n");
+ return -1;
+}
+long fpathconf(int fd, int name)
+{
+ printf("UNIMPL: fpathconf\n");
+ return -1;
+}
+
+
+unsigned int sleep(unsigned int seconds)
+{
+ printf("UNIMPL: sleep\n");
+ return 0;
+}
+
+char *getlogin(void)
+{
+ printf("UNIMPL: getlogin\n");
+ return NULL;
+}
+
+int ioctl(int fd, unsigned long request, ...)
+{
+ printf("UNIMPL: ioctl\n");
+ return -1;
+}
+
+int gtty(int fd, void *buf)
+{
+ // printf("UNIMPL: gettty\n");
+ return -1;
+}
+
+int stty(int fd, void *buf)
+{
+ // printf("UNIMPL: settty\n");
+ return -1;
+}
+