PATCH RFA: Handle lack of struct statfs in ppc/sim/emul_netbsd.c

Ian Lance Taylor ian@wasabisystems.com
Tue Sep 21 02:26:00 GMT 2004


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 <sys/types.h>
+#ifdef HAVE_SYS_PARAM_H
+#include <sys/param.h>
+#endif
+#ifdef HAVE_SYS_MOUNT_H
+#include <sys/mount.h>
+#endif
+#ifdef HAVE_SYS_VFS_H
+#include <sys/vfs.h>
+#endif
+#ifdef HAVE_SYS_STATFS_H
+#include <sys/statfs.h>
+#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 <sys/mount.h>])
+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 <sys/sysctl.h>
 #include <sys/mount.h>
 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 */



More information about the Gdb-patches mailing list