Buildroot Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [Buildroot] [PATCH] package/e2tools: fix build with uClibc on mips64
@ 2026-09-08 13:20 Yegor Yefremov via buildroot
  2026-09-18 19:45 ` Thomas Petazzoni via buildroot
  0 siblings, 1 reply; 4+ messages in thread
From: Yegor Yefremov via buildroot @ 2026-09-08 13:20 UTC (permalink / raw)
  To: buildroot

From: Yegor Yefremov <yegorslists@googlemail.com>

put_file() passes &statbuf.st_size to store_data(), which takes an
'off_t *'. On mips64 those types do not match: uClibc-ng declares
'struct stat::st_size' as '__off_t' (long int) for the N32/N64 ABI,
while '_FILE_OFFSET_BITS=64' makes 'off_t' an alias of '__off64_t'
(long long int). Both are 64 bit wide, but they are distinct types, so
gcc 14 and later reject the call:

src/write.c: In function 'put_file':
src/write.c:237:45: error: passing argument 4 of 'store_data' from incompatible pointer type [-Wincompatible-pointer-types]
  237 |       (retval = store_data(fs, fd, newfile, &statbuf.st_size)))
      |                                             ^~~~~~~~~~~~~~~~
      |                                             |
      |                                             __off_t * {aka long int *}

Add a patch using a local 'off_t' variable instead, copying the size
reported by store_data() back into statbuf.

Fixes:
https://autobuild.buildroot.org/results/49754464e5daf87f69de8a79d7e6d607c00c78e2/

Signed-off-by: Yegor Yefremov <yegorslists@googlemail.com>
Assisted-by: Claude:claude-opus-5
---
 ...ss-struct-stat-st_size-to-store_data.patch | 74 +++++++++++++++++++
 1 file changed, 74 insertions(+)
 create mode 100644 package/e2tools/0001-write-do-not-pass-struct-stat-st_size-to-store_data.patch

diff --git a/package/e2tools/0001-write-do-not-pass-struct-stat-st_size-to-store_data.patch b/package/e2tools/0001-write-do-not-pass-struct-stat-st_size-to-store_data.patch
new file mode 100644
index 0000000000..86dd01192c
--- /dev/null
+++ b/package/e2tools/0001-write-do-not-pass-struct-stat-st_size-to-store_data.patch
@@ -0,0 +1,74 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: Yegor Yefremov <yegorslists@googlemail.com>
+Date: Tue, 8 Sep 2026 12:00:00 +0200
+Subject: [PATCH] write: do not pass &statbuf.st_size to store_data()
+
+store_data() takes an 'off_t *', but put_file() hands it the address of
+'statbuf.st_size', whose type is whatever the C library declares in
+'struct stat'. Those two types are not required to match: on mips64
+uClibc-ng declares 'struct stat::st_size' as '__off_t' (long int), while
+'_FILE_OFFSET_BITS=64' makes 'off_t' an alias of '__off64_t' (long long
+int). Both are 64 bit wide, but they are distinct types, so gcc 14 and
+later reject the call:
+
+src/write.c: In function 'put_file':
+src/write.c:237:45: error: passing argument 4 of 'store_data' from incompatible pointer type [-Wincompatible-pointer-types]
+  237 |       (retval = store_data(fs, fd, newfile, &statbuf.st_size)))
+      |                                             ^~~~~~~~~~~~~~~~
+      |                                             |
+      |                                             __off_t * {aka long int *}
+src/write.c:49:63: note: expected 'off_t *' {aka 'long long int *'} but argument is of type '__off_t *' {aka 'long int *'}
+   49 | store_data(ext2_filsys fs, int fd, ext2_ino_t newfile, off_t *file_size);
+      |                                                        ~~~~~~~^~~~~~~~~
+
+Use a local 'off_t' variable instead and copy the size store_data()
+reports back into statbuf, which is what the code below (the stdin case,
+where the size is only known after the copy) relies on.
+
+Upstream: https://github.com/e2tools/e2tools/pull/40
+Signed-off-by: Yegor Yefremov <yegorslists@googlemail.com>
+Assisted-by: Claude:claude-opus-5
+---
+ src/write.c | 19 ++++++++++++++-----
+ 1 file changed, 14 insertions(+), 5 deletions(-)
+
+diff --git a/src/write.c b/src/write.c
+index 1111111..2222222 100644
+--- a/src/write.c
++++ b/src/write.c
+@@ -114,6 +114,7 @@ put_file(ext2_filsys fs, ext2_ino_t cwd, char *infile, char *outfile,
+   long  retval;
+   struct ext2_inode inode;
+   mode_t cur_umask;
++  off_t file_size;
+ 
+   if (fs == NULL || outfile == NULL)
+     {
+@@ -233,15 +234,19 @@ put_file(ext2_filsys fs, ext2_ino_t cwd, char *infile, char *outfile,
+       return (retval);
+     }
+ 
+-  if (LINUX_S_ISREG(inode.i_mode) &&
+-      (retval = store_data(fs, fd, newfile, &statbuf.st_size)))
++  if (LINUX_S_ISREG(inode.i_mode))
+     {
+-      close(fd);
++      file_size = statbuf.st_size;
++      if ((retval = store_data(fs, fd, newfile, &file_size)))
++        {
++          close(fd);
+ #ifndef DEBUG
+-      rm_file(fs, cwd, outfile, newfile);
++          rm_file(fs, cwd, outfile, newfile);
+ 
+ #endif
+-      return(retval);
++          return(retval);
++        }
++      statbuf.st_size = file_size;
+     }
+ 
+   close(fd);
+-- 
+2.51.0
+
-- 
2.34.1

_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [Buildroot] [PATCH] package/e2tools: fix build with uClibc on mips64
  2026-09-08 13:20 [Buildroot] [PATCH] package/e2tools: fix build with uClibc on mips64 Yegor Yefremov via buildroot
@ 2026-09-18 19:45 ` Thomas Petazzoni via buildroot
  2026-09-19  6:40   ` Waldemar Brodkorb
  0 siblings, 1 reply; 4+ messages in thread
From: Thomas Petazzoni via buildroot @ 2026-09-18 19:45 UTC (permalink / raw)
  To: Yegor Yefremov; +Cc: buildroot

Hello Yegor,

(+Waldemar in Cc)

On Tue, Sep 08, 2026 at 03:20:30PM +0200, Yegor Yefremov via buildroot wrote:

> diff --git a/package/e2tools/0001-write-do-not-pass-struct-stat-st_size-to-store_data.patch b/package/e2tools/0001-write-do-not-pass-struct-stat-st_size-to-store_data.patch
> new file mode 100644
> index 0000000000..86dd01192c
> --- /dev/null
> +++ b/package/e2tools/0001-write-do-not-pass-struct-stat-st_size-to-store_data.patch
> @@ -0,0 +1,74 @@
> +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
> +From: Yegor Yefremov <yegorslists@googlemail.com>
> +Date: Tue, 8 Sep 2026 12:00:00 +0200
> +Subject: [PATCH] write: do not pass &statbuf.st_size to store_data()
> +
> +store_data() takes an 'off_t *', but put_file() hands it the address of
> +'statbuf.st_size', whose type is whatever the C library declares in
> +'struct stat'. Those two types are not required to match: on mips64
> +uClibc-ng declares 'struct stat::st_size' as '__off_t' (long int), while
> +'_FILE_OFFSET_BITS=64' makes 'off_t' an alias of '__off64_t' (long long
> +int). Both are 64 bit wide, but they are distinct types, so gcc 14 and
> +later reject the call:

Are you sure this is the correct fix?

When I look at stat(3type) it says:

       struct stat {
           dev_t      st_dev;      /* ID of device containing file */
           ino_t      st_ino;      /* Inode number */
           mode_t     st_mode;     /* File type and mode */
           nlink_t    st_nlink;    /* Number of hard links */
           uid_t      st_uid;      /* User ID of owner */
           gid_t      st_gid;      /* Group ID of owner */
           dev_t      st_rdev;     /* Device ID (if special file) */
           off_t      st_size;     /* Total size, in bytes */

So st_size is an off_t, so passing &blabla.st_size to a function
expecting an off_t* should always work.

And the fact that this (apparently) only occurs on uClibc makes me
think that this is more likely a uClibc bug.

Waldemar, do you have any thoughts?

Thomas
-- 
Thomas Petazzoni, co-owner and CEO, Bootlin
Embedded Linux and Kernel engineering and training
https://bootlin.com
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Buildroot] [PATCH] package/e2tools: fix build with uClibc on mips64
  2026-09-18 19:45 ` Thomas Petazzoni via buildroot
@ 2026-09-19  6:40   ` Waldemar Brodkorb
  2026-09-19  6:52     ` Yegor Yefremov via buildroot
  0 siblings, 1 reply; 4+ messages in thread
From: Waldemar Brodkorb @ 2026-09-19  6:40 UTC (permalink / raw)
  To: Thomas Petazzoni; +Cc: buildroot

Hi Thomas, Yegor, all,
Thomas Petazzoni wrote,

> Hello Yegor,
> 
> (+Waldemar in Cc)
> 
> On Tue, Sep 08, 2026 at 03:20:30PM +0200, Yegor Yefremov via buildroot wrote:
> 
> > diff --git a/package/e2tools/0001-write-do-not-pass-struct-stat-st_size-to-store_data.patch b/package/e2tools/0001-write-do-not-pass-struct-stat-st_size-to-store_data.patch
> > new file mode 100644
> > index 0000000000..86dd01192c
> > --- /dev/null
> > +++ b/package/e2tools/0001-write-do-not-pass-struct-stat-st_size-to-store_data.patch
> > @@ -0,0 +1,74 @@
> > +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
> > +From: Yegor Yefremov <yegorslists@googlemail.com>
> > +Date: Tue, 8 Sep 2026 12:00:00 +0200
> > +Subject: [PATCH] write: do not pass &statbuf.st_size to store_data()
> > +
> > +store_data() takes an 'off_t *', but put_file() hands it the address of
> > +'statbuf.st_size', whose type is whatever the C library declares in
> > +'struct stat'. Those two types are not required to match: on mips64
> > +uClibc-ng declares 'struct stat::st_size' as '__off_t' (long int), while
> > +'_FILE_OFFSET_BITS=64' makes 'off_t' an alias of '__off64_t' (long long
> > +int). Both are 64 bit wide, but they are distinct types, so gcc 14 and
> > +later reject the call:
> 
> Are you sure this is the correct fix?
> 
> When I look at stat(3type) it says:
> 
>        struct stat {
>            dev_t      st_dev;      /* ID of device containing file */
>            ino_t      st_ino;      /* Inode number */
>            mode_t     st_mode;     /* File type and mode */
>            nlink_t    st_nlink;    /* Number of hard links */
>            uid_t      st_uid;      /* User ID of owner */
>            gid_t      st_gid;      /* Group ID of owner */
>            dev_t      st_rdev;     /* Device ID (if special file) */
>            off_t      st_size;     /* Total size, in bytes */
> 
> So st_size is an off_t, so passing &blabla.st_size to a function
> expecting an off_t* should always work.
> 
> And the fact that this (apparently) only occurs on uClibc makes me
> think that this is more likely a uClibc bug.
> 
> Waldemar, do you have any thoughts?

I believe you are right, it is a uClibc-ng Bug. I could reproduce
the issue with MIPS64 (LE) N32. A fix is committed to uClibc-ng 
git repository.

https://github.com/wbx-github/uclibc-ng/commit/4d307481e2c73e4ec6ae3e37c881d29c182bed58

best regards
 Waldemar

_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Buildroot] [PATCH] package/e2tools: fix build with uClibc on mips64
  2026-09-19  6:40   ` Waldemar Brodkorb
@ 2026-09-19  6:52     ` Yegor Yefremov via buildroot
  0 siblings, 0 replies; 4+ messages in thread
From: Yegor Yefremov via buildroot @ 2026-09-19  6:52 UTC (permalink / raw)
  To: Waldemar Brodkorb; +Cc: Thomas Petazzoni, buildroot

Hi Waldemar, Thomas, all,

On Sat, Sep 19, 2026 at 8:40 AM Waldemar Brodkorb <wbx@openadk.org> wrote:
>
> Hi Thomas, Yegor, all,
> Thomas Petazzoni wrote,
>
> > Hello Yegor,
> >
> > (+Waldemar in Cc)
> >
> > On Tue, Sep 08, 2026 at 03:20:30PM +0200, Yegor Yefremov via buildroot wrote:
> >
> > > diff --git a/package/e2tools/0001-write-do-not-pass-struct-stat-st_size-to-store_data.patch b/package/e2tools/0001-write-do-not-pass-struct-stat-st_size-to-store_data.patch
> > > new file mode 100644
> > > index 0000000000..86dd01192c
> > > --- /dev/null
> > > +++ b/package/e2tools/0001-write-do-not-pass-struct-stat-st_size-to-store_data.patch
> > > @@ -0,0 +1,74 @@
> > > +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
> > > +From: Yegor Yefremov <yegorslists@googlemail.com>
> > > +Date: Tue, 8 Sep 2026 12:00:00 +0200
> > > +Subject: [PATCH] write: do not pass &statbuf.st_size to store_data()
> > > +
> > > +store_data() takes an 'off_t *', but put_file() hands it the address of
> > > +'statbuf.st_size', whose type is whatever the C library declares in
> > > +'struct stat'. Those two types are not required to match: on mips64
> > > +uClibc-ng declares 'struct stat::st_size' as '__off_t' (long int), while
> > > +'_FILE_OFFSET_BITS=64' makes 'off_t' an alias of '__off64_t' (long long
> > > +int). Both are 64 bit wide, but they are distinct types, so gcc 14 and
> > > +later reject the call:
> >
> > Are you sure this is the correct fix?
> >
> > When I look at stat(3type) it says:
> >
> >        struct stat {
> >            dev_t      st_dev;      /* ID of device containing file */
> >            ino_t      st_ino;      /* Inode number */
> >            mode_t     st_mode;     /* File type and mode */
> >            nlink_t    st_nlink;    /* Number of hard links */
> >            uid_t      st_uid;      /* User ID of owner */
> >            gid_t      st_gid;      /* Group ID of owner */
> >            dev_t      st_rdev;     /* Device ID (if special file) */
> >            off_t      st_size;     /* Total size, in bytes */
> >
> > So st_size is an off_t, so passing &blabla.st_size to a function
> > expecting an off_t* should always work.
> >
> > And the fact that this (apparently) only occurs on uClibc makes me
> > think that this is more likely a uClibc bug.
> >
> > Waldemar, do you have any thoughts?
>
> I believe you are right, it is a uClibc-ng Bug. I could reproduce
> the issue with MIPS64 (LE) N32. A fix is committed to uClibc-ng
> git repository.
>
> https://github.com/wbx-github/uclibc-ng/commit/4d307481e2c73e4ec6ae3e37c881d29c182bed58

Then my solution was wrong and can be dismissed. I turned the upstream
PR to a draft.

Yegor
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-09-19  6:52 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-09-08 13:20 [Buildroot] [PATCH] package/e2tools: fix build with uClibc on mips64 Yegor Yefremov via buildroot
2026-09-18 19:45 ` Thomas Petazzoni via buildroot
2026-09-19  6:40   ` Waldemar Brodkorb
2026-09-19  6:52     ` Yegor Yefremov via buildroot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox