summaryrefslogtreecommitdiff
path: root/src/syscall/syscall.go
diff options
context:
space:
mode:
Diffstat (limited to 'src/syscall/syscall.go')
-rw-r--r--src/syscall/syscall.go14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/syscall/syscall.go b/src/syscall/syscall.go
index 7f31c11c9..384be2429 100644
--- a/src/syscall/syscall.go
+++ b/src/syscall/syscall.go
@@ -11,3 +11,17 @@ package syscall
export func Syscall(trap int64, a1, a2, a3 int64) (r1, r2, err int64);
export func AddrToInt(b *byte) int64;
+/*
+ * Used to convert file names to byte arrays for passing to kernel,
+ * but useful elsewhere too.
+ */
+export func StringToBytes(b *[]byte, s string) bool {
+ if len(s) >= len(b) {
+ return false
+ }
+ for i := 0; i < len(s); i++ {
+ b[i] = s[i]
+ }
+ b[len(s)] = '\000'; // not necessary - memory is zeroed - but be explicit
+ return true
+}