diff --git a/libgo/config.h.in b/libgo/config.h.in index 5318cf58c44..d2aa2f67a1c 100644 --- a/libgo/config.h.in +++ b/libgo/config.h.in @@ -12,6 +12,9 @@ /* Define to 1 if you have the `faccessat' function. */ #undef HAVE_FACCESSAT +/* Define to 1 if you have the `fallocate' function. */ +#undef HAVE_FALLOCATE + /* Define to 1 if you have the `fchmodat' function. */ #undef HAVE_FCHMODAT @@ -130,6 +133,9 @@ /* Define to 1 if you have the header file. */ #undef HAVE_SYS_MMAN_H +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_MOUNT_H + /* Define to 1 if you have the header file. */ #undef HAVE_SYS_PRCTL_H @@ -142,6 +148,9 @@ /* Define to 1 if you have the header file. */ #undef HAVE_SYS_SOCKET_H +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_STATFS_H + /* Define to 1 if you have the header file. */ #undef HAVE_SYS_STAT_H @@ -157,6 +166,9 @@ /* Define to 1 if you have the header file. */ #undef HAVE_SYS_UTSNAME_H +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_VFS_H + /* Define to 1 if you have the `tee' function. */ #undef HAVE_TEE @@ -235,3 +247,6 @@ # undef WORDS_BIGENDIAN # endif #endif + +/* Define to `long int' if does not define. */ +#undef off_t diff --git a/libgo/configure b/libgo/configure index 1f61cff0fc7..ecdd647e5b6 100755 --- a/libgo/configure +++ b/libgo/configure @@ -14508,7 +14508,7 @@ no) ;; esac -for ac_header in sys/mman.h syscall.h sys/epoll.h sys/ptrace.h sys/syscall.h sys/user.h sys/utsname.h sys/select.h sys/socket.h net/if.h sys/prctl.h +for ac_header in sys/mman.h syscall.h sys/epoll.h sys/ptrace.h sys/syscall.h sys/user.h sys/utsname.h sys/select.h sys/socket.h net/if.h sys/prctl.h sys/mount.h sys/vfs.h sys/statfs.h do : as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default" @@ -14581,7 +14581,7 @@ else fi -for ac_func in epoll_create1 faccessat fchmodat fchownat futimesat inotify_add_watch inotify_init inotify_rm_watch mkdirat mknodat openat renameat splice tee unlinkat unshare +for ac_func in epoll_create1 faccessat fallocate fchmodat fchownat futimesat inotify_add_watch inotify_init inotify_rm_watch mkdirat mknodat openat renameat splice tee unlinkat unshare do : as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var" @@ -14594,6 +14594,17 @@ _ACEOF fi done +ac_fn_c_check_type "$LINENO" "off_t" "ac_cv_type_off_t" "$ac_includes_default" +if test "x$ac_cv_type_off_t" = x""yes; then : + +else + +cat >>confdefs.h <<_ACEOF +#define off_t long int +_ACEOF + +fi + ac_fn_c_check_type "$LINENO" "loff_t" "ac_cv_type_loff_t" "$ac_includes_default" if test "x$ac_cv_type_loff_t" = x""yes; then : diff --git a/libgo/configure.ac b/libgo/configure.ac index 46c2b29222b..81ed4924fda 100644 --- a/libgo/configure.ac +++ b/libgo/configure.ac @@ -453,7 +453,7 @@ no) ;; esac -AC_CHECK_HEADERS(sys/mman.h syscall.h sys/epoll.h sys/ptrace.h sys/syscall.h sys/user.h sys/utsname.h sys/select.h sys/socket.h net/if.h sys/prctl.h) +AC_CHECK_HEADERS(sys/mman.h syscall.h sys/epoll.h sys/ptrace.h sys/syscall.h sys/user.h sys/utsname.h sys/select.h sys/socket.h net/if.h sys/prctl.h sys/mount.h sys/vfs.h sys/statfs.h) AC_CHECK_HEADERS([linux/filter.h linux/netlink.h linux/rtnetlink.h], [], [], [#ifdef HAVE_SYS_SOCKET_H @@ -467,7 +467,8 @@ AC_CHECK_FUNCS(strerror_r strsignal wait4 mincore setenv) AM_CONDITIONAL(HAVE_STRERROR_R, test "$ac_cv_func_strerror_r" = yes) AM_CONDITIONAL(HAVE_WAIT4, test "$ac_cv_func_wait4" = yes) -AC_CHECK_FUNCS(epoll_create1 faccessat fchmodat fchownat futimesat inotify_add_watch inotify_init inotify_rm_watch mkdirat mknodat openat renameat splice tee unlinkat unshare) +AC_CHECK_FUNCS(epoll_create1 faccessat fallocate fchmodat fchownat futimesat inotify_add_watch inotify_init inotify_rm_watch mkdirat mknodat openat renameat splice tee unlinkat unshare) +AC_TYPE_OFF_T AC_CHECK_TYPES([loff_t]) CFLAGS_hold="$CFLAGS" diff --git a/libgo/go/syscall/libcall_linux.go b/libgo/go/syscall/libcall_linux.go index aa1440118e3..8a3d8c0e65e 100644 --- a/libgo/go/syscall/libcall_linux.go +++ b/libgo/go/syscall/libcall_linux.go @@ -178,9 +178,8 @@ func PtraceDetach(pid int) (err error) { return ptrace(PTRACE_DETACH, pid, 0, 0) //sys Faccessat(dirfd int, path string, mode uint32, flags int) (err error) //faccessat(dirfd int, pathname *byte, mode int, flags int) int -// FIXME: Only in glibc 2.10 and later. -// //sys Fallocate(fd int, mode uint32, off int64, len int64) (err error) -// //fallocate(fd int, mode int, offset Offset_t, len Offset_t) int +//sys Fallocate(fd int, mode uint32, off int64, len int64) (err error) +//fallocate(fd int, mode int, offset Offset_t, len Offset_t) int //sys Fchmodat(dirfd int, path string, mode uint32, flags int) (err error) //fchmodat(dirfd int, pathname *byte, mode Mode_t, flags int) int @@ -191,9 +190,8 @@ func PtraceDetach(pid int) (err error) { return ptrace(PTRACE_DETACH, pid, 0, 0) //sys Flock(fd int, how int) (err error) //flock(fd int, how int) int -// FIXME: mksysinfo statfs -// //sys Fstatfs(fd int, buf *Statfs_t) (err error) -// //fstatfs(fd int, buf *Statfs_t) int +//sys Fstatfs(fd int, buf *Statfs_t) (err error) +//fstatfs(fd int, buf *Statfs_t) int func Gettid() (tid int) { r1, _, _ := Syscall(SYS_GETTID, 0, 0, 0) @@ -283,9 +281,8 @@ func Splice(rfd int, roff *int64, wfd int, woff *int64, len int, flags int) (n i return } -// FIXME: mksysinfo statfs -// //sys Statfs(path string, buf *Statfs_t) (err error) -// //statfs(path *byte, buf *Statfs_t) int +//sys Statfs(path string, buf *Statfs_t) (err error) +//statfs(path *byte, buf *Statfs_t) int // FIXME: Only in glibc 2.6 and later. // //sys SyncFileRange(fd int, off int64, n int64, flags int) (err error) diff --git a/libgo/mksysinfo.sh b/libgo/mksysinfo.sh index 62296b8af2f..29846381315 100755 --- a/libgo/mksysinfo.sh +++ b/libgo/mksysinfo.sh @@ -93,6 +93,15 @@ cat > sysinfo.c < #endif +#if defined(HAVE_SYS_MOUNT_H) +#include +#endif +#if defined(HAVE_SYS_VFS_H) +#include +#endif +#if defined(HAVE_STATFS_H) +#include +#endif /* Constants that may only be defined as expressions on some systems, expressions too complex for -fdump-go-spec to handle. These are @@ -766,4 +775,35 @@ for n in IGNBRK BRKINT IGNPAR PARMRK INPCK ISTRIP INLCR IGNCR ICRNL IUCLC \ sed -e 's/^\(const \)_\([^=]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT} done +# The mount flags +grep '^const _MS_' gen-sysinfo.go | + sed -e 's/^\(const \)_\(MS_[^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT} + +# The fallocate flags. +grep '^const _FALLOC_' gen-sysinfo.go | + sed -e 's/^\(const \)_\(FALLOC_[^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT} + +# The statfs struct. +# Prefer largefile variant if available. +statfs=`grep '^type _statfs64 ' gen-sysinfo.go || true` +if test "$statfs" != ""; then + grep '^type _statfs64 ' gen-sysinfo.go +else + grep '^type _statfs ' gen-sysinfo.go +fi | sed -e 's/type _statfs64/type Statfs_t/' \ + -e 's/type _statfs/type Statfs_t/' \ + -e 's/f_type/Type/' \ + -e 's/f_bsize/Bsize/' \ + -e 's/f_blocks/Blocks/' \ + -e 's/f_bfree/Bfree/' \ + -e 's/f_bavail/Bavail/' \ + -e 's/f_files/Files/' \ + -e 's/f_ffree/Ffree/' \ + -e 's/f_fsid/Fsid/' \ + -e 's/f_namelen/Namelen/' \ + -e 's/f_frsize/Frsize/' \ + -e 's/f_flags/Flags/' \ + -e 's/f_spare/Spare/' \ + >> ${OUT} + exit $? diff --git a/libgo/runtime/go-nosys.c b/libgo/runtime/go-nosys.c index 6b328544f0d..b2829589b14 100644 --- a/libgo/runtime/go-nosys.c +++ b/libgo/runtime/go-nosys.c @@ -48,6 +48,18 @@ faccessat (int fd __attribute__ ((unused)), } #endif +#ifndef HAVE_FALLOCATE +int +fallocate (int fd __attribute__ ((unused)), + int mode __attribute__ ((unused)), + off_t offset __attribute __ ((unused)), + off_t len __attribute__ ((unused))) +{ + errno = ENOSYS; + return -1; +} +#endif + #ifndef HAVE_FCHMODAT int fchmodat (int dirfd __attribute__ ((unused)),