From owner-freebsd-hackers@FreeBSD.ORG Fri Sep 5 20:45:22 2008 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 474F51065670 for ; Fri, 5 Sep 2008 20:45:22 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from mail.terabit.net.ua (mail.terabit.net.ua [195.137.202.147]) by mx1.freebsd.org (Postfix) with ESMTP id DD7148FC16 for ; Fri, 5 Sep 2008 20:45:21 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from skuns.zoral.com.ua ([91.193.166.194] helo=mail.zoral.com.ua) by mail.terabit.net.ua with esmtp (Exim 4.63 (FreeBSD)) (envelope-from ) id 1KbiBE-000EbR-OD; Fri, 05 Sep 2008 23:45:20 +0300 Received: from deviant.kiev.zoral.com.ua (root@deviant.kiev.zoral.com.ua [10.1.1.148]) by mail.zoral.com.ua (8.14.2/8.14.2) with ESMTP id m85Kiwas046806 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Fri, 5 Sep 2008 23:44:59 +0300 (EEST) (envelope-from kostikbel@gmail.com) Received: from deviant.kiev.zoral.com.ua (kostik@localhost [127.0.0.1]) by deviant.kiev.zoral.com.ua (8.14.2/8.14.2) with ESMTP id m85Kiw2O095391; Fri, 5 Sep 2008 23:44:58 +0300 (EEST) (envelope-from kostikbel@gmail.com) Received: (from kostik@localhost) by deviant.kiev.zoral.com.ua (8.14.3/8.14.3/Submit) id m85Kiwkt095390; Fri, 5 Sep 2008 23:44:58 +0300 (EEST) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: deviant.kiev.zoral.com.ua: kostik set sender to kostikbel@gmail.com using -f Date: Fri, 5 Sep 2008 23:44:58 +0300 From: Kostik Belousov To: Igor Sysoev Message-ID: <20080905204458.GW2038@deviant.kiev.zoral.com.ua> References: <20080905184032.GA71993@rambler-co.ru> <20080905194845.GV2038@deviant.kiev.zoral.com.ua> <20080905204014.GB71993@rambler-co.ru> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="/prQV9BysLedkZvy" Content-Disposition: inline In-Reply-To: <20080905204014.GB71993@rambler-co.ru> User-Agent: Mutt/1.4.2.3i X-Virus-Scanned: ClamAV version 0.93.3, clamav-milter version 0.93.3 on skuns.kiev.zoral.com.ua X-Virus-Status: Clean X-Spam-Status: No, score=-4.4 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00 autolearn=ham version=3.2.5 X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on skuns.kiev.zoral.com.ua X-Virus-Scanned: mail.terabit.net.ua 1KbiBE-000EbR-OD 7639c60fd07c23d18f34c17945486e2a X-Terabit: YES Cc: freebsd-hackers@freebsd.org Subject: Re: opendir()/closedir() X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 05 Sep 2008 20:45:22 -0000 --/prQV9BysLedkZvy Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Sat, Sep 06, 2008 at 12:40:14AM +0400, Igor Sysoev wrote: > On Fri, Sep 05, 2008 at 10:48:45PM +0300, Kostik Belousov wrote: >=20 > > On Fri, Sep 05, 2008 at 10:40:32PM +0400, Igor Sysoev wrote: > > > Looking at opendir()/readdir()/closedir() sequence via ktrace, > > > I've seen supposedly useless lseek() syscall just before close(). > > > It's called from closedir(): > > >=20 > > > _seekdir(dirp, dirp->dd_rewind); /* free seekdir stora= ge */ > > >=20 > > > It seems that free()ing libc seekdir storage should be done without > > > calling lseek(). > > >=20 > > > Other strange place for me is stat() before open() in opendir() > > >=20 > > > /* > > > * stat() before _open() because opening of special files may= be > > > * harmful. _fstat() after open because the file may have ch= anged. > > > */ > > >=20 > > > What is the case when opening special file may be harmful ? > >=20 > > For instance, tape may be rewinded. > >=20 > > The whole opendir/seekdir/telldir probably should be synced with OpenBSD > > version, at least due to SINGLEUSE. I made this conclusion when I merged > > the OpenBSD fix for seekdir several months ago. But I also decided then > > that I am not a volunteer. >=20 > BTW, OpenBSD does not worry about tapes :), they use open()/fstat() from > the very start. And closedir() does not lseek() since OpenBSD 4.0. This was my point. They reworked the code, and it seems that rework brought in improvements, that are aligned with your observations. --/prQV9BysLedkZvy Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.9 (FreeBSD) iEYEARECAAYFAkjBmkoACgkQC3+MBN1Mb4hpuACgwTJlwFSolkAVfh8fnk3M/nAK ECEAn3oDT945p9sFOgGzAJyXsjL9nwrN =JidR -----END PGP SIGNATURE----- --/prQV9BysLedkZvy--