Bug 1864

Summary: bad struct statvfs declaration on Alpha when _FILE_OFFSET_BITS is defined
Product: glibc Reporter: Sergey Tikhonov <tsv>
Component: portsAssignee: Not yet assigned to anyone <unassigned>
Severity: normal CC: glibc-bugs, rth, rth, samuel.thibault, stefaan.deroeck, vapier
Priority: P2 Flags: fweimer: security-
Version: 2.3.5   
Target Milestone: ---   
Host: alpha-unknown-linux Target: alpha-unknown-linux
Build: alpha-unknown-linux Last reconfirmed:
Attachments: make alpha use a dual 32/64bit interface for *stat*fs*

Description Sergey Tikhonov 2005-11-14 20:38:15 UTC
GNU C Library development release version 2.3.5, by Roland McGrath et al.
Copyright (C) 2005 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.
There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A
Compiled by GNU CC version 4.0.1 20050727 (Red Hat 4.0.1-5).
Compiled on a Linux 2.4.20 system on 2005-11-01.

The following test program shows invalid behavior:
#include <sys/statvfs.h>
#include <stdio.h>

void print(struct statvfs value)
         printf("%ld\n", (long)value.f_bavail);

int main(int argc, char*argv[])
         struct statvfs st;
                 printf("usage: checkstat <path>\n");
                 return 1;
         statvfs(argv[1], &st);

falk@juist:/tmp% df /                   
Filesystem           1K-blocks      Used Available Use% Mounted on
/dev/hda1               127383     88516     32290  74% /
falk@juist:/tmp% gcc test.c && ./a.out /
falk@juist:/tmp% gcc -D_FILE_OFFSET_BITS=64 test.c && ./a.out /

The problem seems to be that ./sysdeps/unix/sysv/linux/alpha/bits/typesizes.h is
different from ./sysdeps/generic/bits/typesizes.h and defines
macros as 32 and 64 bits. I guess the glibc is build with 32 bits

What is the correct way to fix it? To define above macros the same way as it is
done in generic version?

Thank you
Comment 1 Sergey Tikhonov 2005-11-15 15:05:45 UTC
It seems that in 1999 there was change that converted __FSBLKCNT_T_TYPE,
__FSFILCNT_T_TYPE from 64 bits to 32 bits for alpha. So the question is how it
should work with _FILE_OFFSET_BITS defined.
Comment 2 Stefaan 2005-11-29 09:29:50 UTC
Encountered the same problem when trying to run net-snmp (daemon) on alpha
(latest gentoo stable). Worked around it by hacking into typesizes.h (yes, very
dirty). A clean fix would be really nice.
Comment 3 Samuel Thibault 2008-08-12 02:30:12 UTC
Mmm, looking at kernel source, it looks likes alpha is indeed the only 64bit arch that has a 32bit stat/statfs interface (probably because that's the oldest one).  And although work has been done to expose a 64bit interface to userland for stat, it wasn't for statfs, and applications have been compiled with a dual 32/64bit interface.  Could you try the attached patch? 
Comment 4 Samuel Thibault 2008-08-12 02:31:21 UTC
Created attachment 2903 [details]
make alpha use a dual 32/64bit interface for *stat*fs*
Comment 5 Ulrich Drepper 2008-11-26 23:27:28 UTC
Alpha is not in the main tree anymore since we have no maintainer.  Somebody has
to step up and volunteer to be the maintainer of the alpha ports tree or nothing
will happen.
Comment 6 Richard Henderson 2012-02-15 18:16:37 UTC
This has been fixed since

commit 7ffd2bd725c3e4d77e6bfe36b76500d20427929d
Author: Richard Henderson <rth@twiddle.net>
Date:   Wed May 5 08:12:11 2010 -0700

    alpha: Do the 32/64-bit split on statfs routines.