From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS3215 2.6.0.0/16 X-Spam-Status: No, score=-4.2 required=3.0 tests=AWL,BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED,SPF_HELO_PASS,SPF_PASS shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by dcvr.yhbt.net (Postfix) with ESMTPS id A20521F8C6 for ; Thu, 5 Aug 2021 03:24:57 +0000 (UTC) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 00E5A3985005 for ; Thu, 5 Aug 2021 03:24:56 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 00E5A3985005 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1628133896; bh=P5mcHg4RrZ28vSnfzZutnVz4s4M8FwZA5IwbpbpFznA=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=KPR7vDS4l/rM3HDtBjXuH2zMQLKriGDKHuu+qDj+U5sFjEEvcCTSUdvx64LH36tvk OwpGgZSWydbfHCHra68YvPGe0q9Tb5ZGH4QBE1ew2OGcnB8YGDi44evRaV5/3ugL0V BPZ65DfwaNM8ZZXMjgdE7e4uwRTCsKx56YT9Sjwg= Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by sourceware.org (Postfix) with ESMTP id D12E6398407F for ; Thu, 5 Aug 2021 03:24:35 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org D12E6398407F Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-511-VFr3UWWRNSGIMHT9oqVuMQ-1; Wed, 04 Aug 2021 23:24:34 -0400 X-MC-Unique: VFr3UWWRNSGIMHT9oqVuMQ-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 5248D107ACF5 for ; Thu, 5 Aug 2021 03:24:33 +0000 (UTC) Received: from greed.delorie.com (ovpn-112-6.rdu2.redhat.com [10.10.112.6]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 21BA960BF4 for ; Thu, 5 Aug 2021 03:24:33 +0000 (UTC) Received: from greed.delorie.com.redhat.com (localhost [127.0.0.1]) by greed.delorie.com (8.15.2/8.15.2) with ESMTP id 1753OWIJ1052186 for ; Wed, 4 Aug 2021 23:24:32 -0400 Date: Wed, 04 Aug 2021 23:24:32 -0400 Message-Id: To: libc-alpha@sourceware.org Subject: glob vs '*/' vs GLOB_ONLYDIR vs xfs X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="US-ASCII" 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: , From: DJ Delorie via Libc-alpha Reply-To: DJ Delorie Errors-To: libc-alpha-bounces+e=80x24.org@sourceware.org Sender: "Libc-alpha" in posix/glob.c we have this comment: /* POSIX requires all slashes to be matched. This means that with a trailing slash we must match only directories. */ if (pattern[0] && pattern[strlen (pattern) - 1] == '/') flags |= GLOB_ONLYDIR; In "man glob" we see: GLOB_ONLYDIR This is a _hint_ to glob() that the caller is interested only in directories that match the pattern. So, for starters, we're relying on "a hint" to implement a "must". If you're running glob on an XFS filesystem, readdir() doesn't reliably fill in d_type, and the "hint" fails: #include #include main(int argc, char **argv) { glob_t g; int i; glob (argv[1], 0, NULL, &g); for (i=0; i