From bb282baa93bbb3158f6e52cb1436286a544000e3 Mon Sep 17 00:00:00 2001 From: David Anderson Date: Fri, 14 Oct 2011 09:19:45 -0700 Subject: [PATCH] syscall: adjust Mount to accomodate stricter FS implementations. Notably, the "data" argument should be nil if no options are given, or (at least) the cgroup filesystem will refuse to mount. R=bradfitz, rsc CC=golang-dev https://golang.org/cl/5147047 --- src/pkg/syscall/syscall_linux.go | 11 ++++++++++- src/pkg/syscall/zsyscall_linux_386.go | 16 ++++++++-------- src/pkg/syscall/zsyscall_linux_amd64.go | 16 ++++++++-------- src/pkg/syscall/zsyscall_linux_arm.go | 16 ++++++++-------- 4 files changed, 34 insertions(+), 25 deletions(-) diff --git a/src/pkg/syscall/syscall_linux.go b/src/pkg/syscall/syscall_linux.go index 715561fd7a..50d6fa9837 100644 --- a/src/pkg/syscall/syscall_linux.go +++ b/src/pkg/syscall/syscall_linux.go @@ -784,6 +784,16 @@ func ParseDirent(buf []byte, max int, names []string) (consumed int, count int, return origlen - len(buf), count, names } +//sys mount(source string, target string, fstype string, flags uint32, data *byte) (errno int) +func Mount(source string, target string, fstype string, flags uint32, data string) (errno int) { + // Certain file systems get rather angry and EINVAL if you give + // them an empty string of data, rather than NULL. + if data == "" { + return mount(source, target, fstype, flags, nil) + } + return mount(source, target, fstype, flags, StringBytePtr(data)) +} + // Sendto // Recvfrom // Socketpair @@ -834,7 +844,6 @@ func ParseDirent(buf []byte, max int, names []string) (consumed int, count int, //sys Mkdirat(dirfd int, path string, mode uint32) (errno int) //sys Mknod(path string, mode uint32, dev int) (errno int) //sys Mknodat(dirfd int, path string, mode uint32, dev int) (errno int) -//sys Mount(source string, target string, fstype string, flags int, data string) (errno int) //sys Nanosleep(time *Timespec, leftover *Timespec) (errno int) //sys Pause() (errno int) //sys PivotRoot(newroot string, putold string) (errno int) = SYS_PIVOT_ROOT diff --git a/src/pkg/syscall/zsyscall_linux_386.go b/src/pkg/syscall/zsyscall_linux_386.go index 4eb522ad92..35c54327d7 100644 --- a/src/pkg/syscall/zsyscall_linux_386.go +++ b/src/pkg/syscall/zsyscall_linux_386.go @@ -89,6 +89,14 @@ func reboot(magic1 uint, magic2 uint, cmd int, arg string) (errno int) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func mount(source string, target string, fstype string, flags uint32, data *byte) (errno int) { + _, _, e1 := Syscall6(SYS_MOUNT, uintptr(unsafe.Pointer(StringBytePtr(source))), uintptr(unsafe.Pointer(StringBytePtr(target))), uintptr(unsafe.Pointer(StringBytePtr(fstype))), uintptr(flags), uintptr(unsafe.Pointer(data)), 0) + errno = int(e1) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Access(path string, mode uint32) (errno int) { _, _, e1 := Syscall(SYS_ACCESS, uintptr(unsafe.Pointer(StringBytePtr(path))), uintptr(mode), 0) errno = int(e1) @@ -464,14 +472,6 @@ func Mknodat(dirfd int, path string, mode uint32, dev int) (errno int) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func Mount(source string, target string, fstype string, flags int, data string) (errno int) { - _, _, e1 := Syscall6(SYS_MOUNT, uintptr(unsafe.Pointer(StringBytePtr(source))), uintptr(unsafe.Pointer(StringBytePtr(target))), uintptr(unsafe.Pointer(StringBytePtr(fstype))), uintptr(flags), uintptr(unsafe.Pointer(StringBytePtr(data))), 0) - errno = int(e1) - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func Nanosleep(time *Timespec, leftover *Timespec) (errno int) { _, _, e1 := Syscall(SYS_NANOSLEEP, uintptr(unsafe.Pointer(time)), uintptr(unsafe.Pointer(leftover)), 0) errno = int(e1) diff --git a/src/pkg/syscall/zsyscall_linux_amd64.go b/src/pkg/syscall/zsyscall_linux_amd64.go index 999ed64a18..0d4ce43007 100644 --- a/src/pkg/syscall/zsyscall_linux_amd64.go +++ b/src/pkg/syscall/zsyscall_linux_amd64.go @@ -89,6 +89,14 @@ func reboot(magic1 uint, magic2 uint, cmd int, arg string) (errno int) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func mount(source string, target string, fstype string, flags uint32, data *byte) (errno int) { + _, _, e1 := Syscall6(SYS_MOUNT, uintptr(unsafe.Pointer(StringBytePtr(source))), uintptr(unsafe.Pointer(StringBytePtr(target))), uintptr(unsafe.Pointer(StringBytePtr(fstype))), uintptr(flags), uintptr(unsafe.Pointer(data)), 0) + errno = int(e1) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Access(path string, mode uint32) (errno int) { _, _, e1 := Syscall(SYS_ACCESS, uintptr(unsafe.Pointer(StringBytePtr(path))), uintptr(mode), 0) errno = int(e1) @@ -464,14 +472,6 @@ func Mknodat(dirfd int, path string, mode uint32, dev int) (errno int) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func Mount(source string, target string, fstype string, flags int, data string) (errno int) { - _, _, e1 := Syscall6(SYS_MOUNT, uintptr(unsafe.Pointer(StringBytePtr(source))), uintptr(unsafe.Pointer(StringBytePtr(target))), uintptr(unsafe.Pointer(StringBytePtr(fstype))), uintptr(flags), uintptr(unsafe.Pointer(StringBytePtr(data))), 0) - errno = int(e1) - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func Nanosleep(time *Timespec, leftover *Timespec) (errno int) { _, _, e1 := Syscall(SYS_NANOSLEEP, uintptr(unsafe.Pointer(time)), uintptr(unsafe.Pointer(leftover)), 0) errno = int(e1) diff --git a/src/pkg/syscall/zsyscall_linux_arm.go b/src/pkg/syscall/zsyscall_linux_arm.go index cd49dabed6..a01b16ef16 100644 --- a/src/pkg/syscall/zsyscall_linux_arm.go +++ b/src/pkg/syscall/zsyscall_linux_arm.go @@ -89,6 +89,14 @@ func reboot(magic1 uint, magic2 uint, cmd int, arg string) (errno int) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func mount(source string, target string, fstype string, flags uint32, data *byte) (errno int) { + _, _, e1 := Syscall6(SYS_MOUNT, uintptr(unsafe.Pointer(StringBytePtr(source))), uintptr(unsafe.Pointer(StringBytePtr(target))), uintptr(unsafe.Pointer(StringBytePtr(fstype))), uintptr(flags), uintptr(unsafe.Pointer(data)), 0) + errno = int(e1) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Access(path string, mode uint32) (errno int) { _, _, e1 := Syscall(SYS_ACCESS, uintptr(unsafe.Pointer(StringBytePtr(path))), uintptr(mode), 0) errno = int(e1) @@ -464,14 +472,6 @@ func Mknodat(dirfd int, path string, mode uint32, dev int) (errno int) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func Mount(source string, target string, fstype string, flags int, data string) (errno int) { - _, _, e1 := Syscall6(SYS_MOUNT, uintptr(unsafe.Pointer(StringBytePtr(source))), uintptr(unsafe.Pointer(StringBytePtr(target))), uintptr(unsafe.Pointer(StringBytePtr(fstype))), uintptr(flags), uintptr(unsafe.Pointer(StringBytePtr(data))), 0) - errno = int(e1) - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func Nanosleep(time *Timespec, leftover *Timespec) (errno int) { _, _, e1 := Syscall(SYS_NANOSLEEP, uintptr(unsafe.Pointer(time)), uintptr(unsafe.Pointer(leftover)), 0) errno = int(e1) -- 2.48.1