Should legacy fstat (via __fxstat) and fstat@GLIBC_2.33 call the same syscall?
Adhemerval Zanella
adhemerval.zanella@linaro.org
Thu Jan 14 17:46:07 GMT 2021
On 14/01/2021 14:18, Florian Weimer wrote:
> * Adhemerval Zanella:
>
>> This is a spreadsheet with various supported architectures for the xstat
>> implementation prior the consolidation and the requirements for each
>> syscall and/or transformation required [1].
>
> [1] https://docs.google.com/spreadsheets/d/e/2PACX-1vRG3-1W8roNgHXVaY8zqIBlGqCRtztdyDUvS_VLLkCnmXANYTmZZvONda6TAKcNSNsqfswMn1_IadE5/pubhtml
>
>> It is quite a mess and that's why I think making only fstatat64 the one
>> with the syscall logic does simplify a lot.
>
> I still don't get why this wouldn't be a desirable change:
>
> --- a/sysdeps/unix/sysv/linux/fxstat.c
> +++ b/sysdeps/unix/sysv/linux/fxstat.c
> @@ -35,18 +35,7 @@ __fxstat (int vers, int fd, struct stat *buf)
> switch (vers)
> {
> case _STAT_VER_KERNEL:
> - {
> -# if STAT_IS_KERNEL_STAT
> - /* New kABIs which uses generic pre 64-bit time Linux ABI,
> - e.g. csky, nios2 */
> - int r = INLINE_SYSCALL_CALL (fstat64, fd, buf);
> - return r ?: stat_overflow (buf);
> -# else
> - /* Old kABIs with old non-LFS support, e.g. arm, i386, hppa, m68k,
> - microblaze, s390, sh, powerpc, and sparc. */
> - return INLINE_SYSCALL_CALL (fstat, fd, buf);
> -# endif
> - }
> + return fstat (fd, buf);
>
> default:
> {
Ah you meant to implement the xstat on top of the fstat. I understood
the other way around, implementing the multiple xstat logic on stat
calls.
I think it should be feasible, I haven't done it because I would like
to touch the compatibility as little as possible to avoid further
breakage.
We will need to handle the various vers though (the comment on xstat
is not really in the correct place, ar, i386, etc sets defaults
version to _STAT_VER_LINUX:
int
__xstat (int vers, const char *name, struct stat *buf)
{
switch (vers)
{
case _STAT_VER_KERNEL:
{
# if STAT_IS_KERNEL_STAT
return __fstat (name, buf);
# else
return INLINE_SYSCALL_CALL (stat, name, buf);
# endif
}
/* _STAT_VER_LINUX */
default:
{
# if STAT_IS_KERNEL_STAT
return INLINE_SYSCALL_ERROR_RETURN_VALUE (EINVAL);
# else
/* Old kABIs with old non-LFS support, e.g. arm, i386, hppa,
m68k, microblaze, s390, sh, powerpc, and sparc32. */
return __fstat (name, buf);
#endif
}
}
}
More information about the Libc-alpha
mailing list