Subject: bug#41264: Bootstrap packages fail to build.

From: Mathieu Othacehe <[email-masked]>
Date: Tue, 19 May 2020 10:52:28 +0200

Hello,

> So stat, lstat, and all other related function will return -EOVERFLOW
> unless their 64 bits stat64, lstat64 counterpart is used.
>
> So I think this means that one cannot build the Guix bootstrap toolchain on an
> NVME disk.

After further investigations I think that it is needed to patch GNU Mes
to fix this bug.

We would need to add three new syscalls for x86:

--8<---------------cut here---------------start------------->8---
#define SYS_stat64    0xc3
#define SYS_lstat64   0xc4
#define SYS_fstat64   0xc5
--8<---------------cut here---------------end--------------->8---

lib/linux/stat.c should be modified this way:

--8<---------------cut here---------------start------------->8---
#if __i386__
#define STAT_SYSCALL SYS_stat64
#else
#define STAT_SYSCALL SYS_stat
#endif

int
stat (char const *file_name, struct stat *statbuf)
{
  struct stat64 statbuf64;
  int ret;

  ret = _sys_call2 (STAT_SYSCALL, (long) file_name, (long) &statbuf64);

#if __i386__
  stat64_to_32(&statbuf64, statbuf);
#else
  *statbuf = statbuf64;
#endif

  return ret;
}
--8<---------------cut here---------------end--------------->8---

Then we would need to create stat64_to_32 which could be inspired from
__xstat64_conv from the glibc. Then, lstat and fstat64 would need to be
patched the same way.

This way, we would replicate the glibc behavior.

Thanks,

Mathieu