summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichal Idziorek <m.i@gmx.at>2014-11-23 15:45:31 +0100
committerMichal Idziorek <m.i@gmx.at>2014-11-23 15:45:31 +0100
commit1d472bb0439a83191fcda5e7a778ff0f28a0b6e5 (patch)
treea2ef44129eddacc496f899e4fb6a9e85ce7d35ed
parent6a3ef39feb635f529da9e36975ba77a26c1ff3b4 (diff)
adjusting syscalls
-rw-r--r--kernel/syscalls.c49
-rw-r--r--kernel/syscalls.h1
-rw-r--r--userspace/sys/Makefile22
-rw-r--r--userspace/sys/sys.c26
-rw-r--r--userspace/sys/syscalls.c15
5 files changed, 87 insertions, 26 deletions
diff --git a/kernel/syscalls.c b/kernel/syscalls.c
index 9f29750..9ad07e2 100644
--- a/kernel/syscalls.c
+++ b/kernel/syscalls.c
@@ -288,17 +288,6 @@ int syscall_close(int file,int none1,int none2)
}
-int syscall_fstat(int file, struct stat *st,int none)
-{
- #ifdef LOG_SYSCALLS
- log(FOOLOS_MODULE_NAME,FOOLOS_LOG_INFO,"fstat (file=%d,stat=0x%08X)", file,st);
- #endif
-
- st->st_mode = S_IFCHR;
- return 0;
-}
-
-
int syscall_isatty(int file,int none1,int none2)
{
#ifdef LOG_SYSCALLS
@@ -383,5 +372,41 @@ int syscall_exit(int ret, int none1, int none2)
#ifdef LOG_SYSCALLS
log(FOOLOS_MODULE_NAME,FOOLOS_LOG_INFO,"exit (ret=%d)", ret);
#endif
- syscall_execve(15,0,0); // start shell
+
+ static char *argv[]={"test",NULL};
+ syscall_execve(15,argv,0); // start shell
+}
+
+
+// stat, fstat, lstat
+
+int syscall_stat(const char *path, struct stat *st,int none)
+{
+ #ifdef LOG_SYSCALLS
+ log(FOOLOS_MODULE_NAME,FOOLOS_LOG_INFO,"stat (path=0x%08X,stat=0x%08X)", path,st);
+ #endif
+
+ st->st_mode = S_IFCHR;
+ return 0;
+}
+
+int syscall_fstat(int file, struct stat *st,int none)
+{
+ #ifdef LOG_SYSCALLS
+ log(FOOLOS_MODULE_NAME,FOOLOS_LOG_INFO,"fstat (file=%d,stat=0x%08X)", file,st);
+ #endif
+
+ st->st_mode = S_IFCHR;
+ return 0;
+}
+
+
+int syscall_lstat(const char *path, struct stat *st,int none)
+{
+ #ifdef LOG_SYSCALLS
+ log(FOOLOS_MODULE_NAME,FOOLOS_LOG_INFO,"lstat (path=0x%08X,stat=0x%08X)", path,st);
+ #endif
+
+ st->st_mode = S_IFCHR;
+ return 0;
}
diff --git a/kernel/syscalls.h b/kernel/syscalls.h
index 00df0fa..f42a34b 100644
--- a/kernel/syscalls.h
+++ b/kernel/syscalls.h
@@ -29,6 +29,7 @@
#define SYSCALL_UNLINK 76
#define SYSCALL_WAIT 77
#define SYSCALL_GETPID 78
+#define SYSCALL_LSTAT 79
int syscall_readdir(const char *name,struct fs_dirent *dirs,int max);
diff --git a/userspace/sys/Makefile b/userspace/sys/Makefile
index 7dde55a..374d490 100644
--- a/userspace/sys/Makefile
+++ b/userspace/sys/Makefile
@@ -1,3 +1,25 @@
CC=i686-foolos-gcc
+CFLAGS=-I../..
+CFLAGS+=-w
+
+
+OBJECTS=sys.o syscalls.o crt0.o
+all: $(OBJECTS)
+
+library_install: all
+ mkdir temp
+ mv *.o temp
+ cp /home/miguel/temp/sysroot/usr/lib/libc.a .
+ ar x libc.a
+ rm libc.a
+ cp temp/sys*.o .
+ ar rs libc.a *.o
+ mv libc.a /home/miguel/temp/sysroot/usr/lib/libc.a
+ cp temp/*.o .
+ rm temp -rf
+
+crt_install: all
+ cp crt0.o /home/miguel/temp/sysroot/usr/lib/
+
clean:
-rm *.o
diff --git a/userspace/sys/sys.c b/userspace/sys/sys.c
index ecdf556..ef0d1df 100644
--- a/userspace/sys/sys.c
+++ b/userspace/sys/sys.c
@@ -3,53 +3,61 @@
#include <sys/stat.h>
-// building binutils required this stubs!
+// 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 0;
-}
-
-int fcntl(int fd, int cmd, ...)
-{
return -1;
}
-int lstat(const char *path, struct stat *buf)
+// 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 0;
+ return -1;
}
+// rmdir
int rmdir (const char *pathname)
{
return -1;
}
+// chonw
int chown(const char *path, uid_t owner, gid_t group)
{
- return 0;
+ return -1;
}
diff --git a/userspace/sys/syscalls.c b/userspace/sys/syscalls.c
index 51436fb..314492f 100644
--- a/userspace/sys/syscalls.c
+++ b/userspace/sys/syscalls.c
@@ -1,4 +1,4 @@
-#include "../kernel/syscalls.h"
+#include "kernel/syscalls.h"
/*
char *__env3[]={0};
@@ -43,10 +43,6 @@ int close(int file)
return syscall(SYSCALL_CLOSE,file,0,0);
}
-int fstat(int file, struct stat *st)
-{
- return syscall(SYSCALL_FSTAT,file,st,0);
-}
int isatty(int file)
{
@@ -120,6 +116,15 @@ int stat(const char *file, struct stat *st)
return syscall(SYSCALL_STAT,file,st,0);
}
+int ltat(const char *file, struct stat *st)
+{
+ return syscall(SYSCALL_LSTAT,file,st,0);
+}
+
+int fstat(int file, struct stat *st)
+{
+ return syscall(SYSCALL_FSTAT,file,st,0);
+}
int times(struct tms *buf)
{
return syscall(SYSCALL_TIMES,buf,0,0);