From: Miklos S. <mi...@sz...> - 2005-08-19 09:43:19
|
> I know that I should update my program and use the new *dir interfaces, > but there is a bug with the getdir, or the new mechanism if you use a > zero offset (not sure?). > > Try this with a program that uses the old getdir interface: > > mkdir test ; touch test/one test/two test/three ; rm -rf test Works for me. What kind of 'rm' do you use? $ rm --version rm (coreutils) 5.2.1 > I think what is happening is that rm -rf will list the directory, remove > the contents, rewind the directory, list the directory, remove any > remaining (newly created) files, and loop like that until the directory > is empty. This would be buggy as it is, because in some cases unlink() returning success, doesn't necessarily mean, that the file was really deleted (e.g. open file under NFS). > Unfortunately, inside libfuse's do_readdir, if the directory file handle > buffer is already filled, it simply returns with the old contents of the > directory, and not the updated contents which result from the removal of > the contents of that directory. Yes, it could be a bit more clever about caching the directory contents. However, that would present other problems: the posisions obtained by telldir() would no longer be valid after a directory modification. > Of course, if you use the readdir implementation and accept offsets, > this problem does not occur. > > The fix that I've attached will mark the buffer 'filled' to 0 when the > entire contents of the buffer have been read. This is of course still > only works if the entire directory is read, so we're still better off > using the new readdir interfaces. > > The attached patch applies to 2.3.0, but it looks like the same problem > could occur in your current CVS view, but the patch would be slightly > different. I'd rather not add this until we are sure where the problem lays. Thanks, Miklos |