This is the mail archive of the
ecos-devel@sourceware.org
mailing list for the eCos project.
FATFS bug
- From: Andrew Lunn <andrew at lunn dot ch>
- To: eCos Devel <ecos-devel at ecos dot sourceware dot org>
- Date: Thu, 3 Apr 2008 13:22:17 +0200
- Subject: FATFS bug
Hi Folks
While testing the recent contribution for readdir d_type, i found a
bug in fatfs. Enabling assert brings this to light when running the
fatfs1 test case. Without asserts it dereferences a null pointer,
which on synth in gdb causes a segmentation fault.
The problem sequence goes like:
mkdir("noonoo");
chdir("noonoo");
chdir("..");
rmdir("noonoo");
The problem is with the chdir(".."), which later causes the rmdir to
explode.
The fatfs does not correctly implement the concept of .. . Each
directory does have . and .. directories inodes, but .. does not seem
to link back correctly to the parent directory inode. Doing a
chdir("..") takes you into the .. inode, when it should take you up a
level to the parent. chdir("..") also increments the reference count
on the ".." inode, not the inode of the parent directory. This is why
the rmdir("noonoo") fails, the inode for "noonoo/.." reference count
is not zero.
This problem was not spotted before because until the last patch we
actually leaked the . and .. inodes when a directory was removed. Now
we try to clean them up get run into this problem.
Does anybody have time to look at this?
Thanks
Andrew