From: Jan Blunck Subject: Re: readdir behaviour Date: Tue, 02 Aug 2005 11:54:28 +0200 Message-ID: <1122976468.42ef42d4df4ea@webmail.tu-harburg.de> References: <5931eebf050801162174f6f54@mail.gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7BIT Cc: linux-fsdevel@vger.kernel.org Return-path: Received: from smtp2.rz.tu-harburg.de ([134.28.205.13]:2675 "EHLO smtp2.rz.tu-harburg.de") by vger.kernel.org with ESMTP id S261458AbVHBJyi (ORCPT ); Tue, 2 Aug 2005 05:54:38 -0400 To: Tomas Hruby In-Reply-To: <5931eebf050801162174f6f54@mail.gmail.com> Sender: linux-fsdevel-owner@vger.kernel.org List-Id: linux-fsdevel.vger.kernel.org This was also topic on lkml 2 weeks ago. Zitat von Tomas Hruby : > First of all I would like to know what exactly is the meaning of the > 'offset' parameter of filldir and whether it is used somewhere? Unlike > ext2, our directories are not easily read sequentially and this value > (copied by filldir to dirent->d_off) seems to be quite useless outside > our fs code. The offset of the dirent has no common meaning. Think of it as a cookie or something like that. It should not be interpreted either by VFS or by the user-space. > Related question is what is the correct behaviour of readdir in case > of user's seeking in the directory? If I understand correctly, in case > of ext3 (indexed directories), when seeking is detected, readdir > starts reading from the directory beginning again. On different archs the libc is seeking (to d_off) after each call to getdents(). Therefore the implementation should honor it. > The last is about concurrency. How is solved problem when a directory > is read by readdir and between two readdir calls the same directory is > changed? This is the filesystems duty to seek to the next valid dentry. Although it is not defined if the new directories contents is returned or the one on opendir(). Although I think it would be nice (and convenient to the "everything is a file" paradigm) when the directory is presented like a sequential file this is not the common practice. Due to the fact that there are no applications which are reading and seeking the directories directly this is a good tradeoff to achieve high performance for readdir(). Jan