From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 6826 invoked by alias); 9 Oct 2014 14:31:46 -0000 Mailing-List: contact cygwin-developers-help@cygwin.com; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-developers-owner@cygwin.com Mail-Followup-To: cygwin-developers@cygwin.com Received: (qmail 6813 invoked by uid 89); 9 Oct 2014 14:31:45 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.1 required=5.0 tests=AWL,BAYES_00,SPF_HELO_PASS,SPF_PASS,T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Thu, 09 Oct 2014 14:31:44 +0000 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s99EVhRK000826 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL) for ; Thu, 9 Oct 2014 10:31:43 -0400 Received: from [10.3.113.90] (ovpn-113-90.phx2.redhat.com [10.3.113.90]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id s99EVgbq001056 for ; Thu, 9 Oct 2014 10:31:43 -0400 Message-ID: <54369C4E.2030708@redhat.com> Date: Thu, 09 Oct 2014 14:31:00 -0000 From: Eric Blake User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.1.1 MIME-Version: 1.0 To: cygwin-developers@cygwin.com Subject: Re: src/winsup/cygwin ChangeLog fhandler_proc.cc f ... References: <20141009132437.7650.qmail@sourceware.org> In-Reply-To: <20141009132437.7650.qmail@sourceware.org> OpenPGP: url=http://people.redhat.com/eblake/eblake.gpg Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="RIfODULfvLX2MAoj1G560QnQaGGR8sQah" X-IsSubscribed: yes X-SW-Source: 2014-10/txt/msg00000.txt.bz2 This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --RIfODULfvLX2MAoj1G560QnQaGGR8sQah Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Content-length: 1649 On 10/09/2014 07:24 AM, corinna@cygwin.com wrote: > Log message: > * fhandler_proc.cc (fhandler_proc::readdir): Set dirent d_type. > * fhandler_process.cc (fhandler_process::readdir): Ditto. > * fhandler_procnet.cc (fhandler_procnet::readdir): Ditto. > * fhandler_procsys.cc (fhandler_procsys::readdir): Ditto. > * fhandler_procsysvipc.cc (fhandler_procsysvipc::readdir): Ditto. > * fhandler_virtual.h (virt_ftype_to_dtype): Define new inline function > to generate dirent d_type from virtual_ftype_t. Most of these look okay; but I have a problem with fhandler_procsys.cc: > @@ -357,10 +358,17 @@ > res =3D ENMFILE; > else > { > + struct stat st; > + char *file =3D tp.c_get (); > + > sys_wcstombs (de->d_name, NAME_MAX + 1, f.dbi.ObjectName.Buffer, > f.dbi.ObjectName.Length / sizeof (WCHAR)); > de->d_ino =3D hash_path_name (get_ino (), de->d_name); > - de->d_type =3D 0; > + stpcpy (stpcpy (stpcpy (file, get_name ()), "/"), de->d_name); > + if (!lstat64 (file, &st)) > + de->d_type =3D IFTODT (st.st_mode); > + else > + de->d_type =3D DT_UNKNOWN; The whole point of d_type is for optimization, to tell a process when it can avoid the overhead of an lstat() because the system was able to obtain the information in a cheaper manner. But if you have to resort to an lstat() to get the information, then you are wasting cycles on the case of a user that doesn't care about d_type. I'd rather we always return DT_UNKNOWN if the only way we'd get a better type is by calling lstat(). --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --RIfODULfvLX2MAoj1G560QnQaGGR8sQah Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" Content-length: 539 -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 Comment: Public key at http://people.redhat.com/eblake/eblake.gpg iQEcBAEBCAAGBQJUNpxOAAoJEKeha0olJ0NqQZcIAJdaq6B5C1aspJQxVShBWosz oc7DA6AQ4Or6LX7NHNfFwkz20E60qA6WPSkgI7FUf4T2dJ19Aelirz8H6dxMS5o3 tiGoDzHGJ4jyFbJ3s0S/msSxK4ml3k5GRMO30PjoBa8TswlHZbRrf6g7bYVi4T7W 1vrQirtaCjMHH5ynOEF/oRBKecWhXc4DEmGtXlOVktr/HIGOmASPxVVbqpopTZUL jqdUoYoWnuZRfbrNzH4oMPfLvSGb9Y6FjijgIUjc+NPrr0IgrO1kUl3KOOyUv+Ox 30x1r3zz8An6PiPILigIgw9/VbAmIJPZ51/tMZJuR4ubtJkiSTN9pyFbFNevpQg= =Ck1/ -----END PGP SIGNATURE----- --RIfODULfvLX2MAoj1G560QnQaGGR8sQah--