this repo has no description
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Implemented sys_statfs()

+104 -1
+1
src/kernel/emulation/linux/CMakeLists.txt
··· 60 60 stat/lstat.c 61 61 stat/stat.c 62 62 stat/getfsstat.c 63 + stat/statfs.c 63 64 stat/common.c 64 65 dirent/getdirentries.c 65 66 time/gettimeofday.c
+1 -1
src/kernel/emulation/linux/stat/getfsstat.c
··· 31 31 32 32 fd = sys_open("/proc/self/mounts", O_RDONLY, 0); 33 33 if (fd < 0) 34 - return fd; 34 + return error_linux_to_bsd(fd); 35 35 36 36 __simple_readline_init(&rbuf); 37 37
+90
src/kernel/emulation/linux/stat/statfs.c
··· 1 + #include "statfs.h" 2 + #include "common.h" 3 + #include "../base.h" 4 + #include "../errno.h" 5 + #include "../simple.h" 6 + #include "../../../../libc/include/fcntl.h" 7 + #include "../fcntl/open.h" 8 + #include "../unistd/close.h" 9 + #include <asm/unistd.h> 10 + #include <stddef.h> 11 + 12 + extern char *strtok_r(char *str, const char *delim, char **saveptr); 13 + extern unsigned long strlcpy(char* dst, const char* src, unsigned long size); 14 + extern unsigned long strlen(const char* str); 15 + extern int strncmp(const char* s1, const char* s2, unsigned long len); 16 + 17 + long sys_statfs(const char* path, struct bsd_statfs* buf) 18 + { 19 + #ifdef __x86_64__ 20 + return sys_statfs64(path, (struct bsd_statfs64*) buf); 21 + #else 22 + # warning Not implemented 23 + return 0; 24 + #endif 25 + } 26 + 27 + long sys_statfs64(const char* path, struct bsd_statfs64* buf) 28 + { 29 + int fd, ret; 30 + struct simple_readline_buf rbuf; 31 + struct linux_statfs64 lbuf; 32 + char line[512]; 33 + int max_len = 0; 34 + 35 + #ifdef __NR_statfs64 36 + ret = LINUX_SYSCALL2(__NR_statfs64, path, &lbuf); 37 + #else 38 + ret = LINUX_SYSCALL2(__NR_statfs, path, &lbuf); 39 + #endif 40 + 41 + if (ret < 0) 42 + return errno_linux_to_bsd(ret); 43 + 44 + statfs_linux_to_bsd64(&lbuf, buf); 45 + 46 + fd = sys_open("/proc/self/mounts", O_RDONLY, 0); 47 + if (fd < 0) 48 + return errno_linux_to_bsd(fd); 49 + 50 + __simple_readline_init(&rbuf); 51 + 52 + buf->f_mntonname[0] = 0; 53 + buf->f_fstypename[0] = 0; 54 + buf->f_mntfromname[0] = 0; 55 + 56 + while (__simple_readline(fd, &rbuf, line, sizeof(line))) 57 + { 58 + char* p; 59 + char* saveptr; 60 + char* mntfrom; 61 + int len; 62 + 63 + p = strtok_r(line, " ", &saveptr); 64 + if (p == NULL) 65 + continue; 66 + 67 + mntfrom = p; 68 + p = strtok_r(NULL, " ", &saveptr); 69 + if (p == NULL) 70 + continue; 71 + 72 + len = strlen(p); 73 + if (strncmp(p, path, len) != 0 || len < max_len) 74 + continue; 75 + 76 + max_len = len; 77 + strlcpy(buf->f_mntonname, p, sizeof(buf->f_mntonname)); 78 + 79 + p = strtok_r(NULL, " ", &saveptr); 80 + if (p == NULL) 81 + continue; 82 + 83 + strlcpy(buf->f_fstypename, p, sizeof(buf->f_fstypename)); 84 + strlcpy(buf->f_mntfromname, mntfrom, sizeof(buf->f_mntfromname)); 85 + } 86 + 87 + sys_close(fd); 88 + return 0; 89 + } 90 +
+9
src/kernel/emulation/linux/stat/statfs.h
··· 1 + #ifndef LINUX_STATFS_H 2 + #define LINUX_STATFS_H 3 + #include "common.h" 4 + 5 + long sys_statfs(const char* path, struct bsd_statfs* buf); 6 + long sys_statfs64(const char* path, struct bsd_statfs64* buf); 7 + 8 + #endif 9 +
+3
src/kernel/emulation/linux/syscalls.c
··· 46 46 #include "stat/fstat.h" 47 47 #include "stat/stat.h" 48 48 #include "stat/lstat.h" 49 + #include "stat/statfs.h" 49 50 #include "stat/getfsstat.h" 50 51 #include "time/gettimeofday.h" 51 52 #include "wqueue/bsdthread_register.h" ··· 86 87 [147] = sys_setsid, 87 88 [153] = sys_pread, 88 89 [154] = sys_pwrite, 90 + [157] = sys_statfs, 89 91 [181] = sys_setgid, 90 92 [182] = sys_setegid, 91 93 [183] = sys_seteuid, ··· 104 106 [339] = sys_fstat64, 105 107 [340] = sys_lstat64, 106 108 [344] = sys_getdirentries64, 109 + [345] = sys_statfs64, 107 110 [347] = sys_getfsstat64, 108 111 [366] = sys_bsdthread_register, 109 112 [372] = sys_thread_selfid,