diff -r 1364b9899eed libgo/Makefile.am
--- a/libgo/Makefile.am	Sun Jan 30 12:31:01 2011 +0100
+++ b/libgo/Makefile.am	Sun Jan 30 22:58:03 2011 +0100
@@ -1,6 +1,6 @@
 # Makefile.am -- Go library Makefile.
 
-# Copyright 2009 The Go Authors. All rights reserved.
+# Copyright 2009, 2011 The Go Authors. All rights reserved.
 # Use of this source code is governed by a BSD-style
 # license that can be found in the LICENSE file.
 
@@ -657,6 +657,16 @@
 	go/netchan/export.go \
 	go/netchan/import.go
 
+if LIBGO_IS_SOLARIS
+if LIBGO_IS_386
+go_os_dir_file = go/os/dir_largefile.go
+else
+go_os_dir_file = go/os/dir_regfile.go
+endif
+else
+go_os_dir_file = go/os/dir_regfile.go
+endif
+
 if LIBGO_IS_LINUX
 go_os_sys_file = go/os/sys_linux.go
 else
@@ -672,6 +682,7 @@
 endif
 
 go_os_files = \
+	$(go_os_dir_file) \
 	go/os/dir.go \
 	go/os/env.go \
 	go/os/env_unix.go \
@@ -1111,18 +1122,23 @@
 if LIBGO_IS_LINUX
 # Always use lseek64 on GNU/Linux.
 syscall_filesize_file = syscalls/sysfile_largefile.go
+syscall_stat_file = syscalls/sysfile_stat_regfile.go
 else # !LIBGO_IS_LINUX
 if LIBGO_IS_SOLARIS
+# FIXME: Same for sparc vs. sparc64.  Introduce new/additional conditional?
 if LIBGO_IS_386
 # Use lseek64 on 386 Solaris.
 syscall_filesize_file = syscalls/sysfile_largefile.go
+syscall_stat_file = syscalls/sysfile_stat_largefile.go
 else # !LIBGO_IS_LINUX && LIBGO_IS_SOLARIS && !LIBGO_IS_386
 # Use lseek on amd64 Solaris.
 syscall_filesize_file = syscalls/sysfile_regfile.go
+syscall_stat_file = syscalls/sysfile_stat_regfile.go
 endif # !LIBGO_IS_386
 else # !LIBGO_IS_LINUX && !LIBGO_IS_SOLARIS
 # Use lseek by default.
 syscall_filesize_file = syscalls/sysfile_regfile.go
+syscall_stat_file = syscalls/sysfile_stat_regfile.go
 endif # !LIBGO_IS_SOLARIS
 endif # !LIBGO_IS_LINUX
 
@@ -1195,6 +1211,7 @@
 	syscalls/exec_helpers.go \
 	$(syscall_exec_os_file) \
 	$(syscall_filesize_file) \
+	$(syscall_stat_file) \
 	$(syscall_sleep_file) \
 	syscalls/socket.go \
 	$(syscall_socket_os_file) \
diff -r 1364b9899eed libgo/configure.ac
--- a/libgo/configure.ac	Sun Jan 30 12:31:01 2011 +0100
+++ b/libgo/configure.ac	Sun Jan 30 22:58:03 2011 +0100
@@ -1,6 +1,6 @@
 # configure.ac -- Go library configure script.
 
-# Copyright 2009 The Go Authors. All rights reserved.
+# Copyright 2009, 2011 The Go Authors. All rights reserved.
 # Use of this source code is governed by a BSD-style
 # license that can be found in the LICENSE file.
 
@@ -328,7 +328,7 @@
 
 GCC_CHECK_UNWIND_GETIPINFO
 
-AC_CHECK_HEADERS(sys/mman.h syscall.h sys/epoll.h sys/ptrace.h sys/user.h sys/utsname.h)
+AC_CHECK_HEADERS(sys/mman.h syscall.h sys/epoll.h sys/ptrace.h sys/syscall.h sys/user.h sys/utsname.h)
 AM_CONDITIONAL(HAVE_SYS_MMAN_H, test "$ac_cv_header_sys_mman_h" = yes)
 AC_CHECK_FUNCS(srandom random strsignal)
 
diff -r 1364b9899eed libgo/go/os/dir.go
--- a/libgo/go/os/dir.go	Sun Jan 30 12:31:01 2011 +0100
+++ b/libgo/go/os/dir.go	Sun Jan 30 22:58:03 2011 +0100
@@ -1,4 +1,4 @@
-// Copyright 2009 The Go Authors. All rights reserved.
+// Copyright 2009, 2011 The Go Authors. All rights reserved.
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
@@ -11,7 +11,6 @@
 
 func libc_dup(fd int) int __asm__ ("dup")
 func libc_opendir(*byte) *syscall.DIR __asm__ ("opendir")
-func libc_readdir_r(*syscall.DIR, *syscall.Dirent, **syscall.Dirent) int __asm__ ("readdir_r")
 func libc_closedir(*syscall.DIR) int __asm__ ("closedir")
 
 // FIXME: pathconf returns long, not int.
diff -r 1364b9899eed libgo/go/os/dir_largefile.go
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libgo/go/os/dir_largefile.go	Sun Jan 30 22:58:03 2011 +0100
@@ -0,0 +1,12 @@
+// dir_largefile.go -- For systems which use the large file interface for
+// readdir_r.
+
+// Copyright 2011 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package os
+
+import "syscall"
+
+func libc_readdir_r(*syscall.DIR, *syscall.Dirent, **syscall.Dirent) int __asm__ ("readdir64_r")
diff -r 1364b9899eed libgo/go/os/dir_regfile.go
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libgo/go/os/dir_regfile.go	Sun Jan 30 22:58:03 2011 +0100
@@ -0,0 +1,12 @@
+// dir_regfile.go -- For systems which do not use the large file interface
+// for readdir_r.
+
+// Copyright 2011 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package os
+
+import "syscall"
+
+func libc_readdir_r(*syscall.DIR, *syscall.Dirent, **syscall.Dirent) int __asm__ ("readdir_r")
diff -r 1364b9899eed libgo/mksysinfo.sh
--- a/libgo/mksysinfo.sh	Sun Jan 30 12:31:01 2011 +0100
+++ b/libgo/mksysinfo.sh	Sun Jan 30 22:58:03 2011 +0100
@@ -1,6 +1,6 @@
 #!/bin/sh
 
-# Copyright 2009 The Go Authors. All rights reserved.
+# Copyright 2009, 2011 The Go Authors. All rights reserved.
 # Use of this source code is governed by a BSD-style
 # license that can be found in the LICENSE file.
 
@@ -42,6 +45,9 @@
 #if defined(HAVE_SYSCALL_H)
 #include <syscall.h>
 #endif
+#if defined(HAVE_SYS_SYSCALL_H)
+#include <sys/syscall.h>
+#endif
 #if defined(HAVE_SYS_EPOLL_H)
 #include <sys/epoll.h>
 #endif
@@ -306,36 +317,47 @@
 fi
 
 # The stat type.
-grep 'type _stat ' gen-sysinfo.go | \
-  sed -e 's/type _stat/type Stat_t/' \
-      -e 's/st_dev/Dev/' \
-      -e 's/st_ino/Ino/' \
-      -e 's/st_nlink/Nlink/' \
-      -e 's/st_mode/Mode/' \
-      -e 's/st_uid/Uid/' \
-      -e 's/st_gid/Gid/' \
-      -e 's/st_rdev/Rdev/' \
-      -e 's/st_size/Size/' \
-      -e 's/st_blksize/Blksize/' \
-      -e 's/st_blocks/Blocks/' \
-      -e 's/st_atim/Atime/' \
-      -e 's/st_mtim/Mtime/' \
-      -e 's/st_ctim/Ctime/' \
-      -e 's/\([^a-zA-Z0-9_]\)_timeval\([^a-zA-Z0-9_]\)/\1Timeval\2/g' \
-      -e 's/\([^a-zA-Z0-9_]\)_timespec\([^a-zA-Z0-9_]\)/\1Timespec\2/g' \
-      -e 's/\([^a-zA-Z0-9_]\)_timestruc_t\([^a-zA-Z0-9_]\)/\1Timestruc\2/g' \
-    >> ${OUT}
+# Prefer largefile variant if available.
+stat=`grep '^type _stat64 ' gen-sysinfo.go`
+if test "$stat" != ""; then
+  grep '^type _stat64 ' gen-sysinfo.go
+else
+  grep '^type _stat ' gen-sysinfo.go
+fi | sed -e 's/type _stat\(64\)\?/type Stat_t/' \
+         -e 's/st_dev/Dev/' \
+         -e 's/st_ino/Ino/' \
+         -e 's/st_nlink/Nlink/' \
+         -e 's/st_mode/Mode/' \
+         -e 's/st_uid/Uid/' \
+         -e 's/st_gid/Gid/' \
+         -e 's/st_rdev/Rdev/' \
+         -e 's/st_size/Size/' \
+         -e 's/st_blksize/Blksize/' \
+         -e 's/st_blocks/Blocks/' \
+         -e 's/st_atim/Atime/' \
+         -e 's/st_mtim/Mtime/' \
+         -e 's/st_ctim/Ctime/' \
+         -e 's/\([^a-zA-Z0-9_]\)_timeval\([^a-zA-Z0-9_]\)/\1Timeval\2/g' \
+         -e 's/\([^a-zA-Z0-9_]\)_timespec\([^a-zA-Z0-9_]\)/\1Timespec\2/g' \
+         -e 's/\([^a-zA-Z0-9_]\)_timestruc_t\([^a-zA-Z0-9_]\)/\1Timestruc\2/g' \
+       >> ${OUT}
 
 # The directory searching types.
-grep '^type _dirent ' gen-sysinfo.go | \
-  sed -e 's/type _dirent/type Dirent/' \
-      -e 's/d_name/Name/' \
-      -e 's/]int8/]byte/' \
-      -e 's/d_ino/Ino/' \
-      -e 's/d_off/Off/' \
-      -e 's/d_reclen/Reclen/' \
-      -e 's/d_type/Type/' \
-    >> ${OUT}
+# Prefer largefile variant if available.
+dirent=`grep '^type _dirent64 ' gen-sysinfo.go`
+if test "$dirent" != ""; then
+  grep '^type _dirent64 ' gen-sysinfo.go
+else
+  grep '^type _dirent ' gen-sysinfo.go
+fi | sed -e 's/type _dirent\(64\)\?/type Dirent/' \
+         -e 's/d_name \[0+1\]/d_name [0+256]/' \
+         -e 's/d_name/Name/' \
+         -e 's/]int8/]byte/' \
+         -e 's/d_ino/Ino/' \
+         -e 's/d_off/Off/' \
+         -e 's/d_reclen/Reclen/' \
+         -e 's/d_type/Type/' \
+      >> ${OUT}
 echo "type DIR _DIR" >> ${OUT}
 
 # The rusage struct.
diff -r 1364b9899eed libgo/syscalls/sysfile_posix.go
--- a/libgo/syscalls/sysfile_posix.go	Sun Jan 30 12:31:01 2011 +0100
+++ b/libgo/syscalls/sysfile_posix.go	Sun Jan 30 22:58:03 2011 +0100
@@ -1,6 +1,6 @@
 // sysfile_posix.go -- POSIX File handling.
 
-// Copyright 2010 The Go Authors. All rights reserved.
+// Copyright 2010, 2010 The Go Authors. All rights reserved.
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
@@ -18,9 +18,6 @@
 func libc_write(fd int, buf *byte, count Size_t) Ssize_t __asm__ ("write");
 func libc_fsync(fd int) int __asm__ ("fsync")
 func libc_pipe(filedes *int) int __asm__("pipe");
-func libc_stat(name *byte, buf *Stat_t) int __asm__ ("stat");
-func libc_fstat(fd int, buf *Stat_t) int __asm__ ("fstat");
-func libc_lstat(name *byte, buf *Stat_t) int __asm__ ("lstat");
 func libc_unlink(name *byte) int __asm__ ("unlink");
 func libc_rmdir(name *byte) int __asm__ ("rmdir");
 func libc_fcntl(fd int, cmd int, arg int) int __asm__ ("fcntl");
diff -r 1364b9899eed libgo/syscalls/sysfile_stat_largefile.go
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libgo/syscalls/sysfile_stat_largefile.go	Sun Jan 30 22:58:03 2011 +0100
@@ -0,0 +1,12 @@
+// sysfile_stat_largefile.go -- For systems which use the large file interface
+// for *stat.
+
+// Copyright 2011 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package syscall
+
+func libc_stat(name *byte, buf *Stat_t) int __asm__ ("stat64");
+func libc_fstat(fd int, buf *Stat_t) int __asm__ ("fstat64");
+func libc_lstat(name *byte, buf *Stat_t) int __asm__ ("lstat64");
diff -r 1364b9899eed libgo/syscalls/sysfile_stat_regfile.go
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libgo/syscalls/sysfile_stat_regfile.go	Sun Jan 30 22:58:03 2011 +0100
@@ -0,0 +1,12 @@
+// sysfile_stat_regfile.go -- For systems which do not use the large file
+// interface for *stat.
+
+// Copyright 2011 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package syscall
+
+func libc_stat(name *byte, buf *Stat_t) int __asm__ ("stat");
+func libc_fstat(fd int, buf *Stat_t) int __asm__ ("fstat");
+func libc_lstat(name *byte, buf *Stat_t) int __asm__ ("lstat");
