mlibc: Mescc-tools support: chmod.

* stage0/x86.M1 (SYS_chmod): New define.
* lib/libc-gcc.c (chmod): New function.
* lib/libc-mes.c (chmod): New function.
This commit is contained in:
Jan Nieuwenhuizen 2017-11-26 18:45:10 +01:00
parent e8884d83e1
commit 49d01a46fa
3 changed files with 31 additions and 0 deletions

View file

@ -140,6 +140,26 @@ open (char const *s, int flags, ...)
#endif #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 int
access (char const *s, int mode) access (char const *s, int mode)
{ {

View file

@ -68,6 +68,16 @@ open ()
asm ("int____$0x80"); // int $0x80 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 void
access () access ()
{ {

View file

@ -195,6 +195,7 @@ DEFINE SYS_write 04000000
DEFINE SYS_open 05000000 DEFINE SYS_open 05000000
DEFINE SYS_close 06000000 DEFINE SYS_close 06000000
DEFINE SYS_unlink 0a000000 DEFINE SYS_unlink 0a000000
DEFINE SYS_chmod 0f000000
DEFINE SYS_lseek 13000000 DEFINE SYS_lseek 13000000
DEFINE SYS_access 21000000 DEFINE SYS_access 21000000
DEFINE SYS_brk 2d000000 DEFINE SYS_brk 2d000000