Skip to content
Open
113 changes: 67 additions & 46 deletions so3/arch/arm32/include/asm/syscall_number.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,61 +24,82 @@
*/

#define SYSCALL_EXIT 1
#define SYSCALL_EXECVE 2
#define SYSCALL_WAITPID 3
#define SYSCALL_READ 4
#define SYSCALL_WRITE 5
#define SYSCALL_FORK 7
#define SYSCALL_PTRACE 8
#define SYSCALL_READDIR 9
#define SYSCALL_OPEN 14
#define SYSCALL_CLOSE 15
#define SYSCALL_THREAD_CREATE 16
#define SYSCALL_THREAD_JOIN 17
#define SYSCALL_THREAD_EXIT 18
#define SYSCALL_PIPE 19
#define SYSCALL_IOCTL 20
#define SYSCALL_FCNTL 21
#define SYSCALL_DUP 22
#define SYSCALL_DUP2 23

#define SYSCALL_SOCKET 26
#define SYSCALL_BIND 27
#define SYSCALL_LISTEN 28
#define SYSCALL_ACCEPT 29
#define SYSCALL_CONNECT 30
#define SYSCALL_RECV 31
#define SYSCALL_SEND 32
#define SYSCALL_SENDTO 33

#define SYSCALL_STAT 34
#define SYSCALL_MMAP 35
#define SYSCALL_GETPID 37

#define SYSCALL_GETTIMEOFDAY 38
#define SYSCALL_SETTIMEOFDAY 39
#define SYSCALL_CLOCK_GETTIME 40
#define SYSCALL_FORK 2
#define SYSCALL_READ 3
#define SYSCALL_WRITE 4
#define SYSCALL_OPEN 5
#define SYSCALL_CLOSE 6

#define SYSCALL_THREAD_YIELD 43
#define SYSCALL_EXECVE 11

#define SYSCALL_SBRK 45
#define SYSCALL_SIGACTION 46
#define SYSCALL_KILL 47
#define SYSCALL_SIGRETURN 48
#define SYSCALL_LSEEK 19
#define SYSCALL_GETPID 20

#define SYSCALL_LSEEK 50
#define SYSCALL_PTRACE 26

#define SYSCALL_MUTEX_LOCK 60
#define SYSCALL_MUTEX_UNLOCK 61
#define SYSCALL_KILL 37

#define SYSCALL_DUP 41
#define SYSCALL_PIPE 42

#define SYSCALL_BRK 45

#define SYSCALL_NANOSLEEP 70
#define SYSCALL_IOCTL 54

#define SYSCALL_SYSINFO 99
#define SYSCALL_DUP2 63

#define SYSCALL_SETSOCKOPT 110
#define SYSCALL_RECVFROM 111
#define SYSCALL_GETTIMEOFDAY_TIME32 78

#define SYSCALL_WAIT4 114

#define SYSCALL_SIGRETURN 119

#define SYSCALL_READV 145
#define SYSCALL_WRITEV 146

#define SYSCALL_NANOSLEEP 162

#define SYSCALL_RT_SIGRETURN 173
#define SYSCALL_RT_SIGACTION 174

#define SYSCALL_MMAP2 192

#define SYSCALL_STAT64 195

#define SYSCALL_GETDENTS64 217

#define SYSCALL_CLOCK_GETTIME32 263

#define SYSCALL_SOCKET 281
#define SYSCALL_BIND 282
#define SYSCALL_CONNECT 283
#define SYSCALL_LISTEN 284
#define SYSCALL_ACCEPT 285

#define SYSCALL_SEND 289
#define SYSCALL_SENDTO 290

#define SYSCALL_RECV 291
#define SYSCALL_RECVFROM 292

#define SYSCALL_SETSOCKOPT 294

#define SYSCALL_OPENAT 322

#define SYSCALL_FSTATAT64 327

#define SYSCALL_DUP3 358
#define SYSCALL_PIPE2 359

#define SYSCALL_CLOCK_GETTIME64 403

/* Following syscalls still need to be aligned */
#define SYSCALL_THREAD_CREATE 16
#define SYSCALL_THREAD_JOIN 17
#define SYSCALL_THREAD_EXIT 18
#define SYSCALL_THREAD_YIELD 43

#define SYSCALL_MUTEX_LOCK 60
#define SYSCALL_MUTEX_UNLOCK 61

#endif /* ARCH_ARM32_SYSCALL_NUMBER_H */
2 changes: 1 addition & 1 deletion so3/arch/arm64/exception.S
Original file line number Diff line number Diff line change
Expand Up @@ -557,7 +557,7 @@ el01_sync_handler:

// Check if sigreturn has been called. In this case, we
// clean the stack frame which has been used to manage the user handler.
cmp x8, #SYSCALL_SIGRETURN
cmp x8, #SYSCALL_RT_SIGRETURN
bne __ret_from_fork

// Reset the stack frame by removing the one issued from sigreturn
Expand Down
105 changes: 56 additions & 49 deletions so3/arch/arm64/include/asm/syscall_number.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,63 +22,70 @@
/*
* Syscall number definition
*/
#define SYSCALL_DUP 23
#define SYSCALL_DUP3 24

#define SYSCALL_EXIT 1
#define SYSCALL_EXECVE 2
#define SYSCALL_WAITPID 3
#define SYSCALL_READ 4
#define SYSCALL_WRITE 5
#define SYSCALL_FORK 7
#define SYSCALL_PTRACE 8
#define SYSCALL_READDIR 9
#define SYSCALL_OPEN 14
#define SYSCALL_CLOSE 15
#define SYSCALL_THREAD_CREATE 16
#define SYSCALL_THREAD_JOIN 17
#define SYSCALL_THREAD_EXIT 18
#define SYSCALL_PIPE 19
#define SYSCALL_IOCTL 20
#define SYSCALL_FCNTL 21
#define SYSCALL_DUP 22
#define SYSCALL_DUP2 23

#define SYSCALL_SOCKET 26
#define SYSCALL_BIND 27
#define SYSCALL_LISTEN 28
#define SYSCALL_ACCEPT 29
#define SYSCALL_CONNECT 30
#define SYSCALL_RECV 31
#define SYSCALL_SEND 32
#define SYSCALL_SENDTO 33

#define SYSCALL_STAT 34
#define SYSCALL_MMAP 35
#define SYSCALL_GETPID 37

#define SYSCALL_GETTIMEOFDAY 38
#define SYSCALL_SETTIMEOFDAY 39
#define SYSCALL_CLOCK_GETTIME 40

#define SYSCALL_THREAD_YIELD 43

#define SYSCALL_SBRK 45
#define SYSCALL_SIGACTION 46
#define SYSCALL_KILL 47
#define SYSCALL_SIGRETURN 48
#define SYSCALL_IOCTL 29

#define SYSCALL_LSEEK 50
#define SYSCALL_OPENAT 56
#define SYSCALL_CLOSE 57

#define SYSCALL_MUTEX_LOCK 60
#define SYSCALL_MUTEX_UNLOCK 61
#define SYSCALL_PIPE2 59

#define SYSCALL_GETDENTS64 61
#define SYSCALL_LSEEK 62
#define SYSCALL_READ 63
#define SYSCALL_WRITE 64
#define SYSCALL_READV 65
#define SYSCALL_WRITEV 66

#define SYSCALL_NANOSLEEP 70
#define SYSCALL_NEWFSTATAT 79

#define SYSCALL_EXIT 93

#define SYSCALL_NANOSLEEP 101

#define SYSCALL_CLOCK_GETTIME 113

#define SYSCALL_PTRACE 117

#define SYSCALL_KILL 129

#define SYSCALL_RT_SIGACTION 134

#define SYSCALL_RT_SIGRETURN 139

#define SYSCALL_SYSINFO 99
#define SYSCALL_GETTIMEOFDAY 169

#define SYSCALL_SETSOCKOPT 110
#define SYSCALL_RECVFROM 111
#define SYSCALL_GETPID 172

#define SYSCALL_SOCKET 198

#define SYSCALL_BIND 200
#define SYSCALL_LISTEN 201
#define SYSCALL_ACCEPT 202
#define SYSCALL_CONNECT 203

#define SYSCALL_SENDTO 206
#define SYSCALL_RECVFROM 207
#define SYSCALL_SETSOCKOPT 208

#define SYSCALL_BRK 214

#define SYSCALL_EXECVE 221
#define SYSCALL_MMAP 222

#define SYSCALL_WAIT4 260

/* Following syscalls still need to be aligned */
#define SYSCALL_FORK 7 // => clone

#define SYSCALL_THREAD_CREATE 16
#define SYSCALL_THREAD_JOIN 17
#define SYSCALL_THREAD_EXIT 18
#define SYSCALL_THREAD_YIELD 43

#define SYSCALL_MUTEX_LOCK 60
#define SYSCALL_MUTEX_UNLOCK 61

#endif /* ARCH_ARM64_SYSCALL_NUMBER_H */
4 changes: 2 additions & 2 deletions so3/fs/elf.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,12 @@ uint8_t *elf_load_buffer(const char *filename)
struct stat st;

/* open and read file */
fd = sys_do_open(filename, O_RDONLY);
fd = sys_do_open(filename, O_RDONLY, 0);

if (fd < 0)
return NULL;

if (sys_do_stat(filename, &st))
if (sys_do_newfstatat(AT_FDCWD, filename, &st, 0))
return NULL;

if (!st.st_size)
Expand Down
3 changes: 1 addition & 2 deletions so3/fs/fat/fat.c
Original file line number Diff line number Diff line change
Expand Up @@ -415,8 +415,7 @@ int fat_stat(const char *path, struct stat *st)
}

time_fat_fat2so3(finfo.fdate, finfo.ftime, &tm);
st->st_mtim = tm.tv_sec;
strcpy(st->st_name, path);
st->st_mtime = tm.tv_sec;
st->st_size = finfo.fsize;

return 0;
Expand Down
Loading