Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 5 Sep 2008 22:40:32 +0400
From:      Igor Sysoev <is@rambler-co.ru>
To:        freebsd-hackers@FreeBSD.org
Subject:   opendir()/closedir()
Message-ID:  <20080905184032.GA71993@rambler-co.ru>

next in thread | raw e-mail | index | archive | help
Looking at opendir()/readdir()/closedir() sequence via ktrace,
I've seen supposedly useless lseek() syscall just before close().
It's called from closedir():

        _seekdir(dirp, dirp->dd_rewind);        /* free seekdir storage */

It seems that free()ing libc seekdir storage should be done without
calling lseek().

Other strange place for me is stat() before open() in opendir()

        /*
         * stat() before _open() because opening of special files may be
         * harmful.  _fstat() after open because the file may have changed.
         */

What is the case when opening special file may be harmful ?


-- 
Igor Sysoev
http://sysoev.ru/en/



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