Subject: kern/2779: SVR4-emulation statvfs is wrong; makes WABI break (easy fix)
To: None <gnats-bugs@gnats.netbsd.org>
From: None <abrown@eecs.harvard.edu>
List: netbsd-bugs
Date: 09/24/1996 22:39:32
>Number: 2779
>Category: kern
>Synopsis: SVR4-emulation statvfs is wrong; makes WABI break (easy fix)
>Confidential: no
>Severity: non-critical
>Priority: medium
>Responsible: kern-bug-people (Kernel Bug People)
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Tue Sep 24 19:50:01 1996
>Last-Modified:
>Originator: Aaron Brown
>Organization:
Harvard University Computer Science
>Release: 1.2A, 20 September 1996
>Environment:
Sun SPARCstation 20, fully -current world as of 9/20/96, running
SVR4 emulation with libs from Solaris 2.4
System: NetBSD abrown-2 1.2A NetBSD 1.2A (ABROWN) #2: Tue Sep 24 17:08:40 EDT 1996 abrown@abrown-2:/usr/src/sys/arch/sparc/compile/ABROWN sparc
>Description:
The SVR4 emulation code for statvfs returns the BSD fragment size
as the file system's "preferred FS block size" (solaris manpage) and
the fragment size/8 as the fundamental FS block size. It then reports
all the other stats in terms of the fragment size. This is wrong:
according to the Solaris manpage, all of the other disk stats
are in terms of the fundamental block size (f_frsize). Thus the
current mapping from BSD to SVR4 statfs is:
BSD SVR4
--- ----
f_bsize f_bsize
f_bsize/8 f_frsize
whereas it should be
f_iosize f_bsize (preferred I/O size)
f_bsize f_frsize (fragment size)
The upshot of this bug is that programs like WABI think that
the disk is full, since on a 8K/1K filesystem, it sees the
number of free bytes as f_bfree*128, as opposed to the correct
f_bfree*1024.
The fix is trivial and is included below, although I'm not sure
that the BSD "optimal transfer block size" is always the FFS
block size: thus the XXX.
>How-To-Repeat:
Install WABI 2.1. Try to install MS windows under WABI. Most likely
it will tell you that you don't have enough space (unless you have
a huge disk).
>Fix:
Apply this patch:
Index: svr4_misc.c
===================================================================
RCS file: /cvsroot/src/sys/compat/svr4/svr4_misc.c,v
retrieving revision 1.39
diff -c -r1.39 svr4_misc.c
*** svr4_misc.c 1996/09/03 03:12:38 1.39
--- svr4_misc.c 1996/09/24 21:18:12
***************
*** 1103,1110 ****
const struct statfs *bfs;
struct svr4_statvfs *sfs;
{
! sfs->f_bsize = bfs->f_bsize;
! sfs->f_frsize = bfs->f_bsize / 8; /* XXX */
sfs->f_blocks = bfs->f_blocks;
sfs->f_bfree = bfs->f_bfree;
sfs->f_bavail = bfs->f_bavail;
--- 1103,1110 ----
const struct statfs *bfs;
struct svr4_statvfs *sfs;
{
! sfs->f_bsize = bfs->f_iosize; /* XXX */
! sfs->f_frsize = bfs->f_bsize;
sfs->f_blocks = bfs->f_blocks;
sfs->f_bfree = bfs->f_bfree;
sfs->f_bavail = bfs->f_bavail;
>Audit-Trail:
>Unformatted: