From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 1162 invoked by alias); 21 Sep 2004 02:26:48 -0000 Mailing-List: contact gdb-patches-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sources.redhat.com Received: (qmail 1155 invoked from network); 21 Sep 2004 02:26:47 -0000 Received: from unknown (209.128.65.135) by sourceware.org with QMTP; 21 Sep 2004 02:26:47 -0000 Received: (qmail 21145 invoked by uid 10); 21 Sep 2004 02:26:46 -0000 Received: (qmail 24708 invoked by uid 500); 21 Sep 2004 02:26:38 -0000 Message-ID: <20040921022638.24707.qmail@gossamer.airs.com> Date: Tue, 21 Sep 2004 02:26:00 -0000 From: Ian Lance Taylor To: gdb-patches@sourceware.org Subject: PATCH RFA: Handle lack of struct statfs in ppc/sim/emul_netbsd.c X-SW-Source: 2004-09/txt/msg00332.txt.bz2 NetBSD post 2.0 has deprecated statfs in favor of statvfs. The statfs system call still exists for compatibility purposes (if COMPAT_20), but struct statfs has been removed from the header files. This breaks the PowerPC simulator, which assumes that the existence of the statfs function implies the existence of struct statfs. This patch fixes this problem in the obvious way. I'm not sure why the NetBSD emulation implements fstatfs(). With this patch, it will stop doing so. If implementing fstatfs() is important, somebody will have to add support for the new fstatvfs() system call. OK for mainline? Ian * configure.in: Check for sys/mount.h, sys/vfs.h, sys/statfs.h. Check for struct statfs. * emul_netbsd.c: If not HAVE_STRUCT_STATFS, #undef HAVE_FSTATFS. * configure, config.in: Regenerate. [ Diffs for configure and config.in omitted ] Index: configure.in =================================================================== RCS file: /cvs/src/src/sim/ppc/configure.in,v retrieving revision 1.5 diff -u -r1.5 configure.in --- configure.in 11 May 2004 02:21:58 -0000 1.5 +++ configure.in 21 Sep 2004 02:19:53 -0000 @@ -585,7 +585,7 @@ AC_CHECK_FUNCS(access cfgetispeed cfgetospeed cfsetispeed cfsetospeed chdir chmod chown dup dup2 fchmod fchown fcntl fstat fstatfs getdirentries getegid geteuid getgid getpid getppid getrusage gettimeofday getuid ioctl kill link lseek lstat mkdir pipe readlink rmdir setreuid setregid stat sigprocmask stat symlink tcgetattr tcsetattr tcsendbreak tcdrain tcflush tcflow tcgetpgrp tcsetpgrp time umask unlink) -AC_CHECK_HEADERS(fcntl.h stdlib.h string.h strings.h sys/ioctl.h sys/param.h sys/resource.h sys/stat.h sys/termio.h sys/termios.h sys/time.h sys/times.h sys/types.h time.h unistd.h) +AC_CHECK_HEADERS(fcntl.h stdlib.h string.h strings.h sys/ioctl.h sys/mount.h sys/param.h sys/resource.h sys/stat.h sys/termio.h sys/termios.h sys/time.h sys/times.h sys/types.h time.h unistd.h sys/vfs.h sys/statfs.h) AC_HEADER_DIRENT dnl Figure out what type of termio/termios support there is @@ -658,6 +658,30 @@ ac_cv_termio_cline=no fi +dnl Check for struct statfs +AC_MSG_CHECKING(for struct statfs) +AC_CACHE_VAL(ac_cv_struct_statfs, +[AC_TRY_COMPILE([#include +#ifdef HAVE_SYS_PARAM_H +#include +#endif +#ifdef HAVE_SYS_MOUNT_H +#include +#endif +#ifdef HAVE_SYS_VFS_H +#include +#endif +#ifdef HAVE_SYS_STATFS_H +#include +#endif], +[static struct statfs s;], +ac_cv_struct_statfs=yes, ac_cv_struct_statfs=no)]) +AC_MSG_RESULT($ac_cv_struct_statfs) +if test $ac_cv_struct_statfs = yes; then + AC_DEFINE(HAVE_STRUCT_STATFS, 1, + [Define if struct statfs is defined in ]) +fi + dnl Figure out if /dev/zero exists or not sim_devzero="" AC_MSG_CHECKING(for /dev/zero) Index: emul_netbsd.c =================================================================== RCS file: /cvs/src/src/sim/ppc/emul_netbsd.c,v retrieving revision 1.4 diff -u -r1.4 emul_netbsd.c --- emul_netbsd.c 17 Oct 2003 00:15:25 -0000 1.4 +++ emul_netbsd.c 21 Sep 2004 02:19:53 -0000 @@ -94,6 +94,14 @@ #include #include extern int getdirentries(int fd, char *buf, int nbytes, long *basep); + +/* NetBSD post 2.0 has the statfs system call (if COMPAT_20), but does + not have struct statfs. In this case don't implement fstatfs. + FIXME: Should implement fstatvfs. */ +#ifndef HAVE_STRUCT_STATFS +#undef HAVE_FSTATFS +#endif + #else /* If this is not netbsd, don't allow fstatfs or getdirentries at this time */