Subject: bug#9140: Coreutils Bug on OSX 10.7 (Lion)

From: Bruno Haible <[email-masked]>
Date: Sun, 24 Jul 2011 23:59:42 +0200

Paul Eggert wrote:
> * m4/fsusage.m4 (gl_FILE_SYSTEM_USAGE): Reject statvfs
> implementations that use only 32 bits to count blocks.

Dealing with the statvfs() / statfs() calls is one thing.
But 'df' also relies on the 'mountlist' module, which on MacOS X
uses the function getmntinfo(). This function too exists in
two variants

  getmntinfo
  getmntinfo$INODE64   equivalent to   getmntinfo64

and the first one returns 'struct statfs' entities with 32-bit
f_blocks. Likewise there is

  getfsstat
  getfsstat$INODE64   equivalent to   getfsstat64

Here's an excerpt from the manual page:

NAME
     getmntinfo -- get information about mounted file systems

...
     int
     getmntinfo(struct statfs **mntbufp, int flags);

     int
     getmntinfo64(struct statfs64 **mntbufp, int flags);

...
     The getmntinfo() function passes its flags argument transparently to
     getfsstat(2), while the getmntinfo64() function passes
     its flags argument transparently to getfsstat64().

See [1][2]. So, if the 'mountlist' modules is used outside of coreutils, it
also needs the 'largefile' module, so as to map getmntinfo to
getmntinfo$INODE64. Here's a proposed patch.

[1] http://developer.apple.com/library/mac/#documentation/Darwin/Reference/ManPages/man3/getmntinfo.3.html
[2] http://developer.apple.com/library/mac/#documentation/Darwin/Reference/ManPages/man2/getfsstat.2.html

2011-07-24  Bruno Haible  <[email-masked]>

	mountlist: Enable large volume support on MacOS X >= 10.5.
	* m4/ls-mntd-fs.m4 (gl_LIST_MOUNTED_FILE_SYSTEMS): Require AC_SYS_LARGEFILE.
	* modules/mountlist (Depends-on): Add largefile.

--- m4/ls-mntd-fs.m4.orig	Sun Jul 24 23:44:01 2011
+++ m4/ls-mntd-fs.m4	Sun Jul 24 22:41:08 2011
@@ -1,4 +1,4 @@
-# serial 29
+# serial 30
 # How to list mounted file systems.
 
 # Copyright (C) 1998-2004, 2006, 2009-2011 Free Software Foundation, Inc.
@@ -26,6 +26,12 @@
 # gl_LIST_MOUNTED_FILE_SYSTEMS([ACTION-IF-FOUND[, ACTION-IF-NOT-FOUND]])
 AC_DEFUN([gl_LIST_MOUNTED_FILE_SYSTEMS],
   [
+dnl Enable large-file support. This has the effect of changing the size
+dnl of field f_blocks in 'struct statfs' from 32 bit to 64 bit on
+dnl MacOS X >= 10.5 (32-bit mode), allowing file systems >= 4 TiB to be
+dnl found.
+AC_REQUIRE([AC_SYS_LARGEFILE])
+
 AC_CHECK_FUNCS([listmntent getmntinfo])
 AC_CHECK_HEADERS_ONCE([sys/param.h sys/statvfs.h])
 
--- modules/mountlist.orig	Sun Jul 24 23:44:01 2011
+++ modules/mountlist	Sun Jul 24 22:30:10 2011
@@ -9,6 +9,7 @@
 m4/mountlist.m4
 
 Depends-on:
+largefile
 stdbool
 stdint
 strstr-simple
-- 
In memoriam Ezechiele Ramin <http://en.wikipedia.org/wiki/Ezechiele_Ramin>