os: implement and smoketest os.Chmod

This commit is contained in:
Dan Kegel
2021-12-04 13:50:32 -08:00
committed by Ron Evans
parent e668c8c1a7
commit be7bbba4ca
4 changed files with 106 additions and 16 deletions
+13
View File
@@ -68,6 +68,15 @@ func Chdir(path string) (err error) {
return
}
func Chmod(path string, mode uint32) (err error) {
data := cstring(path)
fail := int(libc_chmod(&data[0], mode))
if fail < 0 {
err = getErrno()
}
return
}
func Mkdir(path string, mode uint32) (err error) {
data := cstring(path)
fail := int(libc_mkdir(&data[0], mode))
@@ -211,6 +220,10 @@ func libc_mprotect(addr unsafe.Pointer, len uintptr, prot int32) int32
//export chdir
func libc_chdir(pathname *byte) int32
// int chmod(const char *pathname, mode_t mode);
//export chmod
func libc_chmod(pathname *byte, mode uint32) int32
// int mkdir(const char *pathname, mode_t mode);
//export mkdir
func libc_mkdir(pathname *byte, mode uint32) int32