* [PATCH 1/2] y2038: Adjust struct __stat64_t64 to be usable by redirected {f}stat{at} calls
@ 2020-10-13 13:16 Lukasz Majewski
2020-10-13 13:16 ` [PATCH 2/2] y2038: Remove not used __fstatat_time64 define Lukasz Majewski
2020-10-13 22:17 ` [PATCH 1/2] y2038: Adjust struct __stat64_t64 to be usable by redirected {f}stat{at} calls Joseph Myers
0 siblings, 2 replies; 6+ messages in thread
From: Lukasz Majewski @ 2020-10-13 13:16 UTC (permalink / raw)
To: Joseph Myers, Paul Eggert, Adhemerval Zanella
Cc: Alistair Francis, Arnd Bergmann, Alistair Francis, GNU C Library,
Florian Weimer, Carlos O'Donell, Stepan Golosunov,
Andreas Schwab, Zack Weinberg, Lukasz Majewski
When glibc port with __WORDSIZE==32 and __TIMESIZE!=64 (e.g. armv7) will
use redirected calls to {f}stat{at}64_time64 functions, it will accept
the struct __stat64_t64 as its argument.
To avoid errors related to proper data placement after casting from
struct __stat64_t64 to struct stat{64} it is necessary to add some missing
padding and update type of {__}st_ino member.
By adding the unsigned int pads there is a possibility to extend struct
stat from: sysdeps/unix/sysv/linux/bits/struct_stat.h
with:
unsigned short int __pad1;
+#ifdef __USE_TIME_BITS64
+ unsigned short int __timepad1;
+#endif
To have it binary compatible with struct __stat64_t64
---
sysdeps/unix/sysv/linux/struct_stat_time64.h | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/sysdeps/unix/sysv/linux/struct_stat_time64.h b/sysdeps/unix/sysv/linux/struct_stat_time64.h
index b85385b6f3..ca3f06c077 100644
--- a/sysdeps/unix/sysv/linux/struct_stat_time64.h
+++ b/sysdeps/unix/sysv/linux/struct_stat_time64.h
@@ -43,12 +43,14 @@
struct __stat64_t64
{
__dev_t st_dev; /* Device. */
- __ino64_t st_ino; /* file serial number. */
+ unsigned int __pad1;
+ __ino_t __st_ino; /* 32bit file serial number. */
__mode_t st_mode; /* File mode. */
__nlink_t st_nlink; /* Link count. */
__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 int __pad2;
__off64_t st_size; /* Size of file, in bytes. */
__blksize_t st_blksize; /* Optimal block size for I/O. */
__blkcnt64_t st_blocks; /* Number 512-byte blocks allocated. */
@@ -70,6 +72,7 @@ struct __stat64_t64
__fieldts64 (st_mtime);
__fieldts64 (st_ctime);
# endif /* __USE_XOPEN2K8 */
+ __ino64_t st_ino; /* file serial number. */
};
# define _STATBUF_ST_BLKSIZE
--
2.20.1
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 2/2] y2038: Remove not used __fstatat_time64 define
2020-10-13 13:16 [PATCH 1/2] y2038: Adjust struct __stat64_t64 to be usable by redirected {f}stat{at} calls Lukasz Majewski
@ 2020-10-13 13:16 ` Lukasz Majewski
2020-10-13 13:31 ` Andreas Schwab
2020-10-13 22:17 ` [PATCH 1/2] y2038: Adjust struct __stat64_t64 to be usable by redirected {f}stat{at} calls Joseph Myers
1 sibling, 1 reply; 6+ messages in thread
From: Lukasz Majewski @ 2020-10-13 13:16 UTC (permalink / raw)
To: Joseph Myers, Paul Eggert, Adhemerval Zanella
Cc: Alistair Francis, Arnd Bergmann, Alistair Francis, GNU C Library,
Florian Weimer, Carlos O'Donell, Stepan Golosunov,
Andreas Schwab, Zack Weinberg, Lukasz Majewski
This define is only present in the ./include/sys/stat.h file. As it is not
used in any other place it is eligible to be removed.
---
include/sys/stat.h | 1 -
1 file changed, 1 deletion(-)
diff --git a/include/sys/stat.h b/include/sys/stat.h
index 646a1622b3..108cb0c9bf 100644
--- a/include/sys/stat.h
+++ b/include/sys/stat.h
@@ -50,7 +50,6 @@ hidden_proto (__fstatat64)
# define __stat64_time64 __stat64
# define __fstat64_time64 __fstat64
# define __lstat64_time64 __lstat64
-# define __fstatat_time64 __fstatat
# define __fstatat64_time64 __fstatat64
# else
extern int __stat64_time64 (const char *file, struct __stat64_t64 *buf);
--
2.20.1
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 2/2] y2038: Remove not used __fstatat_time64 define
2020-10-13 13:16 ` [PATCH 2/2] y2038: Remove not used __fstatat_time64 define Lukasz Majewski
@ 2020-10-13 13:31 ` Andreas Schwab
0 siblings, 0 replies; 6+ messages in thread
From: Andreas Schwab @ 2020-10-13 13:31 UTC (permalink / raw)
To: Lukasz Majewski
Cc: Joseph Myers, Paul Eggert, Adhemerval Zanella, Alistair Francis,
Arnd Bergmann, Alistair Francis, GNU C Library, Florian Weimer,
Carlos O'Donell, Stepan Golosunov, Zack Weinberg
On Okt 13 2020, Lukasz Majewski wrote:
> This define is only present in the ./include/sys/stat.h file. As it is not
> used in any other place it is eligible to be removed.
Ok.
Andreas.
--
Andreas Schwab, SUSE Labs, schwab@suse.de
GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE 1748 E4D4 88E3 0EEA B9D7
"And now for something completely different."
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 1/2] y2038: Adjust struct __stat64_t64 to be usable by redirected {f}stat{at} calls
2020-10-13 13:16 [PATCH 1/2] y2038: Adjust struct __stat64_t64 to be usable by redirected {f}stat{at} calls Lukasz Majewski
2020-10-13 13:16 ` [PATCH 2/2] y2038: Remove not used __fstatat_time64 define Lukasz Majewski
@ 2020-10-13 22:17 ` Joseph Myers
2020-10-14 8:47 ` Lukasz Majewski
1 sibling, 1 reply; 6+ messages in thread
From: Joseph Myers @ 2020-10-13 22:17 UTC (permalink / raw)
To: Lukasz Majewski
Cc: Paul Eggert, Adhemerval Zanella, Florian Weimer, GNU C Library,
Andreas Schwab, Stepan Golosunov, Alistair Francis
On Tue, 13 Oct 2020, Lukasz Majewski wrote:
> When glibc port with __WORDSIZE==32 and __TIMESIZE!=64 (e.g. armv7) will
> use redirected calls to {f}stat{at}64_time64 functions, it will accept
> the struct __stat64_t64 as its argument.
>
> To avoid errors related to proper data placement after casting from
> struct __stat64_t64 to struct stat{64} it is necessary to add some missing
> padding and update type of {__}st_ino member.
When redirecting to those functions, the definitions of struct stat /
struct stat64 should automatically change as a result of the _TIME_BITS=64
definition so that they match the definitions of the __stat64_t64 type -
just as _FILE_OFFSET_BITS=64 results in changes to the content of struct
stat.
I believe the design is that __stat64_t64 has an architecture-independent
layout that is never required to match any particular kernel layout
because translation (typically from statx) will always occur in userspace.
Note that struct_stat_time64.h is currently an *uninstalled* header,
despite the name of the multiple-include guard in the header, and despite
the testing of feature test macros within the header (which only makes
sense for installed headers); it's not a bits/ header at present.
Maybe there should be some indirection so that the installed version of
struct_stat_time64.h defines a macro with all the contents of
__stat64_t64, so that all the many architecture-specific
bits/struct_stat.h headers can just use that macro to get the right
contents when _TIME_BITS=64 rather than needing to duplicate the structure
contents (at least twice per header, for both stat and stat64). But I
don't think any change to the layout of __stat64_t64 is indicated, because
there should always be explicit conversions between different layouts.
--
Joseph S. Myers
joseph@codesourcery.com
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 1/2] y2038: Adjust struct __stat64_t64 to be usable by redirected {f}stat{at} calls
2020-10-13 22:17 ` [PATCH 1/2] y2038: Adjust struct __stat64_t64 to be usable by redirected {f}stat{at} calls Joseph Myers
@ 2020-10-14 8:47 ` Lukasz Majewski
2020-10-14 13:09 ` Joseph Myers
0 siblings, 1 reply; 6+ messages in thread
From: Lukasz Majewski @ 2020-10-14 8:47 UTC (permalink / raw)
To: Joseph Myers
Cc: Paul Eggert, Adhemerval Zanella, Florian Weimer, GNU C Library,
Andreas Schwab, Stepan Golosunov, Alistair Francis
[-- Attachment #1: Type: text/plain, Size: 2582 bytes --]
Hi Joseph,
> On Tue, 13 Oct 2020, Lukasz Majewski wrote:
>
> > When glibc port with __WORDSIZE==32 and __TIMESIZE!=64 (e.g. armv7)
> > will use redirected calls to {f}stat{at}64_time64 functions, it
> > will accept the struct __stat64_t64 as its argument.
> >
> > To avoid errors related to proper data placement after casting from
> > struct __stat64_t64 to struct stat{64} it is necessary to add some
> > missing padding and update type of {__}st_ino member.
>
> When redirecting to those functions, the definitions of struct stat /
> struct stat64 should automatically change as a result of the
> _TIME_BITS=64 definition so that they match the definitions of the
> __stat64_t64 type - just as _FILE_OFFSET_BITS=64 results in changes
> to the content of struct stat.
Thanks for the explanation. I will adjust exported struct stat{64]
accordingly.
>
> I believe the design is that __stat64_t64 has an
> architecture-independent layout that is never required to match any
> particular kernel layout because translation (typically from statx)
> will always occur in userspace.
>
> Note that struct_stat_time64.h is currently an *uninstalled* header,
> despite the name of the multiple-include guard in the header, and
> despite the testing of feature test macros within the header (which
> only makes sense for installed headers); it's not a bits/ header at
> present.
The only change, that I'm going to do is to mode __ino64_t st_ino
member of struct __stat64_t64
(@ sysdeps/unix/sysv/linux/struct_stat_time64.h) to the end of this
structure (as it is in the exported struct stat{64} placed).
This would allow less #ifndef __USE_TIME_BITS64 in the exported struct
stat{64}.
>
> Maybe there should be some indirection so that the installed version
> of struct_stat_time64.h defines a macro with all the contents of
> __stat64_t64, so that all the many architecture-specific
> bits/struct_stat.h headers can just use that macro to get the right
> contents when _TIME_BITS=64 rather than needing to duplicate the
> structure contents (at least twice per header, for both stat and
> stat64). But I don't think any change to the layout of __stat64_t64
> is indicated, because there should always be explicit conversions
> between different layouts.
>
Best regards,
Lukasz Majewski
--
DENX Software Engineering GmbH, Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-59 Fax: (+49)-8142-66989-80 Email: lukma@denx.de
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 1/2] y2038: Adjust struct __stat64_t64 to be usable by redirected {f}stat{at} calls
2020-10-14 8:47 ` Lukasz Majewski
@ 2020-10-14 13:09 ` Joseph Myers
0 siblings, 0 replies; 6+ messages in thread
From: Joseph Myers @ 2020-10-14 13:09 UTC (permalink / raw)
To: Lukasz Majewski
Cc: Paul Eggert, Adhemerval Zanella, Florian Weimer, GNU C Library,
Andreas Schwab, Stepan Golosunov, Alistair Francis
On Wed, 14 Oct 2020, Lukasz Majewski wrote:
> The only change, that I'm going to do is to mode __ino64_t st_ino
> member of struct __stat64_t64
> (@ sysdeps/unix/sysv/linux/struct_stat_time64.h) to the end of this
> structure (as it is in the exported struct stat{64} placed).
>
> This would allow less #ifndef __USE_TIME_BITS64 in the exported struct
> stat{64}.
I don't think any reordering is needed. I expect each header defining
struct stat / struct stat64 to do something like
#if __GLIBC_USE (TIME_BITS64)
__STAT64_T64_CONTENT
#else
/* existing struct contents */
#endif
so just one #if in each such struct definition (given that you define
__STAT64_T64_CONTENT in some installed bits/ header to avoid duplication).
--
Joseph S. Myers
joseph@codesourcery.com
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2020-10-14 20:54 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-13 13:16 [PATCH 1/2] y2038: Adjust struct __stat64_t64 to be usable by redirected {f}stat{at} calls Lukasz Majewski
2020-10-13 13:16 ` [PATCH 2/2] y2038: Remove not used __fstatat_time64 define Lukasz Majewski
2020-10-13 13:31 ` Andreas Schwab
2020-10-13 22:17 ` [PATCH 1/2] y2038: Adjust struct __stat64_t64 to be usable by redirected {f}stat{at} calls Joseph Myers
2020-10-14 8:47 ` Lukasz Majewski
2020-10-14 13:09 ` Joseph Myers
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).