os: implement and smoketest os.Chdir

This commit is contained in:
Dan Kegel
2021-12-04 11:17:28 -08:00
committed by Ron Evans
parent d62c9696fb
commit e668c8c1a7
3 changed files with 66 additions and 0 deletions
+13
View File
@@ -59,6 +59,15 @@ func Open(path string, flag int, mode uint32) (fd int, err error) {
return
}
func Chdir(path string) (err error) {
data := cstring(path)
fail := int(libc_chdir(&data[0]))
if fail < 0 {
err = getErrno()
}
return
}
func Mkdir(path string, mode uint32) (err error) {
data := cstring(path)
fail := int(libc_mkdir(&data[0], mode))
@@ -198,6 +207,10 @@ func libc_mmap(addr unsafe.Pointer, length uintptr, prot, flags, fd int32, offse
//export mprotect
func libc_mprotect(addr unsafe.Pointer, len uintptr, prot int32) int32
// int chdir(const char *pathname, mode_t mode);
//export chdir
func libc_chdir(pathname *byte) int32
// int mkdir(const char *pathname, mode_t mode);
//export mkdir
func libc_mkdir(pathname *byte, mode uint32) int32