From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from APC01-SG2-obe.outbound.protection.outlook.com (mail-eopbgr1310091.outbound.protection.outlook.com [40.107.131.91]) by sourceware.org (Postfix) with ESMTPS id 5FC053857829 for ; Thu, 18 Mar 2021 06:06:13 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 5FC053857829 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=cipunited.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=yunqiang.su@cipunited.com ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=dVKKcuzS0sUHEO7qIcenboKDf9XdMWSlHUBdTz/g2JjhA7sBJNtGVrdHo2nQyBL2bD2DEd3wxt/5Ff8CWZeCFJzhe7OzOiwCPl4iMTvXYjGZjJOFwypcWaSAGHHLqZE0ITuGeE9EC5Dh7xr61F3ugDdSTiJ2A5gxWl3AKVjkhgIlJufP7Q0RDneW9kH+zXYe0phCB0qHcdJMEw/dHWosUKb80btd69sxpAuVj8um5X8EwbyeYY8urweY7Gk4M16GknxnQp+lGXxRUZ+IYx9spefVQGAXjBmXOX2b/CoJ7g74ECQVtVcAUXHCk4FM2oGodmpHuuNLDht0aLx1WtWdWA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=/eDWIR5d00gWQTmO3yaihGCFzSPGOh9LQ2ZpAH9mHZo=; b=L0gojfRajkIofOzirfHwgn8lja21ejHNHqGCjQzG7k+sxh1Zd7G7VB11zOc8W8Md75z1uE30SBogA/ZJennt/IGuzrR9UIzilwglW7DKt1SxxV4pc9o26cnloChi9jehSgu+6OSCAW0ln6LFP+FEKOPS74uSqwXZ2LTXp8JvGPuI9CyxcCz4QXOalC+36uI04MNAo0K5rOmZ1gtRMnZaHcjuW0LpDy8mGB2bOkorwR1El/pjiFGVtVTF+GGRUyS9YAq1EOVlD+GOw8xU+zSChBfgk2m1aQuMZJTYpTD6J+iuIwdeH+JRkR005QlVM5Dx5rboXDCEyJe+knQ9sIQELQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=cipunited.com; dmarc=pass action=none header.from=cipunited.com; dkim=pass header.d=cipunited.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cipunited.onmicrosoft.com; s=selector1-cipunited-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=/eDWIR5d00gWQTmO3yaihGCFzSPGOh9LQ2ZpAH9mHZo=; b=jMNRFwSRbCpgc8Fq+6gW8pTUynG2Xlax1hRHhAOCfHPqzQROWV6xwJlJc77BLHNt3eYDDeBIiT+vdEbXZ+1744FUCoEBNQ2TSS2cfpTSna5FQMKqjC/itIF8OrsT5rsvd4ISxfLLo+P2hLchSz8zHav1GlAu13GeIMIakbQvCvs= Authentication-Results: linaro.org; dkim=none (message not signed) header.d=none;linaro.org; dmarc=none action=none header.from=cipunited.com; Received: from HKAPR04MB3956.apcprd04.prod.outlook.com (2603:1096:203:d5::13) by HK2PR04MB3681.apcprd04.prod.outlook.com (2603:1096:202:2f::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3955.18; Thu, 18 Mar 2021 06:05:57 +0000 Received: from HKAPR04MB3956.apcprd04.prod.outlook.com ([fe80::152f:4f26:f6d1:2d6f]) by HKAPR04MB3956.apcprd04.prod.outlook.com ([fe80::152f:4f26:f6d1:2d6f%3]) with mapi id 15.20.3955.018; Thu, 18 Mar 2021 06:05:57 +0000 From: To: "'Adhemerval Zanella'" , Cc: , , References: <20210312034920.14846-1-yunqiang.su@cipunited.com> <000201d71afe$c7a36ab0$56ea4010$@cipunited.com> In-Reply-To: Subject: =?utf-8?Q?=E5=9B=9E=E5=A4=8D:_=E5=9B=9E=E5=A4=8D:_=5BPATCH=5D_MIPS:_fix_y?= =?utf-8?Q?2106_problem_on_N64_with_statx?= Date: Thu, 18 Mar 2021 14:05:53 +0800 Message-ID: <000401d71bbc$c30ba1c0$4922e540$@cipunited.com> Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Mailer: Microsoft Outlook 16.0 Thread-Index: AQFKESPUEO9BMpN3bmV+ElygrTxgKgG1RfamAaVGeY4B/Imibat4naLw Content-Language: zh-cn X-Originating-IP: [103.125.232.133] X-ClientProxiedBy: HK2PR04CA0047.apcprd04.prod.outlook.com (2603:1096:202:14::15) To HKAPR04MB3956.apcprd04.prod.outlook.com (2603:1096:203:d5::13) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from PCYSU01 (103.125.232.133) by HK2PR04CA0047.apcprd04.prod.outlook.com (2603:1096:202:14::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3955.18 via Frontend Transport; Thu, 18 Mar 2021 06:05:56 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: f9b20299-5a3f-4d5a-24c6-08d8e9d3e588 X-MS-TrafficTypeDiagnostic: HK2PR04MB3681: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:8273; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: lPUIeQXOyrjGPA06fwT9MZbGunRlD4yYBWlr8H+jwsMMELC4IHo8gzKa0+vwv+bcxWIfjpMPR6igFIaUesxWrX5rgo8YXIGtJWXHYddxJNA0LdAyds8QNdRc3Xh5UTMooPf3NxyqkR34Q2pAufsnQf7cQrYRVHF8toB5qoQ+u9BqzfvXoo4hQoy3tJlW8YmK6yrmloGCfOTkw5u21QW1blMQXXKq1dXgWgAh0mi85xaCVSC/zu7ZpMqk0ZLrVvkH4NxeJq9A8np8d05NV2tnUdJMDVl205x/inlWICqC0KMc3I3+PDMsEBCQWfXiVjh8Ou941ig+EQzBpPp5xsAe5HA3avzpGRWviC1/5kFbohdpYa+6Vuv8OjxM4f+v9iAf6kU9JHXgiWfp9DUMiAAA3Uta2T2aGGedpsCC5mJmm5vsFe8ffmy3qFrh71e1T0f13JPw7n9hmcmHhgxY7nJ6el+Yk1zOyryy8+tokWbhQFNqTTxXWlxJ02MWt6+ZcgF/sFZWr3bTaJrxxd1uGlHqTWaj8D2GIqO477bXRkDw9V5veWor7IxEGk50jzX8EfEsPYJr2Ubfnr1Y+DYDJXchr7z+lNDjH6+5Jz+/pxBQIFYZPCLcyvZAxiYgndHFGHzhQUM9zknYt8/VdRP21G4uGZduY637HuXIzCYDYaQrnvidee1j8f8OS1dHivrgZ0ryXal1IDBC/3IxqcnBmwpNHg== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:HKAPR04MB3956.apcprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(366004)(39830400003)(376002)(346002)(396003)(136003)(54906003)(6486002)(36756003)(26005)(83380400001)(478600001)(2876002)(956004)(4326008)(38100700001)(2906002)(316002)(53546011)(66556008)(66476007)(966005)(224303003)(6666004)(5660300002)(30864003)(86362001)(6496006)(110136005)(66946007)(2616005)(16526019)(52116002)(8936002)(44736005)(186003)(1420700001)(2004002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: =?utf-8?B?aUF1VmFiWTdpTG5lb2dIN1QveGRNNnVZakw5c0VFdzNXcDVhT2g2QzJXSWNM?= =?utf-8?B?c2hjdFoybE4wQm1HS0RMSUptaHpaWWNnSE5zTXpiTG9yZk1ZVlRJZmk0a0N0?= =?utf-8?B?WTd5Zjd1akZWM294M1hrWWpKb01FSzV3NSszK1h1U1YzeXczUW9mRjBXL2xp?= =?utf-8?B?Ty9xUVFnd2I3bTF2QWFoM0huOG1QZWRQYXkrQm92K2c4TzlVVGw0MjFMTDZH?= =?utf-8?B?UlpwZEhDcW5hTU5jNzhqWXhSM2tzU25yOW51UzlBZElRYlJLOC9vbEREL2Yx?= =?utf-8?B?VEY1QVFQRkZ0VDlTM2JnMGI4MUxhQ2tsUzl4Si95UzEwRTkrcC9YaktRdnlh?= =?utf-8?B?Nzcrb2xXajhGdE5PVGNJNkVvc1ZzUlNWZGt6MEh1UUIzOWRrL0tNVmJhNDJp?= =?utf-8?B?U3YvcGVoaTlDSkhDRUJuSHFOQms2UnV5OHpGd24waVo5bU5YdXEvU1ZjbkVR?= =?utf-8?B?eWoxNm40UVdXZkdZOHI5UjA0RlEwY05xWjd3NWRSL3ZneWVielpON1YrQ3VS?= =?utf-8?B?R1YvQkN4TC9aR094d09xUDV4MUdmT3pER205T2ZBTlo1WU9PZ2tBZTJPWjV5?= =?utf-8?B?Q2FjNmFYb3FHeG1DNzl3SjI0cmxuTzRZVEU0QVhURjNmZ0tNR2M1cnJFdmRF?= =?utf-8?B?b3VFT1pDQUFLSm1Vemg3VkJLUjRwYVJyWE9MKzdUN2NXL3RZQkw5MUx5UmNv?= =?utf-8?B?RHZtbHpYUGxrK3EwcUhzeFlIenF6Z1RzdmJwMTVSNWNyUStFU2VmLzBqMVpp?= =?utf-8?B?UU5BckZyL3hPYzFBOVd3YWxmZG9OM0xVOVJadE5tZUpNUVBuK1hnSnh3R0FL?= =?utf-8?B?b0dXN0FUdEQxUjltUzlmRWpIQW9HczBJTk9FckJqMVc2UU9kc3dGT21VdFUy?= =?utf-8?B?Tm0zdUpKVzFIc2p3OGtQQ09sWW11eldwRGViN1gxb25MMXBZYzVMK0VtTlJY?= =?utf-8?B?dlFIYUtSdThhUWhZNFNQZlRCbkxsbFdaY0lhWk5UWS96TTNzaW9LTys0REhx?= =?utf-8?B?bkp6a1FueFp2Rk5XcGNkQzdTOVJlS0VDaWxsTk15ZTlOKzJSTlowR2NOQkFi?= =?utf-8?B?d05oeEdEWjJXTVkzeGRlMFBUSkxIcGhMSmtlcmZqRnUzZjcxOUVoODRwZ1Fa?= =?utf-8?B?d3JnY29ZazVTQ2dTL1cveFhPaFEvdUF1cVJOVGdFL1NrVG9IaUo1ck1NcDFL?= =?utf-8?B?N3pwQ1J2N1hIcGtZeHdLYmtMMklvaW0rVS80b3BUcWFmK2o5OVQ5bWJVMUdk?= =?utf-8?B?elk4cjhiL3UrMlNueGExVUdCU3VwdnZxaVp5dHExM1FJcC9WY2NIbk5vcUxN?= =?utf-8?B?OFBlMENlZXpkekRXYlRORmFhdFdGQWl6RHpRM2hOQUpyZ2tUbWk2UURLa0Ix?= =?utf-8?B?MnRXbzlMQmg3bGNMMzQwUG1XTFo0Y1FnSkR6OThWR0JydVFKYkhZT2JnV294?= =?utf-8?B?Zk52bCtEcE51MDlNY2hQQVJSdkhiRU5yamdvS2VWdk13ZXRWRWZKQWw1ZGd3?= =?utf-8?B?eHdIOFV3Q0ZSblBsUWVxdHJsenM1V1duRy9sQTQ2cUl1WkVmMTBnaERBVXpn?= =?utf-8?B?MmYwbXhWUmVuRTRrUzQ0YVJZUllKVCtnaDZZckg3WTBmb3A2V3BpeWNhaGEv?= =?utf-8?B?NmtheUJ4ZnJyOGRNWkdLbTZSRTNXaFVTUlZkS1hROEI4TGxiYTRQVWx2SWs3?= =?utf-8?B?TnRiWHpuVjNUd2pjU0ZQL0lYQVM5enZJeE5FQlp3MU5wcldEWEZnc0laM1Zw?= =?utf-8?Q?CPpZpquOyv9p7/SeM5RaAAMjcWC7IP+T7SRoB+A?= X-OriginatorOrg: cipunited.com X-MS-Exchange-CrossTenant-Network-Message-Id: f9b20299-5a3f-4d5a-24c6-08d8e9d3e588 X-MS-Exchange-CrossTenant-AuthSource: HKAPR04MB3956.apcprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Mar 2021 06:05:57.5263 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: e31cf5b5-ee69-4d5f-9c69-edeeda2458c0 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: Jhnm9PIQYu28jTbiNdB3/XB+dGdced3w295hGX5RbA0Xb1cH88VwruAGLfpsTN31IqgDEyMJaDh+uKlgm60ZCPbDGDwFsvsJ9Bc4R/iJVM4= X-MS-Exchange-Transport-CrossTenantHeadersStamped: HK2PR04MB3681 X-Spam-Status: No, score=-8.4 required=5.0 tests=BAYES_00, BODY_8BITS, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, KAM_SHORT, MSGID_FROM_MTA_HEADER, RCVD_IN_ABUSEAT, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2, RCVD_IN_SBL_CSS, SPF_HELO_PASS, 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: Thu, 18 Mar 2021 06:06:19 -0000 > -----=E9=82=AE=E4=BB=B6=E5=8E=9F=E4=BB=B6----- > =E5=8F=91=E4=BB=B6=E4=BA=BA: Adhemerval Zanella > =E5=8F=91=E9=80=81=E6=97=B6=E9=97=B4: 2021=E5=B9=B43=E6=9C=8817=E6=97=A5 = 19:27 > =E6=94=B6=E4=BB=B6=E4=BA=BA: yunqiang.su@cipunited.com; libc-alpha@source= ware.org > =E6=8A=84=E9=80=81: aurelien@aurel32.net; jiaxun.yang@flygoat.com; macro@= orcam.me.uk > =E4=B8=BB=E9=A2=98: Re: =E5=9B=9E=E5=A4=8D: [PATCH] MIPS: fix y2106 probl= em on N64 with statx >=20 >=20 >=20 > On 17/03/2021 04:25, yunqiang.su@cipunited.com wrote: > > > > > >> -----=E9=82=AE=E4=BB=B6=E5=8E=9F=E4=BB=B6----- > >> =E5=8F=91=E4=BB=B6=E4=BA=BA: Adhemerval Zanella > >> =E5=8F=91=E9=80=81=E6=97=B6=E9=97=B4: 2021=E5=B9=B43=E6=9C=8812=E6=97= =A5 20:35 > >> =E6=94=B6=E4=BB=B6=E4=BA=BA: YunQiang Su ; > >> libc-alpha@sourceware.org > >> =E6=8A=84=E9=80=81: aurelien@aurel32.net; jiaxun.yang@flygoat.com; > macro@orcam.me.uk > >> =E4=B8=BB=E9=A2=98: Re: [PATCH] MIPS: fix y2106 problem on N64 with st= atx > >> > >> > >> > >> On 12/03/2021 00:49, YunQiang Su wrote: > >>> the stat series syscall of N64 use uint32 as its time. > >>> Glibc converts it to int64 then. For example a file with timestamp -1= : > >>> syscall(stat) gets 0xffffffff > >>> Glibc convert it to 0x00000000ffffffff Then, -1 becomes a time in > >>> y2106. > >> > >> Sigh, another MIPS ABI idissionacracy that I am not aware about... > >> > >>> > >>> In this patch, we use statx syscall to replace stat-series syscall. > >>> statx always return int64 timestamp, and the `struct stat' in > >>> userland of N64 always has 64bit timestamp. We can convert between > >>> them without any problem > >> Some comments below. > >> > >>> --- > >>> io/tst-fstatat.c | 26 +++++++- > >>> sysdeps/unix/sysv/linux/fstatat64.c | 8 ++- > >>> .../unix/sysv/linux/mips/mips64/n64/fstatat.c | 52 +++++++++++++++ > >>> .../unix/sysv/linux/mips/mips64/n64/fxstat.c | 51 +++++++++++++++ > >>> .../sysv/linux/mips/mips64/n64/fxstat64.c | 43 +++++++++++++ > >>> .../sysv/linux/mips/mips64/n64/fxstatat.c | 63 > >> +++++++++++++++++++ > >>> .../sysv/linux/mips/mips64/n64/fxstatat64.c | 53 > ++++++++++++++++ > >>> .../unix/sysv/linux/mips/mips64/n64/lxstat.c | 51 +++++++++++++++ > >>> .../sysv/linux/mips/mips64/n64/lxstat64.c | 43 +++++++++++++ > >>> .../unix/sysv/linux/mips/mips64/n64/xstat.c | 51 +++++++++++++++ > >>> .../unix/sysv/linux/mips/mips64/n64/xstat64.c | 43 +++++++++++++ > >>> 11 files changed, 482 insertions(+), 2 deletions(-) create mode > >>> 100644 sysdeps/unix/sysv/linux/mips/mips64/n64/fstatat.c > >>> create mode 100644 > sysdeps/unix/sysv/linux/mips/mips64/n64/fxstat.c > >>> create mode 100644 > >> sysdeps/unix/sysv/linux/mips/mips64/n64/fxstat64.c > >>> create mode 100644 > >>> sysdeps/unix/sysv/linux/mips/mips64/n64/fxstatat.c > >>> create mode 100644 > >>> sysdeps/unix/sysv/linux/mips/mips64/n64/fxstatat64.c > >>> create mode 100644 > sysdeps/unix/sysv/linux/mips/mips64/n64/lxstat.c > >>> create mode 100644 > >> sysdeps/unix/sysv/linux/mips/mips64/n64/lxstat64.c > >>> create mode 100644 sysdeps/unix/sysv/linux/mips/mips64/n64/xstat.c > >>> create mode 100644 > >>> sysdeps/unix/sysv/linux/mips/mips64/n64/xstat64.c > >>> > >>> diff --git a/io/tst-fstatat.c b/io/tst-fstatat.c index > >>> 4766bb2e71..8297b14479 100644 > >>> --- a/io/tst-fstatat.c > >>> +++ b/io/tst-fstatat.c > >>> @@ -5,7 +5,7 @@ > >>> #include > >>> #include > >>> #include > >>> - > >>> +#include > >>> > >>> static void prepare (void); > >>> #define PREPARE(argc, argv) prepare () @@ -134,6 +134,30 @@ > do_test > >>> (void) > >>> puts ("stat results do not match"); > >>> return 1; > >>> } > >>> +#if defined(__mips64) && (_MIPS_SIM =3D=3D _ABI64) && > >>> +defined(__ASSUME_STATX) > >>> + /* fstatat syscall has y2106 problem on MIPS N64 > >>> + Now we use statx to implement *stat* functions > >>> + So the problem should have gone */ > >>> + struct timespec tm_1[2] =3D {{-1, 0}, {-1, 0}}; > >>> + if (utimensat(dir_fd, "some-file", tm_1, 0) !=3D 0) > >>> + { > >>> + puts ("utimensat fail"); > >>> + return 1; > >>> + } > >>> + > >>> + if (fstatat64 (dir_fd, "some-file", &st2, 0) !=3D 0) > >>> + { > >>> + puts ("fstatat64 failed"); > >>> + return 1; > >>> + } > >>> + > >>> + if (st2.st_mtim.tv_sec !=3D -1 > >>> + || st2.st_atim.tv_sec !=3D -1) > >>> + { > >>> + puts ("fstatat64 has y2106 problem?"); > >>> + return 1; > >>> + } > >>> +#endif > >>> > >>> if (unlinkat (dir_fd, "some-file", 0) !=3D 0) > >>> { > >> > >> I am about to push a way to check in if the file has support for > >> y2038 [1], so please use this instead. Also this tests does not > >> really check any file timestamps so I don't think this is the place > >> add this warning (and making it mips specific it not a good approach, > >> neither by using __ASSUME_STATX which is Linux specific and it should = be > used on internal tests). > >> > >> Instead please add the y2106 checks on Linux specific tests: > >> > >> sysdeps/unix/sysv/linux/tst-futimens.c > >> sysdeps/unix/sysv/linux/tst-utime.c > >> sysdeps/unix/sysv/linux/tst-utimes.c > >> > >> Since they use fstat to check against the set timestamps. > >> > >> [1] > >> > https://patchwork.sourceware.org/project/glibc/patch/20210311123557.3 > >> 48 6677-1-adhemerval.zanella@linaro.org/ > >> > > > > That's a great idea to add the test here. > > > >>> diff --git a/sysdeps/unix/sysv/linux/fstatat64.c > >>> b/sysdeps/unix/sysv/linux/fstatat64.c > >>> index 490226a8ec..220321be9c 100644 > >>> --- a/sysdeps/unix/sysv/linux/fstatat64.c > >>> +++ b/sysdeps/unix/sysv/linux/fstatat64.c > >>> @@ -47,15 +47,21 @@ __fstatat64_time64 (int fd, const char *file, > >>> struct > >> __stat64_t64 *buf, > >>> int r; > >>> > >>> #if (__WORDSIZE =3D=3D 32 \ > >>> - && (!defined __SYSCALL_WORDSIZE || __SYSCALL_WORDSIZE =3D=3D > >> 32)) > >>> + && (!defined __SYSCALL_WORDSIZE || __SYSCALL_WORDSIZE > =3D=3D > >> 32)) \ > >>> + || defined(__mips64) > >> > >> I would prefer to add a define added on kernel_stat.h, even though it > >> seems from a briefly inspecting on kernel sources that it is only > >> mips64 that has this issue. I think we should avoid the preprocessor > >> archirecture define on Linux generic code. > >> > >> So add a STAT_KERNEL_UNSIGNED_TIME_T with a proper comment on > mips.h > >> kernel_stat.h > >> > > > > Yes. It is much cleaner. > > > >>> /* 32-bit kABI with default 64-bit time_t, e.g. arc, riscv32. Al= so > >>> 64-bit time_t support is done through statx syscall. */ > >>> + /* Also use statx syscall for MIPS N64, since newfstatat has > >>> + y2106 problem */ > >>> struct statx tmp; > >> > >> Merge it with the previous comment. > >> > >>> r =3D INTERNAL_SYSCALL_CALL (statx, fd, file, AT_NO_AUTOMOUNT | > >> flag, > >>> STATX_BASIC_STATS, &tmp); > >>> if (r =3D=3D 0) > >>> { > >>> +#if defined(__mips64) && (_MIPS_SIM =3D=3D _ABI64) > >>> + __cp_stat64_statx (buf, &tmp); #else > >>> __cp_stat64_t64_statx (buf, &tmp); > >>> +#endif > >>> return 0; > >>> } > >>> if (-r !=3D ENOSYS) > >>> diff --git a/sysdeps/unix/sysv/linux/mips/mips64/n64/fstatat.c > >>> b/sysdeps/unix/sysv/linux/mips/mips64/n64/fstatat.c > >>> new file mode 100644 > >>> index 0000000000..5000cd0715 > >>> --- /dev/null > >>> +++ b/sysdeps/unix/sysv/linux/mips/mips64/n64/fstatat.c > >>> @@ -0,0 +1,52 @@ > >>> +/* Copyright (C) 2005-2020 Free Software Foundation, Inc. > >>> + This file is part of the GNU C Library. > >>> + > >>> + The GNU C Library is free software; you can redistribute it and/o= r > >>> + modify it under the terms of the GNU Lesser General Public > >>> + License as published by the Free Software Foundation; either > >>> + version 2.1 of the License, or (at your option) any later version= . > >>> + > >>> + The GNU C Library is distributed in the hope that it will be usef= ul, > >>> + but WITHOUT ANY WARRANTY; without even the implied warranty > of > >>> + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See > >> the GNU > >>> + Lesser General Public License for more details. > >>> + > >>> + You should have received a copy of the GNU Lesser General Public > >>> + License along with the GNU C Library; if not, see > >>> + . */ > >>> + > >>> +/* Ho hum, since fxstatat =3D=3D fxstatat64 we must get rid of the > >>> + prototype or gcc will complain since they don't strictly match. > >>> +*/ > >>> + > >>> +#include > >>> +#include > >>> +#if defined(__ASSUME_STATX) && defined(__NR_statx) #include > >>> + #include #include #include > >>> +#include #include > >>> + > >>> +#include > >>> +#include > >>> +#include > >>> + > >>> + > >>> +/* Get information about the file NAME relative to FD in ST. */ > >>> +int __fstatat (int fd, const char *file, struct stat *st, int flag) > >>> +{ > >>> + struct statx xbuf; > >>> + int r =3D INLINE_SYSCALL (statx, 5, fd, file, > flag&AT_SYMLINK_NOFOLLOW, > >>> + STATX_BASIC_STATS, &xbuf); > >>> + if (r =3D=3D 0) > >>> + __cp_stat64_statx((struct stat64 *)st, &xbuf); > >>> + return r; > >>> +} > >>> + > >>> +weak_alias (__fstatat, fstatat) > >>> + > >>> +#else /* __ASSUME_STATX && __NR_statx */ #include > >>> + > >>> +#endif > >> > >> I see no point in such optimization, which adds another mips specific = file. > >> If glibc is still alive near 2106 most likely we would had increases > >> the minimum kernel version to include __NR_statx... > >> > > > > linux/fstatat.c has no statx call. So, should we do the similar like fs= tatat64? >=20 > Even though it is not the default, non LFS interface are legacy ones. > y2038 support, for instance, is only supported with LFS interfaces. >=20 > So it is up to you if you want to fix on fstatat.c, it should also fix th= e s390 issue > with missing nanosecond support. >=20 fstatat is not recommend used by any new write code? All new write code should use fstatat64? > > > >>> diff --git a/sysdeps/unix/sysv/linux/mips/mips64/n64/fxstat.c > >>> b/sysdeps/unix/sysv/linux/mips/mips64/n64/fxstat.c > >>> new file mode 100644 > >>> index 0000000000..acd929dfaa > >>> --- /dev/null > >>> +++ b/sysdeps/unix/sysv/linux/mips/mips64/n64/fxstat.c > >>> @@ -0,0 +1,51 @@ > >>> +/* fxstat using old-style Unix stat system call. > >>> + Copyright (C) 1991-2021 Free Software Foundation, Inc. > >>> + This file is part of the GNU C Library. > >>> + > >>> + The GNU C Library is free software; you can redistribute it and/o= r > >>> + modify it under the terms of the GNU Lesser General Public > >>> + License as published by the Free Software Foundation; either > >>> + version 2.1 of the License, or (at your option) any later version= . > >>> + > >>> + The GNU C Library is distributed in the hope that it will be usef= ul, > >>> + but WITHOUT ANY WARRANTY; without even the implied warranty > of > >>> + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See > >> the GNU > >>> + Lesser General Public License for more details. > >>> + > >>> + You should have received a copy of the GNU Lesser General Public > >>> + License along with the GNU C Library; if not, see > >>> + . */ > >>> + > >>> +#include > >>> +#include > >>> +#if defined(__ASSUME_STATX) && defined(__NR_statx) #include > >>> + #include #include #include > >>> + #include > >>> + > >>> +/* Get information about the file NAME in BUF. */ int __fxstat > >>> +(int vers, int fd, struct stat *buf) { > >>> + switch (vers) > >>> + { > >>> + case _STAT_VER_KERNEL: > >>> + return INLINE_SYSCALL_CALL (fstat, fd, buf); > >>> + > >>> + default: > >>> + { > >>> + struct statx xbuf; > >>> + int r =3D INLINE_SYSCALL (statx, 5, fd, "", AT_EMPTY_PATH, > >>> + STATX_BASIC_STATS, &xbuf); > >>> + if (r =3D=3D 0) > >>> + __cp_stat64_statx((struct stat64 *)buf, &xbuf); > >>> + return r; > >>> + } > >>> + } > >>> +} > >>> + > >>> +#else /* __ASSUME_STATX && __NR_statx */ #include > >>> + > >>> +#endif > >> > >> As for the mips specific implementation, the __fxstat are > >> compatibilty symbols and I don't want us to change their semantic. > >> If user really care about > >> y2106 they should use the newer stat symbols. > >> > > > > While the pre-exists binaries do use __fxstat. > > With this patch, I think that we can make them work correctly with just= libc > upgrade. > > > > With the previous binaries, even they use `stat' in source code, the re= sult > binaries do use __xstat. > > > > And the problem of Y2106 is not only about Y2106, and it also has probl= em > for Y1969. > > It may make some trouble, if we set the timestamp before 1970. >=20 > But is this really an issue for MIPS in a sense legacy programs will be a= ffected > in the referred timeframe? If we limit the fix for newly built binaries i= t > simplifies a lot the code base. >=20 > My xstat refactor work was really to avoid the nasty profileration of > arch-specific implementations and I think we are getting a step back by > adding back this specific fix. >=20 > If you really want to fix on legacy compat implementation, I think it wou= ld be > better to make in arch neutral way: 1. make xstat, lxstat, fxstat call fx= statat, 2. > add statx on fxstatat/fxstatat64, and 3. > convert back the struct to the _STAT_VER. >=20 I will split this patch, then. > > > >>> diff --git a/sysdeps/unix/sysv/linux/mips/mips64/n64/fxstat64.c > >>> b/sysdeps/unix/sysv/linux/mips/mips64/n64/fxstat64.c > >>> new file mode 100644 > >>> index 0000000000..a8da108347 > >>> --- /dev/null > >>> +++ b/sysdeps/unix/sysv/linux/mips/mips64/n64/fxstat64.c > >>> @@ -0,0 +1,43 @@ > >>> +/* fxstat64 using 64-bit MIPS fstat system call. > >>> + Copyright (C) 1997-2020 Free Software Foundation, Inc. > >>> + This file is part of the GNU C Library. > >>> + > >>> + The GNU C Library is free software; you can redistribute it and/o= r > >>> + modify it under the terms of the GNU Lesser General Public > >>> + License as published by the Free Software Foundation; either > >>> + version 2.1 of the License, or (at your option) any later version= . > >>> + > >>> + The GNU C Library is distributed in the hope that it will be usef= ul, > >>> + but WITHOUT ANY WARRANTY; without even the implied warranty > of > >>> + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See > >> the GNU > >>> + Lesser General Public License for more details. > >>> + > >>> + You should have received a copy of the GNU Lesser General Public > >>> + License along with the GNU C Library; if not, see > >>> + . */ > >>> + > >>> +#include > >>> +#include > >>> +#if defined(__ASSUME_STATX) && defined(__NR_statx) #include > >>> + #include #include #include > >>> + #include > >>> + > >>> +/* Get information about the file FD in BUF. */ > >>> + > >>> +int > >>> +__fxstat64 (int vers, int fd, struct stat64 *buf) { > >>> + struct statx xbuf; > >>> + int r =3D INLINE_SYSCALL (statx, 5, fd, "", AT_EMPTY_PATH, > >>> + STATX_BASIC_STATS, &xbuf); > >>> + if (r =3D=3D 0) > >>> + __cp_stat64_statx(buf, &xbuf); > >>> + return r; > >>> +} > >>> + > >>> +#else /* __ASSUME_STATX && __NR_statx */ #include > >>> + > >>> +#endif > >>> diff --git a/sysdeps/unix/sysv/linux/mips/mips64/n64/fxstatat.c > >>> b/sysdeps/unix/sysv/linux/mips/mips64/n64/fxstatat.c > >>> new file mode 100644 > >>> index 0000000000..935888efe6 > >>> --- /dev/null > >>> +++ b/sysdeps/unix/sysv/linux/mips/mips64/n64/fxstatat.c > >>> @@ -0,0 +1,63 @@ > >>> +/* Copyright (C) 2005-2020 Free Software Foundation, Inc. > >>> + This file is part of the GNU C Library. > >>> + > >>> + The GNU C Library is free software; you can redistribute it and/o= r > >>> + modify it under the terms of the GNU Lesser General Public > >>> + License as published by the Free Software Foundation; either > >>> + version 2.1 of the License, or (at your option) any later version= . > >>> + > >>> + The GNU C Library is distributed in the hope that it will be usef= ul, > >>> + but WITHOUT ANY WARRANTY; without even the implied warranty > of > >>> + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See > >> the GNU > >>> + Lesser General Public License for more details. > >>> + > >>> + You should have received a copy of the GNU Lesser General Public > >>> + License along with the GNU C Library; if not, see > >>> + . */ > >>> + > >>> +/* Ho hum, since fxstatat =3D=3D fxstatat64 we must get rid of the > >>> + prototype or gcc will complain since they don't strictly match. > >>> +*/ > >>> + > >>> +#include > >>> +#include > >>> +#if defined(__ASSUME_STATX) && defined(__NR_statx) #include > >>> + #include #include #include > >>> +#include #include > >>> + > >>> +#include > >>> +#include > >>> +#include > >>> + > >>> + > >>> +/* Get information about the file NAME relative to FD in ST. */ > >>> +int __fxstatat (int vers, int fd, const char *file, struct stat > >>> +*st, int > >>> +flag) { > >>> + switch (vers) > >>> + { > >>> + case _STAT_VER_KERNEL: > >>> + return INLINE_SYSCALL (newfstatat, 4, fd, file, st, flag); > >>> + > >>> + case _STAT_VER_LINUX: > >>> + { > >>> + struct statx xbuf; > >>> + int r =3D INLINE_SYSCALL (statx, 5, fd, file, > flag&AT_SYMLINK_NOFOLLOW, > >>> + STATX_BASIC_STATS, &xbuf); > >>> + if (r =3D=3D 0) > >>> + __cp_stat64_statx((struct stat64 *)st, &xbuf); > >>> + return r; > >>> + } > >>> + > >>> + default: > >>> + __set_errno (EINVAL); > >>> + return -1; > >>> + } > >>> +} > >>> + > >>> +#else /* __ASSUME_STATX && __NR_statx */ #include > >>> + > >>> +#endif > >>> diff --git a/sysdeps/unix/sysv/linux/mips/mips64/n64/fxstatat64.c > >>> b/sysdeps/unix/sysv/linux/mips/mips64/n64/fxstatat64.c > >>> new file mode 100644 > >>> index 0000000000..80bd0f1d09 > >>> --- /dev/null > >>> +++ b/sysdeps/unix/sysv/linux/mips/mips64/n64/fxstatat64.c > >>> @@ -0,0 +1,53 @@ > >>> +/* Copyright (C) 2005-2020 Free Software Foundation, Inc. > >>> + This file is part of the GNU C Library. > >>> + > >>> + The GNU C Library is free software; you can redistribute it and/o= r > >>> + modify it under the terms of the GNU Lesser General Public > >>> + License as published by the Free Software Foundation; either > >>> + version 2.1 of the License, or (at your option) any later version= . > >>> + > >>> + The GNU C Library is distributed in the hope that it will be usef= ul, > >>> + but WITHOUT ANY WARRANTY; without even the implied warranty > of > >>> + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See > >> the GNU > >>> + Lesser General Public License for more details. > >>> + > >>> + You should have received a copy of the GNU Lesser General Public > >>> + License along with the GNU C Library. If not, see > >>> + . */ > >>> + > >>> +#include > >>> +#include > >>> +#if defined(__ASSUME_STATX) && defined(__NR_statx) #include > >>> + #include #include #include > >>> +#include #include #include > >>> + > >>> +#include > >>> +#include > >>> + > >>> +/* Get information about the file NAME in BUF. */ > >>> + > >>> +int > >>> +__fxstatat64 (int vers, int fd, const char *file, struct stat64 > >>> +*st, int flag) { > >>> + if (__builtin_expect (vers !=3D _STAT_VER_LINUX, 0)) > >>> + { > >>> + __set_errno (EINVAL); > >>> + return -1; > >>> + } > >>> + > >>> + struct statx xbuf; > >>> + int r =3D INLINE_SYSCALL (statx, 5, fd, file, > flag&AT_SYMLINK_NOFOLLOW, > >>> + STATX_BASIC_STATS, &xbuf); > >>> + if (r =3D=3D 0) > >>> + __cp_stat64_statx(st, &xbuf); > >>> + return r; > >>> +} > >>> + > >>> +#else /* __ASSUME_STATX && __NR_statx */ #include > >>> + > >>> +#endif > >>> diff --git a/sysdeps/unix/sysv/linux/mips/mips64/n64/lxstat.c > >>> b/sysdeps/unix/sysv/linux/mips/mips64/n64/lxstat.c > >>> new file mode 100644 > >>> index 0000000000..f9c28b753b > >>> --- /dev/null > >>> +++ b/sysdeps/unix/sysv/linux/mips/mips64/n64/lxstat.c > >>> @@ -0,0 +1,51 @@ > >>> +/* lxstat using old-style Unix stat system call. > >>> + Copyright (C) 1991-2021 Free Software Foundation, Inc. > >>> + This file is part of the GNU C Library. > >>> + > >>> + The GNU C Library is free software; you can redistribute it and/o= r > >>> + modify it under the terms of the GNU Lesser General Public > >>> + License as published by the Free Software Foundation; either > >>> + version 2.1 of the License, or (at your option) any later version= . > >>> + > >>> + The GNU C Library is distributed in the hope that it will be usef= ul, > >>> + but WITHOUT ANY WARRANTY; without even the implied warranty > of > >>> + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See > >> the GNU > >>> + Lesser General Public License for more details. > >>> + > >>> + You should have received a copy of the GNU Lesser General Public > >>> + License along with the GNU C Library; if not, see > >>> + . */ > >>> + > >>> +#include > >>> +#include > >>> +#if defined(__ASSUME_STATX) && defined(__NR_statx) #include > >>> + #include #include #include > >>> + #include > >>> + > >>> +/* Get information about the file NAME in BUF. */ int __lxstat > >>> +(int vers, const char *name, struct stat *buf) { > >>> + switch (vers) > >>> + { > >>> + case _STAT_VER_KERNEL: > >>> + return INLINE_SYSCALL_CALL (lstat, name, buf); > >>> + > >>> + default: > >>> + { > >>> + struct statx xbuf; > >>> + int r =3D INLINE_SYSCALL (statx, 5, AT_FDCWD, name, > >> AT_SYMLINK_NOFOLLOW, > >>> + STATX_BASIC_STATS, &xbuf); > >>> + if (r =3D=3D 0) > >>> + __cp_stat64_statx((struct stat64 *)buf, &xbuf); > >>> + return r; > >>> + } > >>> + } > >>> +} > >>> + > >>> +#else /* __ASSUME_STATX && __NR_statx */ #include > >>> + > >>> +#endif > >>> diff --git a/sysdeps/unix/sysv/linux/mips/mips64/n64/lxstat64.c > >>> b/sysdeps/unix/sysv/linux/mips/mips64/n64/lxstat64.c > >>> new file mode 100644 > >>> index 0000000000..927c542ca7 > >>> --- /dev/null > >>> +++ b/sysdeps/unix/sysv/linux/mips/mips64/n64/lxstat64.c > >>> @@ -0,0 +1,43 @@ > >>> +/* lxstat64 using 64-bit MIPS lstat system call. > >>> + Copyright (C) 1997-2020 Free Software Foundation, Inc. > >>> + This file is part of the GNU C Library. > >>> + > >>> + The GNU C Library is free software; you can redistribute it and/o= r > >>> + modify it under the terms of the GNU Lesser General Public > >>> + License as published by the Free Software Foundation; either > >>> + version 2.1 of the License, or (at your option) any later version= . > >>> + > >>> + The GNU C Library is distributed in the hope that it will be usef= ul, > >>> + but WITHOUT ANY WARRANTY; without even the implied warranty > of > >>> + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See > >> the GNU > >>> + Lesser General Public License for more details. > >>> + > >>> + You should have received a copy of the GNU Lesser General Public > >>> + License along with the GNU C Library; if not, see > >>> + . */ > >>> + > >>> +#include > >>> +#include > >>> +#if defined(__ASSUME_STATX) && defined(__NR_statx) #include > >>> + #include #include #include > >>> + #include > >>> + > >>> +/* Get information about the file NAME in BUF. */ int > >>> +__lxstat64 (int vers, const char *name, struct stat64 *buf) { > >>> + struct statx xbuf; > >>> + int r =3D INLINE_SYSCALL (statx, 5, AT_FDCWD, name, > >> AT_SYMLINK_NOFOLLOW, > >>> + STATX_BASIC_STATS, &xbuf); > >>> + // cast to struct stat from struct stat64 is OK for N64. > >>> + if (r =3D=3D 0) > >>> + __cp_stat64_statx(buf, &xbuf); > >>> + return r; > >>> +} > >>> + > >>> +#else /* __ASSUME_STATX && __NR_statx */ #include > >>> + > >>> +#endif > >>> diff --git a/sysdeps/unix/sysv/linux/mips/mips64/n64/xstat.c > >>> b/sysdeps/unix/sysv/linux/mips/mips64/n64/xstat.c > >>> new file mode 100644 > >>> index 0000000000..6c735e5365 > >>> --- /dev/null > >>> +++ b/sysdeps/unix/sysv/linux/mips/mips64/n64/xstat.c > >>> @@ -0,0 +1,51 @@ > >>> +/* xstat using old-style Unix stat system call. > >>> + Copyright (C) 1991-2021 Free Software Foundation, Inc. > >>> + This file is part of the GNU C Library. > >>> + > >>> + The GNU C Library is free software; you can redistribute it and/o= r > >>> + modify it under the terms of the GNU Lesser General Public > >>> + License as published by the Free Software Foundation; either > >>> + version 2.1 of the License, or (at your option) any later version= . > >>> + > >>> + The GNU C Library is distributed in the hope that it will be usef= ul, > >>> + but WITHOUT ANY WARRANTY; without even the implied warranty > of > >>> + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See > >> the GNU > >>> + Lesser General Public License for more details. > >>> + > >>> + You should have received a copy of the GNU Lesser General Public > >>> + License along with the GNU C Library; if not, see > >>> + . */ > >>> + > >>> +#include > >>> +#include > >>> +#if defined(__ASSUME_STATX) && defined(__NR_statx) #include > >>> + #include #include #include > >>> + #include > >>> + > >>> +/* Get information about the file NAME in BUF. */ int __xstat (int > >>> +vers, const char *name, struct stat *buf) { > >>> + switch (vers) > >>> + { > >>> + case _STAT_VER_KERNEL: > >>> + return INLINE_SYSCALL_CALL (stat, name, buf); > >>> + > >>> + default: > >>> + { > >>> + struct statx xbuf; > >>> + int r =3D INLINE_SYSCALL (statx, 5, AT_FDCWD, name, 0, > >>> + STATX_BASIC_STATS, &xbuf); > >>> + if (r =3D=3D 0) > >>> + __cp_stat64_statx((struct stat64 *)buf, &xbuf); > >>> + return r; > >>> + } > >>> + } > >>> +} > >>> + > >>> +#else /* __ASSUME_STATX && __NR_statx */ #include > >>> + > >>> +#endif > >>> diff --git a/sysdeps/unix/sysv/linux/mips/mips64/n64/xstat64.c > >>> b/sysdeps/unix/sysv/linux/mips/mips64/n64/xstat64.c > >>> new file mode 100644 > >>> index 0000000000..84db1b7a85 > >>> --- /dev/null > >>> +++ b/sysdeps/unix/sysv/linux/mips/mips64/n64/xstat64.c > >>> @@ -0,0 +1,43 @@ > >>> +/* xstat64 using 64-bit MIPS stat system call. > >>> + Copyright (C) 1991-2020 Free Software Foundation, Inc. > >>> + This file is part of the GNU C Library. > >>> + > >>> + The GNU C Library is free software; you can redistribute it and/o= r > >>> + modify it under the terms of the GNU Lesser General Public > >>> + License as published by the Free Software Foundation; either > >>> + version 2.1 of the License, or (at your option) any later version= . > >>> + > >>> + The GNU C Library is distributed in the hope that it will be usef= ul, > >>> + but WITHOUT ANY WARRANTY; without even the implied warranty > of > >>> + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See > >> the GNU > >>> + Lesser General Public License for more details. > >>> + > >>> + You should have received a copy of the GNU Lesser General Public > >>> + License along with the GNU C Library; if not, see > >>> + . */ > >>> + > >>> +#include > >>> +#include > >>> +#if defined(__ASSUME_STATX) && defined(__NR_statx) #include > >>> + #include #include #include > >>> + #include > >>> + > >>> +/* Get information about the file NAME in BUF. */ > >>> + > >>> +int > >>> +__xstat64 (int vers, const char *name, struct stat64 *buf) { > >>> + struct statx xbuf; > >>> + int r =3D INLINE_SYSCALL (statx, 5, AT_FDCWD, name, 0, > >>> + STATX_BASIC_STATS, &xbuf); > >>> + if (r =3D=3D 0) > >>> + __cp_stat64_statx(buf, &xbuf); > >>> + return r; > >>> +} > >>> + > >>> +#else /* __ASSUME_STATX && __NR_statx */ #include > >>> + > >>> +#endif > >>> > >