[PATCH] support: Use __utimensat64 to set file access and modification times
Lukasz Majewski
lukma@denx.de
Wed Mar 17 22:32:55 GMT 2021
Hi Adhemerval,
> On 17/03/2021 15:05, Florian Weimer wrote:
> > * Lukasz Majewski:
> >
> >> @@ -49,8 +38,9 @@ support_path_support_time64 (const char *path)
> >> { 0x80000001ULL, 0 },
> >> { 0x80000002ULL, 0 }
> >> };
> >> - /* Return is kernel does not support __NR_utimensat_time64. */
> >> - if (utimesat_call (path, tsp) == -1)
> >> +
> >> + /* Return if kernel does not support __NR_utimensat_time64. */
> >> + if (__utimensat64 (AT_FDCWD, path, &tsp[0], 0) == -1)
> >> return false;
> >>
> >> /* Verify if the last access and last modification time match
> >> the ones @@ -67,7 +57,7 @@ support_path_support_time64 (const char
> >> *path) { ostx.stx_atime.tv_sec, ostx.stx_atime.tv_nsec },
> >> { ostx.stx_mtime.tv_sec, ostx.stx_mtime.tv_nsec },
> >> };
> >> - TEST_VERIFY_EXIT (utimesat_call (path, otsp) == 0);
> >> + TEST_VERIFY_EXIT (__utimensat64 (AT_FDCWD, path, &otsp[0], 0)
> >> == 0);
> >> return support;
> >> #else
> >
> > I don't see how this can work given that __utimensat64 is currently
> > a symbol exported from libc.so.6. Doesn't this result in link
> > failures on, say, i386?
>
> It does not, it either fail with an invalid linking for legacy ABIs:
>
> /libsupport_nonshared.a(support_path_support_time64.oS): in function
> `support_path_support_time64':
> /home/azanella/glibc/glibc-git/support/support_path_support_time64.c:43:
> undefined reference to `__utimensat64'
> /home/azanella/toolchain/install/compilers/arm-linux-gnueabihf/lib/gcc/arm-glibc-linux-gnueabihf/10.2.1/../../../../arm-glibc-linux-gnueabihf/bin/ld:
> /home/azanella/glibc/glibc-git/support/support_path_su
> pport_time64.c:60: undefined reference to `__utimensat64'
>
> Or with the following for abi with default 64 bit support:
>
> In file included from ../sysdeps/generic/hp-timing.h:23,
> from ../nptl/descr.h:27,
> from ../sysdeps/aarch64/nptl/tls.h:44,
> from ../sysdeps/unix/sysv/linux/aarch64/sysdep.h:29,
> from support_path_support_time64.c:24:
> support_path_support_time64.c: In function
> ‘support_path_support_time64’: ../include/time.h:180:24: error:
> implicit declaration of function ‘__utimensat’; did you mean
> ‘utimensat’? [-Werror=implicit-function-declaration] 180 | # define
> __utimensat64 __utimensat | ^~~~~~~~~~~
> support_path_support_time64.c:43:7: note: in expansion of macro
> ‘__utimensat64’ 43 | if (__utimensat64 (AT_FDCWD, path, &tsp[0], 0)
> == -1)
>
>
> I will commit the following fix:
>
> diff --git a/support/support_path_support_time64.c
> b/support/support_path_support_time64.c index 74af7d4973..452fedcde5
> 100644 --- a/support/support_path_support_time64.c
> +++ b/support/support_path_support_time64.c
> @@ -31,7 +31,7 @@ utimesat_call (const char *path, const struct
> __timespec64 tsp[2]) # ifndef __NR_utimensat_time64
> # define __NR_utimensat_time64 __NR_utimensat
> # endif
> - return INLINE_SYSCALL_CALL (utimensat_time64, AT_FDCWD, path,
> &tsp[0], 0);
> + return syscall (__NR_utimensat_time64, AT_FDCWD, path, &tsp[0], 0);
> }
> #endif
>
I've checked it with ARM 32 bit. It works without issues. Thanks for
providing this proper fix.
Tested-by: Lukasz Majewski <lukma@denx.de>
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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 488 bytes
Desc: OpenPGP digital signature
URL: <https://sourceware.org/pipermail/libc-alpha/attachments/20210317/c5def590/attachment.sig>
More information about the Libc-alpha
mailing list