From owner-freebsd-hackers@FreeBSD.ORG Fri Sep 5 19:48:52 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 43E801065670 for ; Fri, 5 Sep 2008 19:48:52 +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 DD9158FC17 for ; Fri, 5 Sep 2008 19:48:51 +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 1KbhIX-0007Ig-O8; Fri, 05 Sep 2008 22:48:49 +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 m85JmkP2070837 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Fri, 5 Sep 2008 22:48:46 +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 m85JmkRo089761; Fri, 5 Sep 2008 22:48:46 +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 m85JmjhD089760; Fri, 5 Sep 2008 22:48:45 +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 22:48:45 +0300 From: Kostik Belousov To: Igor Sysoev Message-ID: <20080905194845.GV2038@deviant.kiev.zoral.com.ua> References: <20080905184032.GA71993@rambler-co.ru> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="t/OLoFZ234xJS33u" Content-Disposition: inline In-Reply-To: <20080905184032.GA71993@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 1KbhIX-0007Ig-O8 3b314a861a5f6613ae16997e40c92d9c 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 19:48:52 -0000 --t/OLoFZ234xJS33u Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable 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 storage */ >=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 change= d. > */ >=20 > What is the case when opening special file may be harmful ? For instance, tape may be rewinded. 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. --t/OLoFZ234xJS33u Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.9 (FreeBSD) iEYEARECAAYFAkjBjR0ACgkQC3+MBN1Mb4i5ZACgy0o29M427E7EXlZCGET3NWjX t2EAn1LfapVOUX8PBSaIZrKl1mU+QT2n =yCdT -----END PGP SIGNATURE----- --t/OLoFZ234xJS33u--