Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 5 Sep 2008 23:44:58 +0300
From:      Kostik Belousov <kostikbel@gmail.com>
To:        Igor Sysoev <is@rambler-co.ru>
Cc:        freebsd-hackers@freebsd.org
Subject:   Re: opendir()/closedir()
Message-ID:  <20080905204458.GW2038@deviant.kiev.zoral.com.ua>
In-Reply-To: <20080905204014.GB71993@rambler-co.ru>
References:  <20080905184032.GA71993@rambler-co.ru> <20080905194845.GV2038@deviant.kiev.zoral.com.ua> <20080905204014.GB71993@rambler-co.ru>

next in thread | previous in thread | raw e-mail | index | archive | help

--/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--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20080905204458.GW2038>