diff --git a/mlibc.c b/mlibc.c index 562079b6..1e64cfb4 100644 --- a/mlibc.c +++ b/mlibc.c @@ -114,6 +114,24 @@ write (int fd, char const* s, int n) ); } +int +fsync (int fd) +{ + int r; + //syscall (SYS_fsync, fd)); + asm ( + "mov %1,%%ebx\n\t" + + "mov $0x76, %%eax\n\t" + "int $0x80\n\t" + "mov %%eax,%0\n\t" + : "=r" (r) + : "" (fd) + : "eax", "ebx" + ); + return r; +} + void * brk (void *p) { diff --git a/module/mes/libc-i386.mes b/module/mes/libc-i386.mes index 1bc66129..b72a750b 100644 --- a/module/mes/libc-i386.mes +++ b/module/mes/libc-i386.mes @@ -92,6 +92,18 @@ #xc3 ; ret )) +(define (i386:fsync f g ta t d) + '( + #x55 ; push %ebp + #x89 #xe5 ; mov %esp,%ebp + + #x8b #x5d #x08 ; mov 0x8(%ebp),%ebx + #xb8 #x76 #x00 #x00 #x00 ; mov $0x76,%eax + #xcd #x80 ; int $0x80 + + #xc9 ; leave + #xc3 ; ret + )) (define (i386:_start) (string-append ".byte" @@ -110,4 +122,5 @@ (cons "open" (list i386:open)) (cons "read" (list i386:read)) (cons "write" (list i386:write)) + (cons "fsync" (list i386:fsync)) (cons "brk" (list i386:brk))))