From patchwork Fri Mar 12 03:49:20 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: YunQiang Su X-Patchwork-Id: 42487 Return-Path: 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 448CB3896C0C; Fri, 12 Mar 2021 03:49:51 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from APC01-SG2-obe.outbound.protection.outlook.com (mail-eopbgr1310122.outbound.protection.outlook.com [40.107.131.122]) by sourceware.org (Postfix) with ESMTPS id 1BA713894C25 for ; Fri, 12 Mar 2021 03:49:45 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 1BA713894C25 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=ldUNQ9e+wTnMAYs8VL4UAcdlOhc9coLAZr91py7JPxC60Y0GIcXSXyN1GfuS/MVwARE641el8JAkv3Cs1wG1mvvkWYaCP579kO0vEjCvNNjgNE/cNaPziTlYC5xwiZuMJ764IijpZZdlkqMMG3oMhjA+3lRVTi+N6kUASwg4/XjMW0kQ9UyzkUo29FSSFZhce+7nrF2/RrEztzqrl4oGttuC+9ACIgoLgsB1hHTZO4UUFAv5a6Te92mVa9WcvvD6zD239MofF2DVC+0fyy8F7sMzDAzhh8/cZppPGriz2G1LrcA8/XKnAqs1idAbeF90bArQfFARDHkgNin21mvLUQ== 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=PkkGGv0xVtKW+3SiUphALxLq8GEXcwCy4RtjsVR4Gh8=; b=bgZ08fqsbwBkA5naMkhmdZvC6qzFOgLP+ymOb0QQmEVuhQRzjvx/wU6uopJpRyDEuvGGT7/sAFROpN1A3k9zGFZOFbl2SINKEqfXh0tWDU818lB4g05KBFGcC909oNnYG/m99515sEWPG7edMyrZPljxv66c1LhV3p5ASRk1wIoFaivfACySDviobt8XlSkM7lyTh6pJBQOJO3sWoSESsVJRA8gU5a7rA6g5vaXnw7id3p3juHSpiQ0kmgbXM3AtcMDAGsO3Z1Gdfx9WV/udEZITuNGRfvPI9O0vSyz5k/ErBP+Eg789/M74HUfGJFj5QMy8P/xEixw52nyQyOZ29w== 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=PkkGGv0xVtKW+3SiUphALxLq8GEXcwCy4RtjsVR4Gh8=; b=KWwWLkqqgzdmwF+9B4Tg4YbRhOD8+Xk3X7qUibOnaFLwuFxgV6V94AFUYpCsNXr+bLEPtJ9+jWQpq6ZaXymM6xjPH1CWFMRFjp6ulklvEVg48efdeask6/DKHANBE6eeaeAIvm+/gh9o4biBfb2kUSjUb1se129K4ws3VEb1Ezk= Authentication-Results: sourceware.org; dkim=none (message not signed) header.d=none;sourceware.org; dmarc=none action=none header.from=cipunited.com; Received: from HKAPR04MB3956.apcprd04.prod.outlook.com (2603:1096:203:d5::13) by HKAPR04MB3956.apcprd04.prod.outlook.com (2603:1096:203:d5::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3890.19; Fri, 12 Mar 2021 03:49:37 +0000 Received: from HKAPR04MB3956.apcprd04.prod.outlook.com ([fe80::b5d5:d70f:ed37:984c]) by HKAPR04MB3956.apcprd04.prod.outlook.com ([fe80::b5d5:d70f:ed37:984c%6]) with mapi id 15.20.3890.038; Fri, 12 Mar 2021 03:49:37 +0000 From: YunQiang Su To: libc-alpha@sourceware.org Subject: [PATCH] MIPS: fix y2106 problem on N64 with statx Date: Fri, 12 Mar 2021 03:49:20 +0000 Message-Id: <20210312034920.14846-1-yunqiang.su@cipunited.com> X-Mailer: git-send-email 2.20.1 X-Originating-IP: [60.247.76.83] X-ClientProxiedBy: HK2PR0401CA0011.apcprd04.prod.outlook.com (2603:1096:202:2::21) To HKAPR04MB3956.apcprd04.prod.outlook.com (2603:1096:203:d5::13) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (60.247.76.83) by HK2PR0401CA0011.apcprd04.prod.outlook.com (2603:1096:202:2::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3912.17 via Frontend Transport; Fri, 12 Mar 2021 03:49:36 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 1221e23d-7670-481c-1b22-08d8e509db3b X-MS-TrafficTypeDiagnostic: HKAPR04MB3956: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:1468; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 8gT9uafGlfcBsPF0D+n95K3XKpk9MUORNpNxPtCkaLo2rMRgbFtHDTsVosy/MAsDYtfpM3vCYexzEsG1u1id9HlxOFMydJmaXVKsRrHnO3o9F9Mboa9qupnmmBBkq2XFVnyineEv15rhTaei6blaYiRdh15ZMrTw72GE61RHmh1DbZO2JOJk8wdDjpO1+E+rco+BVrsHo+leIS8XYQO5NlWShJE0AjjtIrXIo6GB5FJ9ZzajL4yhKHQFVgRorPPOuZPZW3mqnYWzCyKqg1ksCJVypBvifgSxo0bmJvG9zH1WRRsn2c8PyTqUymPFRpWHgE3Dxi2chALLaYtSjSoWC/wK+uTnT21Bqc+5o37jBOrRSywZd1F5D8Qvx/B7j6td++iadeGihe3QR+7TZuWG1zYicVDQUNZ/8pRxQB6Ma/6LWo/krhDhN65DL7/jS6m1gwxLZIiB9NDB16u2CFL+aLj+QGBTIjZCq+e5GHD6wURvDpz6dkHisSyBU9IboBv/alDm/dXnPIOX4zKwpLVh4UZZi/FNZ/p+Xw5WcI4dE+1RxTLiIx26pstvI5a16pXJxAnzUzuQ8N0bg9q1glnpB6uAwb8RVZCwnDhAbJLYlMmDVLAxR5efwdmZzHzPOT19npNM+Dc4Hv2kVVnsD7GgVMVJ6NlVmlIPuwgTxePnY0GKUbyRtGezqtWJ3BNRwNBB 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:(136003)(366004)(376002)(39830400003)(396003)(346002)(1076003)(4326008)(66476007)(26005)(8936002)(8676002)(69590400012)(36756003)(6486002)(6506007)(6916009)(186003)(2906002)(52116002)(956004)(86362001)(30864003)(478600001)(2616005)(5660300002)(316002)(6512007)(66946007)(83380400001)(6666004)(107886003)(66556008)(16526019)(2004002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: HH298ERvRB/etxlr5q9cs9lmElkL93ygFW+o2OOiXl+OsEhlNs+BH5qqWYK2Sx4iGCUSKJSFQUlgldqqN+uIOUXN52zl5xhaBWBujP59euucbE6IU3qOQCHAtrEX9+xakYWtnLzPjsWuJor7h08YbnYKUzTqMdOMIeS1C5utz4lFRTKuy/xTPbZfjNQPoOPdlZsov+DFPFXCBvawK9rKV53RGIUd6Hjy/PZewgAIpyd9va+2Ex0Cc6Jz/ED71L6VxY90dZdnu+HAhJEJ7PzDE7KivvWeEVzVQkpRbjmMPbMoGX9BZd326Sxjqk4LEH3zMglZEW0fyg7gnt/phk4GFL0RjrT1WLEJ07zM2zN4k2HU3qthO9hPKgUglxzWm2bWV8tLwz7z4P+cjituQAN5ly0w+VWum9PhnUvsrUSRtaKhonmRpRNCvR23DU2/WI0EqCCQsdFCGhvN5Jq6jcV0wVpNx3bZ2KMhFqByT/pZbm+LvxGORrgLVBdUmpz82gQ8jkfdZY8C7z/NqArsMb2CjovslWre3/9sUZ2pdMKzJGi5FSoq7TD78IRXNypkRAccngAxdx4i5CkoigSjfMLRHr/mOQv+OiqfGpBk/lRpMa/H/REFXqv+iAYG8guX3+z14F2KXmeLyLpH1upgArzy3T2476MtiY3T+Qi0bMk+mwJ29uF4JIr/TQ5ChTW6L+qsa3yGRUZVa77sIJFnMZe4rZFrpH/a2YsAfnqjn1j36xa44756sQGOLxzH+oxQINjoifuv8AzhVV/2Aybq1NLV071rwyeL/HJP8/RFSaYUWzcJHmxDKcqFPAz/iWd7lh+Ll38/0UOL1ugVOxLiIqW+qwgUQp+CKCzqArQtF8vNkM2G1Cc9gqf6xqGG28gZIleYnRgiiHxgmHTOprD/Y66vcOYH5b26LdcDqI4rZ8h41HaIeGydKm4FzVOeh/loJj5lKXVGOaqrwdEl/xQfLlGE/kYYRJw4J6b+oxcYPPw3t4t6b7i3JJCEIVUCIKu4QfmDqmAeI5iAwUn47IfhLNy5xB5iFE0jDoczQJ7vyT0nE8C6EoffOgQ1VWDyY3RZ8NVHMIO45Yu8QXPsJG6WgkF1c8GrD8tNtIG/Qv1vvZlJItokOd3x2TVviz7jh0tQrgFWOtZKjsEo9hQEx7XvqtBA7NaYVPE4Pz8wP+dVfE/zrTznX7wgwBd/gTDCMJG1O0TcRYMRwr9Ray7atLDwV65b4+O/ccf0qtP2MtySSgfNhXOf1I9fsCUOucES6B1FONOwgU2/Hi99IvA+OXEVJghVsYhiy3M0xN6QqV5QO0M7UKMNY7R6PTLGLSXJMVzJnVzx X-OriginatorOrg: cipunited.com X-MS-Exchange-CrossTenant-Network-Message-Id: 1221e23d-7670-481c-1b22-08d8e509db3b X-MS-Exchange-CrossTenant-AuthSource: HKAPR04MB3956.apcprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Mar 2021 03:49:37.2517 (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: c8gdF1ZerfXl2CoWIKSuAo5oAEAAzAmdZFuoa7cbDAyV/QlTewR6dLYoEJhxk6VC0Wv4w62eb5CqDC+vkSNyB/U31k9a5Sqaryygkt8C6xY= X-MS-Exchange-Transport-CrossTenantHeadersStamped: HKAPR04MB3956 X-Spam-Status: No, score=-13.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, KAM_SHORT, MSGID_FROM_MTA_HEADER, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2, 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: , Cc: YunQiang Su , aurelien@aurel32.net, jiaxun.yang@flygoat.com, macro@orcam.me.uk Errors-To: libc-alpha-bounces@sourceware.org Sender: "Libc-alpha" 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. 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. --- 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 == _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] = {{-1, 0}, {-1, 0}}; + if (utimensat(dir_fd, "some-file", tm_1, 0) != 0) + { + puts ("utimensat fail"); + return 1; + } + + if (fstatat64 (dir_fd, "some-file", &st2, 0) != 0) + { + puts ("fstatat64 failed"); + return 1; + } + + if (st2.st_mtim.tv_sec != -1 + || st2.st_atim.tv_sec != -1) + { + puts ("fstatat64 has y2106 problem?"); + return 1; + } +#endif if (unlinkat (dir_fd, "some-file", 0) != 0) { 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 == 32 \ - && (!defined __SYSCALL_WORDSIZE || __SYSCALL_WORDSIZE == 32)) + && (!defined __SYSCALL_WORDSIZE || __SYSCALL_WORDSIZE == 32)) \ + || defined(__mips64) /* 32-bit kABI with default 64-bit time_t, e.g. arc, riscv32. Also 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; r = INTERNAL_SYSCALL_CALL (statx, fd, file, AT_NO_AUTOMOUNT | flag, STATX_BASIC_STATS, &tmp); if (r == 0) { +#if defined(__mips64) && (_MIPS_SIM == _ABI64) + __cp_stat64_statx (buf, &tmp); +#else __cp_stat64_t64_statx (buf, &tmp); +#endif return 0; } if (-r != 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/or + 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 useful, + 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 == 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 = INLINE_SYSCALL (statx, 5, fd, file, flag&AT_SYMLINK_NOFOLLOW, + STATX_BASIC_STATS, &xbuf); + if (r == 0) + __cp_stat64_statx((struct stat64 *)st, &xbuf); + return r; +} + +weak_alias (__fstatat, fstatat) + +#else /* __ASSUME_STATX && __NR_statx */ +#include +#endif 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/or + 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 useful, + 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 = INLINE_SYSCALL (statx, 5, fd, "", AT_EMPTY_PATH, + STATX_BASIC_STATS, &xbuf); + if (r == 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/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/or + 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 useful, + 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 = INLINE_SYSCALL (statx, 5, fd, "", AT_EMPTY_PATH, + STATX_BASIC_STATS, &xbuf); + if (r == 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/or + 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 useful, + 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 == 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 = INLINE_SYSCALL (statx, 5, fd, file, flag&AT_SYMLINK_NOFOLLOW, + STATX_BASIC_STATS, &xbuf); + if (r == 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/or + 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 useful, + 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 != _STAT_VER_LINUX, 0)) + { + __set_errno (EINVAL); + return -1; + } + + struct statx xbuf; + int r = INLINE_SYSCALL (statx, 5, fd, file, flag&AT_SYMLINK_NOFOLLOW, + STATX_BASIC_STATS, &xbuf); + if (r == 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/or + 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 useful, + 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 = INLINE_SYSCALL (statx, 5, AT_FDCWD, name, AT_SYMLINK_NOFOLLOW, + STATX_BASIC_STATS, &xbuf); + if (r == 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/or + 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 useful, + 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 = 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 == 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/or + 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 useful, + 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 = INLINE_SYSCALL (statx, 5, AT_FDCWD, name, 0, + STATX_BASIC_STATS, &xbuf); + if (r == 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/or + 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 useful, + 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 = INLINE_SYSCALL (statx, 5, AT_FDCWD, name, 0, + STATX_BASIC_STATS, &xbuf); + if (r == 0) + __cp_stat64_statx(buf, &xbuf); + return r; +} + +#else /* __ASSUME_STATX && __NR_statx */ +#include +#endif