[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Correct semantics in rm -rf ?
From: |
shailesh jain |
Subject: |
Correct semantics in rm -rf ? |
Date: |
Tue, 25 Aug 2009 11:15:46 -0700 |
Hi All,
rm -rf does following (highly simplified)
----
remove_cwd_entries() {
// Check if dirp is empty ...
readdir();
}
remove_dir() {
while(1) {
remove_cwd_entries();
// Get the fd of directory
fd = open();
// Unlink empty_dir
unlinkat();
dirp = fdopendir(fd);
}
}
-----
open() call on directory goes to the VFS layer that is when the directory
stream gets attached to it. Any subsequent modifications made to the
directory like unlinkat() may or may not be reflected in readdir() calls.
(Note: fdopendir() call does not goto underlying filesystem... ). So the
code in remove_cwd_entries() that checks if directory is empty may find the
deleted directory entry.... Isn't this code relying upon incorrect semantics
?
I see that local filesystems tend to work even with this behavior but
network file systems that would bring in entire directory contents on open()
will not work ?
Shailesh Jain
- Correct semantics in rm -rf ?,
shailesh jain <=
- Re: Correct semantics in rm -rf ?, Jim Meyering, 2009/08/26
- Re: Correct semantics in rm -rf ?, shailesh jain, 2009/08/26
- Re: Correct semantics in rm -rf ?, Jim Meyering, 2009/08/26
- Re: Correct semantics in rm -rf ?, shailesh jain, 2009/08/26
- Re: Correct semantics in rm -rf ?, Jim Meyering, 2009/08/26
- Re: Correct semantics in rm -rf ?, shailesh jain, 2009/08/26
- Re: Correct semantics in rm -rf ?, Jim Meyering, 2009/08/27
- Re: Correct semantics in rm -rf ?, shailesh jain, 2009/08/27
- Re: Correct semantics in rm -rf ?, Jim Meyering, 2009/08/27
- Re: Correct semantics in rm -rf ?, shailesh jain, 2009/08/27