{"id":2221100,"url":"http://patchwork.ozlabs.org/api/1.1/patches/2221100/?format=json","web_url":"http://patchwork.ozlabs.org/project/uclibc-ng/patch/20260408190035.2759806-7-cmirabil@redhat.com/","project":{"id":55,"url":"http://patchwork.ozlabs.org/api/1.1/projects/55/?format=json","name":"uClibc NG development","link_name":"uclibc-ng","list_id":"devel.uclibc-ng.org","list_email":"devel@uclibc-ng.org","web_url":"http://www.uclibc-ng.org","scm_url":"","webscm_url":"http://cgit.uclibc-ng.org/cgi/cgit/uclibc-ng.git"},"msgid":"<20260408190035.2759806-7-cmirabil@redhat.com>","date":"2026-04-08T19:00:34","name":"[uclibc-ng-devel,v1,6/7] readdir{,_r}: remove loop to skip files with d_ino == 0","commit_ref":null,"pull_url":null,"state":"new","archived":false,"hash":"cfe49e69af21c75c4eb1589c3b7feeaef077fa9b","submitter":{"id":82370,"url":"http://patchwork.ozlabs.org/api/1.1/people/82370/?format=json","name":"Charles Mirabile","email":"cmirabil@redhat.com"},"delegate":null,"mbox":"http://patchwork.ozlabs.org/project/uclibc-ng/patch/20260408190035.2759806-7-cmirabil@redhat.com/mbox/","series":[{"id":499191,"url":"http://patchwork.ozlabs.org/api/1.1/series/499191/?format=json","web_url":"http://patchwork.ozlabs.org/project/uclibc-ng/list/?series=499191","date":"2026-04-08T19:00:29","name":"Bug fixes discovered trying to build allnoconfig","version":1,"mbox":"http://patchwork.ozlabs.org/series/499191/mbox/"}],"comments":"http://patchwork.ozlabs.org/api/patches/2221100/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/2221100/checks/","tags":{},"headers":{"Return-Path":"<devel-bounces@uclibc-ng.org>","X-Original-To":"incoming@patchwork.ozlabs.org","Delivered-To":"patchwork-incoming@legolas.ozlabs.org","Authentication-Results":["legolas.ozlabs.org;\n\tdkim=fail reason=\"signature verification failed\" (1024-bit key;\n unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256\n header.s=mimecast20190719 header.b=N41RDfuX;\n\tdkim-atps=neutral","legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=uclibc-ng.org\n (client-ip=89.238.66.15; helo=helium.openadk.org;\n envelope-from=devel-bounces@uclibc-ng.org; receiver=patchwork.ozlabs.org)","helium.openadk.org;\n\tdkim=fail reason=\"signature verification failed\" (1024-bit key;\n unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256\n header.s=mimecast20190719 header.b=N41RDfuX;\n\tdkim-atps=neutral"],"Received":["from helium.openadk.org (helium.openadk.org [89.238.66.15])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\t key-exchange x25519)\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4frXW973Vtz1xy1\n\tfor <incoming@patchwork.ozlabs.org>; Thu, 09 Apr 2026 05:02:29 +1000 (AEST)","from helium.openadk.org (localhost [127.0.0.1])\n\tby helium.openadk.org (Postfix) with ESMTP id 02BA531E0D0E;\n\tWed, 08 Apr 2026 21:02:19 +0200 (CEST)","from us-smtp-delivery-124.mimecast.com\n (us-smtp-delivery-124.mimecast.com [170.10.129.124])\n\tby helium.openadk.org (Postfix) with ESMTPS id 6833C31E0C64\n\tfor <devel@uclibc-ng.org>; Wed, 08 Apr 2026 21:01:09 +0200 (CEST)","from mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com\n (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by\n relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3,\n cipher=TLS_AES_256_GCM_SHA384) id us-mta-151-69OLuDXTM8izkyxxM2MUUw-1; Wed,\n 08 Apr 2026 15:00:47 -0400","from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com\n (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\t key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest\n SHA256)\n\t(No client certificate requested)\n\tby mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS\n id 6529118002D6\n\tfor <devel@uclibc-ng.org>; Wed,  8 Apr 2026 19:00:46 +0000 (UTC)","from cmirabil.redhat.com (unknown [10.2.16.11])\n\tby mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP\n id DAF60300019F;\n\tWed,  8 Apr 2026 19:00:45 +0000 (UTC)"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com;\n\ts=mimecast20190719; t=1775674867;\n\th=from:from:reply-to:subject:subject:date:date:message-id:message-id:\n\t to:to:cc:cc:mime-version:mime-version:content-type:content-type:\n\t content-transfer-encoding:content-transfer-encoding:\n\t in-reply-to:in-reply-to:references:references;\n\tbh=/J0SRI4WlUYXyTHvt4MeWRkPqxXzY8vtiuX2m/FfLcQ=;\n\tb=N41RDfuX+tgpyZlW8c+tZuD8Wicb1aH3WeGa0La++ZxoYi8E15xJwu9DeU69E/yx0Yx336\n\tjvQuAM8pxe2PPTcs6U1rSd4mXjGW4lvHObqrcL0nKSAQYx4lM1FJ/X/fikJn/ZMBTqIeqo\n\tGbdCnEIJ5V9Ik3c4H9Y4eteNZW/HIQs=","X-MC-Unique":"69OLuDXTM8izkyxxM2MUUw-1","X-Mimecast-MFC-AGG-ID":"69OLuDXTM8izkyxxM2MUUw_1775674846","From":"Charles Mirabile <cmirabil@redhat.com>","To":"devel@uclibc-ng.org","Date":"Wed,  8 Apr 2026 15:00:34 -0400","Message-ID":"<20260408190035.2759806-7-cmirabil@redhat.com>","In-Reply-To":"<20260408190035.2759806-1-cmirabil@redhat.com>","References":"<20260408190035.2759806-1-cmirabil@redhat.com>","MIME-Version":"1.0","X-Scanned-By":"MIMEDefang 3.4.1 on 10.30.177.4","X-Mimecast-Spam-Score":"0","X-Mimecast-MFC-PROC-ID":"terVKwYhU4habca9BnXEtdlU0L-ChM5MJ4prUm1x7E8_1775674846","X-Mimecast-Originator":"redhat.com","Message-ID-Hash":"GMZXVSPDV5T7AGXHL3FAHW7ZRQH2MSTN","X-Message-ID-Hash":"GMZXVSPDV5T7AGXHL3FAHW7ZRQH2MSTN","X-MailFrom":"cmirabil@redhat.com","X-Mailman-Rule-Misses":"dmarc-mitigation; no-senders; approved; loop;\n banned-address; emergency; member-moderation; nonmember-moderation;\n administrivia; implicit-dest; max-recipients; max-size; news-moderation;\n no-subject; digests; suspicious-header","CC":"Charles Mirabile <cmirabil@redhat.com>","X-Mailman-Version":"3.3.10","Precedence":"list","Subject":"[uclibc-ng-devel] [PATCH v1 6/7] readdir{,_r}: remove loop to skip\n files with\n d_ino == 0","List-Id":"uClibc-ng Development <devel.uclibc-ng.org>","Archived-At":"\n <https://uclibc-ng.org/mailman3/hyperkitty/list/devel@uclibc-ng.org/message/GMZXVSPDV5T7AGXHL3FAHW7ZRQH2MSTN/>","List-Archive":"\n <https://uclibc-ng.org/mailman3/hyperkitty/list/devel@uclibc-ng.org/>","List-Help":"<mailto:devel-request@uclibc-ng.org?subject=help>","List-Owner":"<mailto:devel-owner@uclibc-ng.org>","List-Post":"<mailto:devel@uclibc-ng.org>","List-Subscribe":"<mailto:devel-join@uclibc-ng.org>","List-Unsubscribe":"<mailto:devel-leave@uclibc-ng.org>","Content-Type":"text/plain; charset=\"us-ascii\"; x-default=\"true\"","Content-Transfer-Encoding":"7bit"},"content":"It is not prohibited to use inode zero according to SUS/POSIX and you can\nreally do it in practice on a filesystem in linux (even if doing so is\ninadvisable). All of the linux libcs I checked (musl, glibc, picolibc,\ndietlibc) have no such check.\n\nFixes: a4f075815 (\"Implement readdir_r.  Audit for proper thread safety and locking.  -Erik\")\nSigned-off-by: Charles Mirabile <cmirabil@redhat.com>\n---\n libc/misc/dirent/readdir.c   | 32 ++++++++++++++------------------\n libc/misc/dirent/readdir_r.c | 35 ++++++++++++++++-------------------\n 2 files changed, 30 insertions(+), 37 deletions(-)","diff":"diff --git a/libc/misc/dirent/readdir.c b/libc/misc/dirent/readdir.c\nindex 52fd26b62..7701ffb51 100644\n--- a/libc/misc/dirent/readdir.c\n+++ b/libc/misc/dirent/readdir.c\n@@ -28,28 +28,24 @@ __DIRENT_TYPE *__READDIR(DIR * dir)\n \n \t__UCLIBC_MUTEX_LOCK(dir->dd_lock);\n \n-\tdo {\n-\t    if (dir->dd_size <= dir->dd_nextloc) {\n-\t\t/* read dir->dd_max bytes of directory entries. */\n-\t\tbytes = __GETDENTS(dir->dd_fd, dir->dd_buf, dir->dd_max);\n-\t\tif (bytes <= 0) {\n-\t\t    de = NULL;\n-\t\t    goto all_done;\n-\t\t}\n-\t\tdir->dd_size = bytes;\n-\t\tdir->dd_nextloc = 0;\n+\tif (dir->dd_size <= dir->dd_nextloc) {\n+\t    /* read dir->dd_max bytes of directory entries. */\n+\t    bytes = __GETDENTS(dir->dd_fd, dir->dd_buf, dir->dd_max);\n+\t    if (bytes <= 0) {\n+\t\tde = NULL;\n+\t\tgoto all_done;\n \t    }\n+\t    dir->dd_size = bytes;\n+\t    dir->dd_nextloc = 0;\n+\t}\n \n-\t    de = (__DIRENT_TYPE *) (((char *) dir->dd_buf) + dir->dd_nextloc);\n-\n-\t    /* Am I right? H.J. */\n-\t    dir->dd_nextloc += de->d_reclen;\n+\tde = (__DIRENT_TYPE *) (((char *) dir->dd_buf) + dir->dd_nextloc);\n \n-\t    /* We have to save the next offset here. */\n-\t    dir->dd_nextoff = de->d_off;\n+\t/* Am I right? H.J. */\n+\tdir->dd_nextloc += de->d_reclen;\n \n-\t    /* Skip deleted files.  */\n-\t} while (de->d_ino == 0);\n+\t/* We have to save the next offset here. */\n+\tdir->dd_nextoff = de->d_off;\n \n all_done:\n \t__UCLIBC_MUTEX_UNLOCK(dir->dd_lock);\ndiff --git a/libc/misc/dirent/readdir_r.c b/libc/misc/dirent/readdir_r.c\nindex 04feac9c6..2e93f4e5b 100644\n--- a/libc/misc/dirent/readdir_r.c\n+++ b/libc/misc/dirent/readdir_r.c\n@@ -30,29 +30,26 @@ int __READDIR_R(DIR *dir, __DIRENT_TYPE *entry, __DIRENT_TYPE **result)\n \n \t__UCLIBC_MUTEX_LOCK(dir->dd_lock);\n \n-\tdo {\n-\t    if (dir->dd_size <= dir->dd_nextloc) {\n-\t\t/* read dir->dd_max bytes of directory entries. */\n-\t\tbytes = __GETDENTS(dir->dd_fd, dir->dd_buf, dir->dd_max);\n-\t\tif (bytes <= 0) {\n-\t\t    de = NULL;\n-\t\t    *result = NULL;\n-\t\t    ret = (bytes==0)? 0 : errno;\n-\t\t    goto all_done;\n-\t\t}\n-\t\tdir->dd_size = bytes;\n-\t\tdir->dd_nextloc = 0;\n+\tif (dir->dd_size <= dir->dd_nextloc) {\n+\t    /* read dir->dd_max bytes of directory entries. */\n+\t    bytes = __GETDENTS(dir->dd_fd, dir->dd_buf, dir->dd_max);\n+\t    if (bytes <= 0) {\n+\t\tde = NULL;\n+\t\t*result = NULL;\n+\t\tret = (bytes==0)? 0 : errno;\n+\t\tgoto all_done;\n \t    }\n+\t    dir->dd_size = bytes;\n+\t    dir->dd_nextloc = 0;\n+\t}\n \n-\t    de = (__DIRENT_TYPE *) (((char *) dir->dd_buf) + dir->dd_nextloc);\n+\tde = (__DIRENT_TYPE *) (((char *) dir->dd_buf) + dir->dd_nextloc);\n \n-\t    /* Am I right? H.J. */\n-\t    dir->dd_nextloc += de->d_reclen;\n+\t/* Am I right? H.J. */\n+\tdir->dd_nextloc += de->d_reclen;\n \n-\t    /* We have to save the next offset here. */\n-\t    dir->dd_nextoff = de->d_off;\n-\t    /* Skip deleted files.  */\n-\t} while (de->d_ino == 0);\n+\t/* We have to save the next offset here. */\n+\tdir->dd_nextoff = de->d_off;\n \n \tif (de == NULL) {\n \t    *result = NULL;\n","prefixes":["uclibc-ng-devel","v1","6/7"]}