From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-3.1 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 3353 invoked from network); 24 May 2022 08:07:37 -0000 Received: from mother.openwall.net (195.42.179.200) by inbox.vuxu.org with ESMTPUTF8; 24 May 2022 08:07:37 -0000 Received: (qmail 21897 invoked by uid 550); 24 May 2022 08:07:35 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Reply-To: musl@lists.openwall.com Received: (qmail 21862 invoked from network); 24 May 2022 08:07:35 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1653379655; x=1684915655; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=fzEDrhHF+YXo73q5TrKtD5KNnKA4QkZqBMVW/Dtz9q8=; b=PLHc9O69L7pZoRiS1hYUFARLrpQTYaP69dhksrjlbW7S6gdUKWnB4D8O owocN7EBZFcg/xW6zEOeDurlXCL55BbQcsjCO3DA6iEkzDKHYCZ49s6Vj Mcadta6Ofdwnn7ZggcrI7gvxbFKYbhLscSNgEHrwMH3EKT1UfBwuxisNw ZYx/9s3dmsGQVt8M7r+DFV7Z1704r0hcVYIHyzXU2WiO9z3UawxnMmYb8 mQ05C31FkZc6CKky2cLW43uqs+70CUeEMmm5izxRtcLexVhwKOmE29a5A 6G6/ws6W1c8KL3Ap1BvHfgMpchy1AghVQTMyWDj60/gjRZYzcJLXOzT9l g==; X-IronPort-AV: E=McAfee;i="6400,9594,10356"; a="271037509" X-IronPort-AV: E=Sophos;i="5.91,248,1647327600"; d="scan'208";a="271037509" X-IronPort-AV: E=Sophos;i="5.91,248,1647327600"; d="scan'208";a="572512012" From: Jiaqing Zhao To: musl@lists.openwall.com Cc: Jiaqing Zhao Date: Tue, 24 May 2022 16:07:04 +0800 Message-Id: <20220524080704.70894-1-jiaqing.zhao@linux.intel.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [musl] [PATCH] dirent: implement getdents64 In musl, getdents64 is an alias of getdents, but the type annotation of these two functions are different according to man page[1], causing compile errors. This patch implements the standard getdents64. ssize_t getdents64(int fd, void *dirp, size_t count); [1] https://man7.org/linux/man-pages/man2/getdents.2.html Signed-off-by: Jiaqing Zhao --- include/dirent.h | 3 ++- src/linux/getdents.c | 6 +++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/include/dirent.h b/include/dirent.h index 650ecf64..4c5367c2 100644 --- a/include/dirent.h +++ b/include/dirent.h @@ -11,6 +11,7 @@ extern "C" { #define __NEED_off_t #if defined(_BSD_SOURCE) || defined(_GNU_SOURCE) #define __NEED_size_t +#define __NEED_ssize_t #endif #include @@ -50,6 +51,7 @@ long telldir(DIR *); #define IFTODT(x) ((x)>>12 & 017) #define DTTOIF(x) ((x)<<12) int getdents(int, struct dirent *, size_t); +ssize_t getdents64(int, void *, size_t); #endif #ifdef _GNU_SOURCE @@ -65,7 +67,6 @@ int versionsort(const struct dirent **, const struct dirent **); #define versionsort64 versionsort #define off64_t off_t #define ino64_t ino_t -#define getdents64 getdents #endif #ifdef __cplusplus diff --git a/src/linux/getdents.c b/src/linux/getdents.c index 796c1e5c..923a8076 100644 --- a/src/linux/getdents.c +++ b/src/linux/getdents.c @@ -9,4 +9,8 @@ int getdents(int fd, struct dirent *buf, size_t len) return syscall(SYS_getdents, fd, buf, len); } -weak_alias(getdents, getdents64); +ssize_t getdents64(int fd, void *buf, size_t len) +{ + if (len>INT_MAX) len = INT_MAX; + return syscall(SYS_getdents64, fd, buf, len); +} -- 2.34.1