From d8f412571f8768df2d3239e72392dfeabbad1559 Mon Sep 17 00:00:00 2001 From: Ian Lance Taylor Date: Wed, 26 Oct 2011 23:57:58 +0000 Subject: Update Go library to last weekly. From-SVN: r180552 --- libgo/go/os/dir_plan9.go | 2 +- libgo/go/os/dir_unix.go | 2 ++ libgo/go/os/env.go | 4 ++-- libgo/go/os/env_unix.go | 2 ++ libgo/go/os/error_plan9.go | 1 + libgo/go/os/error_posix.go | 2 ++ libgo/go/os/exec_posix.go | 2 ++ libgo/go/os/exec_unix.go | 5 ++++- libgo/go/os/file_posix.go | 37 +++--------------------------------- libgo/go/os/file_unix.go | 35 ++++++++++++++++++++++++++++++++++ libgo/go/os/inotify/inotify_linux.go | 2 +- libgo/go/os/os_test.go | 6 ++++++ libgo/go/os/path.go | 2 +- libgo/go/os/path_unix.go | 2 ++ libgo/go/os/str.go | 2 ++ libgo/go/os/sys_bsd.go | 2 ++ libgo/go/os/user/lookup_stubs.go | 2 ++ libgo/go/os/user/lookup_unix.go | 2 ++ 18 files changed, 72 insertions(+), 40 deletions(-) (limited to 'libgo/go/os') diff --git a/libgo/go/os/dir_plan9.go b/libgo/go/os/dir_plan9.go index bbc2cb6..bf17005 100644 --- a/libgo/go/os/dir_plan9.go +++ b/libgo/go/os/dir_plan9.go @@ -295,6 +295,6 @@ func pstring(b []byte, s string) []byte { panic(NewError("string too long")) } b = pbit16(b, uint16(len(s))) - b = append(b, []byte(s)...) + b = append(b, s...) return b } diff --git a/libgo/go/os/dir_unix.go b/libgo/go/os/dir_unix.go index 7835ed5..5295933 100644 --- a/libgo/go/os/dir_unix.go +++ b/libgo/go/os/dir_unix.go @@ -2,6 +2,8 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +// +build darwin freebsd linux openbsd + package os import ( diff --git a/libgo/go/os/env.go b/libgo/go/os/env.go index 3772c09..4844fa3 100644 --- a/libgo/go/os/env.go +++ b/libgo/go/os/env.go @@ -16,9 +16,9 @@ func Expand(s string, mapping func(string) string) string { i := 0 for j := 0; j < len(s); j++ { if s[j] == '$' && j+1 < len(s) { - buf = append(buf, []byte(s[i:j])...) + buf = append(buf, s[i:j]...) name, w := getShellName(s[j+1:]) - buf = append(buf, []byte(mapping(name))...) + buf = append(buf, mapping(name)...) j += w i = j + 1 } diff --git a/libgo/go/os/env_unix.go b/libgo/go/os/env_unix.go index 9cc0b03..8dd84ae 100644 --- a/libgo/go/os/env_unix.go +++ b/libgo/go/os/env_unix.go @@ -2,6 +2,8 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +// +build darwin freebsd linux openbsd + // Unix environment variables. package os diff --git a/libgo/go/os/error_plan9.go b/libgo/go/os/error_plan9.go index cacfc15..91ace6d 100644 --- a/libgo/go/os/error_plan9.go +++ b/libgo/go/os/error_plan9.go @@ -48,6 +48,7 @@ var ( EPERM = Eperm EISDIR = syscall.EISDIR + EBADF = NewError("bad file descriptor") ENAMETOOLONG = NewError("file name too long") ERANGE = NewError("math result not representable") EPIPE = NewError("Broken Pipe") diff --git a/libgo/go/os/error_posix.go b/libgo/go/os/error_posix.go index d43f178..9dc258a 100644 --- a/libgo/go/os/error_posix.go +++ b/libgo/go/os/error_posix.go @@ -2,6 +2,8 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +// +build darwin freebsd linux openbsd windows + package os import syscall "syscall" diff --git a/libgo/go/os/exec_posix.go b/libgo/go/os/exec_posix.go index f37bfab..035b156 100644 --- a/libgo/go/os/exec_posix.go +++ b/libgo/go/os/exec_posix.go @@ -2,6 +2,8 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +// +build darwin freebsd linux openbsd windows + package os import ( diff --git a/libgo/go/os/exec_unix.go b/libgo/go/os/exec_unix.go index 8a4b2e1..e1adb20 100644 --- a/libgo/go/os/exec_unix.go +++ b/libgo/go/os/exec_unix.go @@ -2,6 +2,8 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +// +build darwin freebsd linux openbsd + package os import ( @@ -38,7 +40,8 @@ func (p *Process) Wait(options int) (w *Waitmsg, err Error) { if e != 0 { return nil, NewSyscallError("wait", e) } - if options&WSTOPPED == 0 { + // With WNOHANG pid is 0 if child has not exited. + if pid1 != 0 && options&WSTOPPED == 0 { p.done = true } w = new(Waitmsg) diff --git a/libgo/go/os/file_posix.go b/libgo/go/os/file_posix.go index 0791a0d..5269149 100644 --- a/libgo/go/os/file_posix.go +++ b/libgo/go/os/file_posix.go @@ -2,6 +2,8 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +// +build darwin freebsd linux openbsd windows + package os import ( @@ -21,39 +23,6 @@ func epipecheck(file *File, e int) { } } -// Stat returns a FileInfo structure describing the named file and an error, if any. -// If name names a valid symbolic link, the returned FileInfo describes -// the file pointed at by the link and has fi.FollowedSymlink set to true. -// If name names an invalid symbolic link, the returned FileInfo describes -// the link itself and has fi.FollowedSymlink set to false. -func Stat(name string) (fi *FileInfo, err Error) { - var lstat, stat syscall.Stat_t - e := syscall.Lstat(name, &lstat) - if iserror(e) { - return nil, &PathError{"stat", name, Errno(e)} - } - statp := &lstat - if lstat.Mode&syscall.S_IFMT == syscall.S_IFLNK { - e := syscall.Stat(name, &stat) - if !iserror(e) { - statp = &stat - } - } - return fileInfoFromStat(name, new(FileInfo), &lstat, statp), nil -} - -// Lstat returns the FileInfo structure describing the named file and an -// error, if any. If the file is a symbolic link, the returned FileInfo -// describes the symbolic link. Lstat makes no attempt to follow the link. -func Lstat(name string) (fi *FileInfo, err Error) { - var stat syscall.Stat_t - e := syscall.Lstat(name, &stat) - if iserror(e) { - return nil, &PathError{"lstat", name, Errno(e)} - } - return fileInfoFromStat(name, new(FileInfo), &stat, &stat), nil -} - // Remove removes the named file or directory. func Remove(name string) Error { // System call interface forces us to know @@ -79,7 +48,7 @@ func Remove(name string) Error { // both errors will be ENOTDIR, so it's okay to // use the error from unlink. // For windows syscall.ENOTDIR is set - // to syscall.ERROR_DIRECTORY, hopefully it should + // to syscall.ERROR_PATH_NOT_FOUND, hopefully it should // do the trick. if e1 != syscall.ENOTDIR { e = e1 diff --git a/libgo/go/os/file_unix.go b/libgo/go/os/file_unix.go index 8243701..0ebaf23 100644 --- a/libgo/go/os/file_unix.go +++ b/libgo/go/os/file_unix.go @@ -2,6 +2,8 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +// +build darwin freebsd linux openbsd + package os import ( @@ -100,6 +102,39 @@ func (file *File) Stat() (fi *FileInfo, err Error) { return fileInfoFromStat(file.name, new(FileInfo), &stat, &stat), nil } +// Stat returns a FileInfo structure describing the named file and an error, if any. +// If name names a valid symbolic link, the returned FileInfo describes +// the file pointed at by the link and has fi.FollowedSymlink set to true. +// If name names an invalid symbolic link, the returned FileInfo describes +// the link itself and has fi.FollowedSymlink set to false. +func Stat(name string) (fi *FileInfo, err Error) { + var lstat, stat syscall.Stat_t + e := syscall.Lstat(name, &lstat) + if iserror(e) { + return nil, &PathError{"stat", name, Errno(e)} + } + statp := &lstat + if lstat.Mode&syscall.S_IFMT == syscall.S_IFLNK { + e := syscall.Stat(name, &stat) + if !iserror(e) { + statp = &stat + } + } + return fileInfoFromStat(name, new(FileInfo), &lstat, statp), nil +} + +// Lstat returns the FileInfo structure describing the named file and an +// error, if any. If the file is a symbolic link, the returned FileInfo +// describes the symbolic link. Lstat makes no attempt to follow the link. +func Lstat(name string) (fi *FileInfo, err Error) { + var stat syscall.Stat_t + e := syscall.Lstat(name, &stat) + if iserror(e) { + return nil, &PathError{"lstat", name, Errno(e)} + } + return fileInfoFromStat(name, new(FileInfo), &stat, &stat), nil +} + // Readdir reads the contents of the directory associated with file and // returns an array of up to n FileInfo structures, as would be returned // by Lstat, in directory order. Subsequent calls on the same file will yield diff --git a/libgo/go/os/inotify/inotify_linux.go b/libgo/go/os/inotify/inotify_linux.go index 99fa516..ee3c75f 100644 --- a/libgo/go/os/inotify/inotify_linux.go +++ b/libgo/go/os/inotify/inotify_linux.go @@ -131,7 +131,7 @@ func (w *Watcher) RemoveWatch(path string) os.Error { if success == -1 { return os.NewSyscallError("inotify_rm_watch", errno) } - w.watches[path] = nil, false + delete(w.watches, path) return nil } diff --git a/libgo/go/os/os_test.go b/libgo/go/os/os_test.go index 3f7d306..3277fc2 100644 --- a/libgo/go/os/os_test.go +++ b/libgo/go/os/os_test.go @@ -918,6 +918,12 @@ func TestHostname(t *testing.T) { if syscall.OS == "windows" || syscall.OS == "plan9" { return } + + // TODO(jsing): Fix nametomib() on OpenBSD + if syscall.OS == "openbsd" { + return + } + // Check internal Hostname() against the output of /bin/hostname. // Allow that the internal Hostname returns a Fully Qualified Domain Name // and the /bin/hostname only returns the first component diff --git a/libgo/go/os/path.go b/libgo/go/os/path.go index a8dfce3..b190c51 100644 --- a/libgo/go/os/path.go +++ b/libgo/go/os/path.go @@ -68,7 +68,7 @@ func RemoveAll(path string) Error { // Otherwise, is this a directory we need to recurse into? dir, serr := Lstat(path) if serr != nil { - if serr, ok := serr.(*PathError); ok && serr.Error == ENOENT { + if serr, ok := serr.(*PathError); ok && (serr.Error == ENOENT || serr.Error == ENOTDIR) { return nil } return serr diff --git a/libgo/go/os/path_unix.go b/libgo/go/os/path_unix.go index 0d327cd..33045b6 100644 --- a/libgo/go/os/path_unix.go +++ b/libgo/go/os/path_unix.go @@ -2,6 +2,8 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +// +build darwin freebsd linux openbsd + package os const ( diff --git a/libgo/go/os/str.go b/libgo/go/os/str.go index 8dc9e47..e3606b6 100644 --- a/libgo/go/os/str.go +++ b/libgo/go/os/str.go @@ -2,6 +2,8 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +// +build plan9 + package os func itoa(val int) string { // do it here rather than with fmt to avoid dependency diff --git a/libgo/go/os/sys_bsd.go b/libgo/go/os/sys_bsd.go index 188993b..b0d097a 100644 --- a/libgo/go/os/sys_bsd.go +++ b/libgo/go/os/sys_bsd.go @@ -2,6 +2,8 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +// +build darwin freebsd openbsd + // os code shared between *BSD systems including OS X (Darwin) // and FreeBSD. diff --git a/libgo/go/os/user/lookup_stubs.go b/libgo/go/os/user/lookup_stubs.go index 2f08f70..2d2de98 100644 --- a/libgo/go/os/user/lookup_stubs.go +++ b/libgo/go/os/user/lookup_stubs.go @@ -2,6 +2,8 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +// +build openbsd plan9 windows + package user import ( diff --git a/libgo/go/os/user/lookup_unix.go b/libgo/go/os/user/lookup_unix.go index 18a9687..3336b52 100644 --- a/libgo/go/os/user/lookup_unix.go +++ b/libgo/go/os/user/lookup_unix.go @@ -2,6 +2,8 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +// +build darwin freebsd linux + package user import ( -- cgit v1.1