From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-qk1-x731.google.com (mail-qk1-x731.google.com [IPv6:2607:f8b0:4864:20::731]) by sourceware.org (Postfix) with ESMTPS id ECC6C3857C7F for ; Fri, 19 Mar 2021 18:38:40 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org ECC6C3857C7F Received: by mail-qk1-x731.google.com with SMTP id q3so3965766qkq.12 for ; Fri, 19 Mar 2021 11:38:40 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:to:cc:references:from:subject:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=6AxAWu5m6TEzJqGFnUvmvuO5zBczpyZuYH00meMyH3A=; b=ITzVGoi/fM4Xqu5x9SBWojBKKde9uHEc4U0Auf6oItjOeTnPVQfknjHz9GWmwJDrdG F0+VvMat72gAQjtYgNxjro8lmxzWIjSjcyKhAQkVfLmE7aX2gpgsqo3G0LCY8XPwETBN 6ZVmZfMh/uLwFK2s8iCKJb0wcGKPR7yIdgxrqLZ3RD6K6yVLhH0UBZ3HKWksrmkTo4mU UPFsxcW7jRCyM4llfkiIHZYZwB2VaN9nkPWjwma+w1SgmtozrB8W2P/V0AqXCiMq1kV5 WpsU7MWxksQWxsOT9ZHA2IKh7fmezHzwwo6qSVXEzmlK8+ls60eWqhc4fO8sVfFksV6E DeNw== X-Gm-Message-State: AOAM530UCFvy6WLRRQu6zlU4FWBeUbRUahVf8fpzVt+Uq7dTTsXPJJNs NADjNkYv8A/UMbMamzCs3qb+wg== X-Google-Smtp-Source: ABdhPJw9q7VKfwkZWBnmcXovywredTknrnqn2k0lzQjlDlaOB4kwLv+Yj2U+1gG6dhYm4KJArT36Dg== X-Received: by 2002:a05:620a:12ae:: with SMTP id x14mr10939345qki.25.1616179120481; Fri, 19 Mar 2021 11:38:40 -0700 (PDT) Received: from [192.168.1.4] ([177.194.48.209]) by smtp.googlemail.com with ESMTPSA id j6sm4089678qtx.14.2021.03.19.11.38.38 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 19 Mar 2021 11:38:40 -0700 (PDT) To: YunQiang Su , libc-alpha@sourceware.org Cc: aurelien@aurel32.net, jiaxun.yang@flygoat.com, macro@orcam.me.uk, syq@debian.org References: <20210319011837.3883510-1-yunqiang.su@cipunited.com> From: Adhemerval Zanella Subject: Re: [PATCH v2 1/2] fstatat64: use statx on kernel using uint32 for time Message-ID: Date: Fri, 19 Mar 2021 15:38:37 -0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.7.1 MIME-Version: 1.0 In-Reply-To: <20210319011837.3883510-1-yunqiang.su@cipunited.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-13.4 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, NICE_REPLY_A, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, 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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 19 Mar 2021 18:38:42 -0000 On 18/03/2021 22:18, YunQiang Su wrote: > diff --git a/sysdeps/unix/sysv/linux/fstatat.c b/sysdeps/unix/sysv/linux/fstatat.c > index 59efff615f..ccb6027b64 100644 > --- a/sysdeps/unix/sysv/linux/fstatat.c > +++ b/sysdeps/unix/sysv/linux/fstatat.c > @@ -37,7 +37,12 @@ __fstatat (int fd, const char *file, struct stat *buf, int flag) > || buf->__st_blocks_pad != 0)) > return INLINE_SYSCALL_ERROR_RETURN_VALUE (EOVERFLOW); > # else > -# ifdef __NR_fstatat64 > +# if defined(STAT_KERNEL64_TIME32_T) > + /* Some architecture, like MIPS N64, is 64bit, while its kernel_stat has 32bit timespec. > + Since they are 64bit, and time_t is also 64bit, it is safe for this cast */ > + return __fstatat64_time64(fd, file, (struct __stat64_t64 *)buf, flag); > +# endif I am not very found of this aliasing violation, specially because my refactor tried exactly to avoid it on the newer implementations (only the old xstat does require them because of the way the compat is implemented). > diff --git a/sysdeps/unix/sysv/linux/statx_cp.h b/sysdeps/unix/sysv/linux/statx_cp.h > index 634330aaa6..cc1ae4698d 100644 > --- a/sysdeps/unix/sysv/linux/statx_cp.h > +++ b/sysdeps/unix/sysv/linux/statx_cp.h > @@ -18,6 +18,10 @@ > > extern void __cp_stat64_statx (struct stat64 *to, struct statx *from) > attribute_hidden; > +#if defined(STAT_KERNEL64_TIME32_T) > +# define __cp_stat64_t64_statx __cp_stat64_statx > +#else > extern void __cp_stat64_t64_statx (struct __stat64_t64 *to, > const struct statx *from) > attribute_hidden; > +#endif Instead of adding this hack, it is better to just open code the __cp_stat64_t64_statx (it is used solely on fstatat64). > diff --git a/sysdeps/unix/sysv/linux/tst-futimens.c b/sysdeps/unix/sysv/linux/tst-futimens.c > index 785cd87557..67a411db74 100644 > --- a/sysdeps/unix/sysv/linux/tst-futimens.c > +++ b/sysdeps/unix/sysv/linux/tst-futimens.c > @@ -37,6 +37,9 @@ const struct timespec t2[2] = { { 0x80000001ULL, 0 }, { 0x80000002ULL, 0 } }; > /* struct timespec array around Y2038 threshold. */ > const struct timespec t3[2] = { { 0x7FFFFFFE, 0 }, { 0x80000002ULL, 0 } }; > > +/* struct timespec array around -1: may trigger Y2106 problem */ > +const struct timespec t4[2] = { { -1, 0 }, { -2, 0 } }; > + > #define PREPARE do_prepare > static void > do_prepare (int argc, char *argv[]) > @@ -83,6 +86,7 @@ do_test (void) > test_futimens_helper (&t1[0]); > test_futimens_helper (&t2[0]); > test_futimens_helper (&t3[0]); > + test_futimens_helper (&t4[0]); > > return 0; > } This test will fail on MIPSn64 kernels older than 4.11. I have sent a more complete fix, that also fixes the s390 issue regarding missing nanoseconds and improves the tests to handle the y2106 issue as well [1]. [1] https://patchwork.sourceware.org/project/glibc/list/?series=1878