bug-mes
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH v2] lib: Fix struct stat's fields for riscv64.


From: Ekaitz Zarraga
Subject: [PATCH v2] lib: Fix struct stat's fields for riscv64.
Date: Thu, 7 Mar 2024 00:59:17 +0100

We detected this behavior when building `make` with `tcc` during the
bootstrapping process.  That resulting `make` rebuilt the files, even if
they were just built.

This problem broke the whole Guix bootstrapping process as the
`configure` script was run again in the `build` step because the `make`
program thought it needed a rebuild.  This wouldn't be that much of a
problem if it wasn't that the phase that patches the shebangs on the
generated files is run after `configure` and not after the
"re-configure" that was triggered during the `build` phase.  That made
every generated file that was using `/usr/bin/sh` to explode.

Other architectures (x86_64 is the most suspicious one) may have the
same issue.

NOTE: We used `musl` as a reference, but we have different field names,
which ones should we keep?

    Ours:                              Musl:
      time_t         st_atime;           long st_atime_sec;
      unsigned long  st_atime_usec;      long st_atime_nsec;
      time_t         st_mtime;           long st_mtime_sec;
      unsigned long  st_mtime_usec;      long st_mtime_nsec;
      time_t         st_ctime;           long st_ctime_sec;
      unsigned long  st_ctime_usec;      long st_ctime_nsec;

* include/linux/riscv64/kernel-stat.h (struct stat): Introduce padding
and fix field lengths.
---
 include/linux/riscv64/kernel-stat.h | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/include/linux/riscv64/kernel-stat.h 
b/include/linux/riscv64/kernel-stat.h
index 9519ef39..e3d46703 100644
--- a/include/linux/riscv64/kernel-stat.h
+++ b/include/linux/riscv64/kernel-stat.h
@@ -1,6 +1,7 @@
 /* -*-comment-start: "//";comment-end:""-*-
  * GNU Mes --- Maxwell Equations of Software
  * Copyright © 2021 W. J. van der Laan <laanwj@protonmail.com>
+ * Copyright © 2024 Ekaitz Zarraga <ekaitz@elenq.tech>
  *
  * This file is part of GNU Mes.
  *
@@ -30,8 +31,10 @@ struct stat
   unsigned int   st_uid;
   unsigned int   st_gid;
   unsigned long  st_rdev;
+  unsigned long  __pad;
   long           st_size;
-  unsigned long  st_blksize;
+  int            st_blksize;
+  int            __pad2;
   unsigned long  st_blocks;
   time_t         st_atime;
   unsigned long  st_atime_usec;
@@ -40,7 +43,6 @@ struct stat
   time_t         st_ctime;
   unsigned long  st_ctime_usec;
   unsigned long  __foo0;
-  unsigned long  __foo1;
 };
 
 #endif // __MES_LINUX_RISCV64_KERNEL_STAT_H
-- 
2.41.0




reply via email to

[Prev in Thread] Current Thread [Next in Thread]