This is the mail archive of the libc-alpha@sources.redhat.com mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

PATCH: Fix struct stat [__USE_FILE_OFFSET64] in sysdeps/unix/sysv/linux/bits/stat.h


Hi.

This bug is visible for programs compiled with
-D_FILE_OFFSET_BITS=64 on platforms where the ABI says there is
no alignment-padding between structure elements.  AFAIK only
cris-axis-linux-gnu matches that description.  The bug causes
struct stat and struct stat64 to have different layout.  To
repeat, compile GNU awk (3.1.1 specifically) on a
cris-axis-linux-gnu platform.  Boom; "gawk: fatal error:
internal error" even with just "gawk --help".  Reportedly ls
(from fileutils?) is also built with _FILE_OFFSET_BITS 64 by
default; the bug "only" causes erroneous output there.
User-level workaround: don't compile programs with
-D_FILE_OFFSET_BITS=64 (usually translates to: configure
programs with --disable-largefile).

2003-06-03  Hans-Peter Nilsson  <hp@axis.com>

	* sysdeps/unix/sysv/linux/bits/stat.h (struct stat): Move __pad1
	and __pad2 inside #ifndef/else __USE_FILE_OFFSET64.  Use types
	matching stat64.

Index: sysdeps/unix/sysv/linux/bits/stat.h
===================================================================
RCS file: /cvs/glibc/libc/sysdeps/unix/sysv/linux/bits/stat.h,v
retrieving revision 1.15
diff -c -p -r1.15 stat.h
*** sysdeps/unix/sysv/linux/bits/stat.h	8 Feb 2002 07:48:10 -0000	1.15
--- sysdeps/unix/sysv/linux/bits/stat.h	3 Jun 2003 08:57:55 -0000
***************
*** 1,4 ****
! /* Copyright (C) 1992, 1995-2001, 2002 Free Software Foundation, Inc.
     This file is part of the GNU C Library.
  
     The GNU C Library is free software; you can redistribute it and/or
--- 1,4 ----
! /* Copyright (C) 1992, 1995-2001, 2002, 2003 Free Software Foundation, Inc.
     This file is part of the GNU C Library.
  
     The GNU C Library is free software; you can redistribute it and/or
***************
*** 36,45 ****
  struct stat
    {
      __dev_t st_dev;			/* Device.  */
-     unsigned short int __pad1;
  #ifndef __USE_FILE_OFFSET64
      __ino_t st_ino;			/* File serial number.	*/
  #else
      __ino_t __st_ino;			/* 32bit file serial number.	*/
  #endif
      __mode_t st_mode;			/* File mode.  */
--- 36,46 ----
  struct stat
    {
      __dev_t st_dev;			/* Device.  */
  #ifndef __USE_FILE_OFFSET64
+     unsigned short int __pad1;
      __ino_t st_ino;			/* File serial number.	*/
  #else
+     unsigned int __pad1;
      __ino_t __st_ino;			/* 32bit file serial number.	*/
  #endif
      __mode_t st_mode;			/* File mode.  */
*************** struct stat
*** 47,56 ****
      __uid_t st_uid;			/* User ID of the file's owner.	*/
      __gid_t st_gid;			/* Group ID of the file's group.*/
      __dev_t st_rdev;			/* Device number, if device.  */
-     unsigned short int __pad2;
  #ifndef __USE_FILE_OFFSET64
      __off_t st_size;			/* Size of file, in bytes.  */
  #else
      __off64_t st_size;			/* Size of file, in bytes.  */
  #endif
      __blksize_t st_blksize;		/* Optimal block size for I/O.  */
--- 48,58 ----
      __uid_t st_uid;			/* User ID of the file's owner.	*/
      __gid_t st_gid;			/* Group ID of the file's group.*/
      __dev_t st_rdev;			/* Device number, if device.  */
  #ifndef __USE_FILE_OFFSET64
+     unsigned short int __pad2;
      __off_t st_size;			/* Size of file, in bytes.  */
  #else
+     unsigned int __pad2;
      __off64_t st_size;			/* Size of file, in bytes.  */
  #endif
      __blksize_t st_blksize;		/* Optimal block size for I/O.  */

brgds, H-P


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]