diff --git a/lib/libc-gcc.c b/lib/libc-gcc.c index 303d4e3e..f951433c 100644 --- a/lib/libc-gcc.c +++ b/lib/libc-gcc.c @@ -140,6 +140,26 @@ open (char const *s, int flags, ...) #endif } +int +chmod (char const *s, int mode) +{ +#if !__TINYC__ + int r; + //syscall (SYS_chmod, mode)); + asm ( + "mov %1,%%ebx\n\t" + "mov %2,%%ecx\n\t" + "mov $0x0f,%%eax\n\t" + "int $0x80\n\t" + "mov %%eax,%0\n\t" + : "=r" (r) + : "" (s), "" (mode) + : "eax", "ebx", "ecx" + ); + return r; +#endif +} + int access (char const *s, int mode) { diff --git a/lib/libc-mes.c b/lib/libc-mes.c index 3fbd68be..670eaca4 100644 --- a/lib/libc-mes.c +++ b/lib/libc-mes.c @@ -68,6 +68,16 @@ open () asm ("int____$0x80"); // int $0x80 } +void +chmod () +{ + asm ("mov____0x8(%ebp),%ebx !8"); // mov 0x8(%ebp),%ebx + asm ("mov____0x8(%ebp),%ecx !12"); // mov 0x8(%ebp),%ecx + + asm ("mov____$i32,%eax SYS_chmod"); // mov $0x0f,%eax + asm ("int____$0x80"); // int $0x80 +} + void access () { diff --git a/stage0/x86.M1 b/stage0/x86.M1 index cbac03e2..f1554a22 100644 --- a/stage0/x86.M1 +++ b/stage0/x86.M1 @@ -195,6 +195,7 @@ DEFINE SYS_write 04000000 DEFINE SYS_open 05000000 DEFINE SYS_close 06000000 DEFINE SYS_unlink 0a000000 +DEFINE SYS_chmod 0f000000 DEFINE SYS_lseek 13000000 DEFINE SYS_access 21000000 DEFINE SYS_brk 2d000000