This is the mail archive of the libc-ports@sources.redhat.com mailing list for the libc-ports 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]

Alternative fix for MIPS fstatat() problems


As Khem said here:

    http://sources.redhat.com/ml/libc-ports/2006-08/msg00036.html

it isn't possible to build MIPS with --enable-kernel>=2.6.17.
Khem added:

  Index: sysdeps/unix/sysv/linux/mips/fxstatat.c
  ===================================================================
  --- /dev/null
  +++ sysdeps/unix/sysv/linux/mips/fxstatat.c
  @@ -0,0 +1 @@
  +#include <sysdeps/unix/sysv/linux/i386/fxstatat.c>

but although this compiles, I don't think it's right.  i386/fxstatat.c
expects the syscall to be called __NR_fstatat64, but it isn't for any of
the three MIPS ABIs.  fxstatat() therefore becomes an empty function,
without even a return statement.  (gcc does warn.)  The same problem
already applies to fxstatat64.c.

As I said on the linux-mips list, MIPS is unique in calling the
fstatat() syscall "__NR_fstatat".  I think this is misleading for o32,
as the syscall provides a stat64, and all the other stat64 syscalls have
a "64" suffix.  Other 64-bit targets call the syscall "__NR_newfstatat"
instead of "__NR_fstatat".

So I think we should:

  (1) Rename the o32 syscall to "__NR_fstatat64".

  (2) Rename the n32 and n64 syscalls to "__NR_newfstatat".

  (3) Add Khem's forwarder to mips/mip32 and thus use i386/fstatat.c
      for o32.  The file expects a stat64 syscall called "__NR_fstatat64"
      and uses __xstat32_conv to convert it to a 32-bit stat.

  (4) Use the generic fstatat64.c for o32.  The file expects a stat64
      syscall called "__NR_fstatat64" and does no conversion on the
      result.  This is OK because the kernel and user stat64 fields
      have the same offsets and sizes on o32.  The only difference
      is that the user stat64 has more trailing padding.

  (5) Use the generic fstatat.c for n32 and n64.  The file expects
      a plain stat syscall called "__NR_newfstatat".  It uses
      __xconv_stat to convert the result.

  (6) Use a new fstatat64.c for n32 and n64.  Call __NR_newfstatat
      and use __xstat_conv to convert the result.  (The kernel stat
      fields are not the same as the user stat64 fields; in particular,
      st_dev is 32-bit for the former and 64-bit for the latter.)

  (7) Define __xstat32_conv for o32, as required by (3).

I've submitted a patch for (1) and (2) to the linux-mips list.
The patch below does (3)-(7).  I also noticed a couple of other
things in xstatconv.c:

  - __xstat_conv doesn't check for overflow
  - we don't clear all the st_pad5 padding

I thought I'd fix those problems at the same time because the code
in question is basically the same as the new __xstat32_conv code.
I thought all three xstat functions should remain consistent.

I've tested the patch with and without --enable-kernel=2.6.18.
In the "without" case, I tested with a stock 2.6.18 kernel and
then with one in which the syscalls were disabled.  All three
combinations seemed to work for all three ABIs.

I've attached the test I used.  I compiled it twice for each
combination, once with and once without -D_FILE_OFFSET_BITS=64.

Richard


	* sysdeps/unix/sysv/linux/mips/xstatconv.c: Remove STAT_IS_KERNEL_STAT
	code.
	(__xstat_conv): Use memset to clear padding arrays.  Check for
	overflow.
	(__xstat64_conv): Use memset to clear padding arrays.
	(__xstat32_conv): New function.
	* sysdeps/unix/sysv/linux/mips/mips32/fxstatat.c: New file.
	* sysdeps/unix/sysv/linux/mips/mips64/fxstatat64.c: Likewise.

Attachment: fstatat.diff
Description: Text document

Attachment: fstatat-test.c
Description: Text document


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