syscall: refactor environment handling

* Move environment functions to their own files.
  * Rewrite the WASIp2 version of environment variables to be much
    simpler (don't go through C functions).
This commit is contained in:
Ayke van Laethem
2024-11-18 11:43:50 +01:00
committed by Ayke
parent e12da15f7d
commit 289fceb3ea
6 changed files with 142 additions and 146 deletions
-42
View File
@@ -87,48 +87,6 @@ const (
MAP_ANONYMOUS = MAP_ANON
)
func runtime_envs() []string
func Getenv(key string) (value string, found bool) {
env := runtime_envs()
for _, keyval := range env {
// Split at '=' character.
var k, v string
for i := 0; i < len(keyval); i++ {
if keyval[i] == '=' {
k = keyval[:i]
v = keyval[i+1:]
}
}
if k == key {
return v, true
}
}
return "", false
}
func Setenv(key, val string) (err error) {
// stub for now
return ENOSYS
}
func Unsetenv(key string) (err error) {
// stub for now
return ENOSYS
}
func Clearenv() (err error) {
// stub for now
return ENOSYS
}
func Environ() []string {
env := runtime_envs()
envCopy := make([]string, len(env))
copy(envCopy, env)
return envCopy
}
func Open(path string, mode int, perm uint32) (fd int, err error) {
return 0, ENOSYS
}