Message ID | 20210317153810.12070-1-lukma@denx.de |
---|---|
State | Superseded |
Headers |
Return-Path: <libc-alpha-bounces@sourceware.org> X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 8C65C384B0C0; Wed, 17 Mar 2021 15:38:27 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-out.m-online.net (mail-out.m-online.net [IPv6:2001:a60:0:28:0:1:25:1]) by sourceware.org (Postfix) with ESMTPS id 79671385481A for <libc-alpha@sourceware.org>; Wed, 17 Mar 2021 15:38:25 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 79671385481A Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=denx.de Authentication-Results: sourceware.org; spf=none smtp.mailfrom=lukma@denx.de Received: from frontend01.mail.m-online.net (unknown [192.168.8.182]) by mail-out.m-online.net (Postfix) with ESMTP id 4F0vSZ6KvDz1ryX8; Wed, 17 Mar 2021 16:38:22 +0100 (CET) Received: from localhost (dynscan1.mnet-online.de [192.168.6.70]) by mail.m-online.net (Postfix) with ESMTP id 4F0vSZ5Nx4z1r1M6; Wed, 17 Mar 2021 16:38:22 +0100 (CET) X-Virus-Scanned: amavisd-new at mnet-online.de Received: from mail.mnet-online.de ([192.168.8.182]) by localhost (dynscan1.mail.m-online.net [192.168.6.70]) (amavisd-new, port 10024) with ESMTP id rjFZ2BuHBRUa; Wed, 17 Mar 2021 16:38:21 +0100 (CET) X-Auth-Info: 344T636WdpymRfZJaYEFczWHjq9mrMlUUAi15mFG9Ic= Received: from localhost.localdomain (85-222-111-42.dynamic.chello.pl [85.222.111.42]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.mnet-online.de (Postfix) with ESMTPSA; Wed, 17 Mar 2021 16:38:21 +0100 (CET) From: Lukasz Majewski <lukma@denx.de> To: Joseph Myers <joseph@codesourcery.com>, Adhemerval Zanella <adhemerval.zanella@linaro.org> Subject: [PATCH] support: Use __utimensat64 to set file access and modification times Date: Wed, 17 Mar 2021 16:38:10 +0100 Message-Id: <20210317153810.12070-1-lukma@denx.de> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-14.7 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, KAM_LAZY_DOMAIN_SECURITY, RCVD_IN_BARRACUDACENTRAL, RCVD_IN_DNSWL_LOW, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list <libc-alpha.sourceware.org> List-Unsubscribe: <https://sourceware.org/mailman/options/libc-alpha>, <mailto:libc-alpha-request@sourceware.org?subject=unsubscribe> List-Archive: <https://sourceware.org/pipermail/libc-alpha/> List-Post: <mailto:libc-alpha@sourceware.org> List-Help: <mailto:libc-alpha-request@sourceware.org?subject=help> List-Subscribe: <https://sourceware.org/mailman/listinfo/libc-alpha>, <mailto:libc-alpha-request@sourceware.org?subject=subscribe> Cc: Florian Weimer <fweimer@redhat.com>, GNU C Library <libc-alpha@sourceware.org> Errors-To: libc-alpha-bounces@sourceware.org Sender: "Libc-alpha" <libc-alpha-bounces@sourceware.org> |
Series |
support: Use __utimensat64 to set file access and modification times
|
|
Commit Message
Lukasz Majewski
March 17, 2021, 3:38 p.m. UTC
Before this patch the ARM port required the __libc_do_syscall function to be able to call utimensat_time64 syscall required to check if file system supports 64 bit time. This patch fixes the following error on ARM 32 bit port: y2038-glibc/support/support_path_support_time64.c:34: undefined reference to `__libc_do_syscall' collect2: error: ld returned 1 exit status As it now calls the __utimensat64 glibc exported function, which supports 64 bit time. --- support/support_path_support_time64.c | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-)
Comments
* 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? Thanks, Florian
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
* Adhemerval Zanella: > 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 > Thanks, that looks okay to me. Florian
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
diff --git a/support/support_path_support_time64.c b/support/support_path_support_time64.c index 74af7d4973..e42350fa43 100644 --- a/support/support_path_support_time64.c +++ b/support/support_path_support_time64.c @@ -24,17 +24,6 @@ #include <sysdep.h> #endif -#ifdef __linux__ -static int -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); -} -#endif - bool support_path_support_time64 (const char *path) { @@ -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