[Yaffs] Problems on "rm -rf" on Yaffs2

Top Page
Attachments:
Message as email
+ (text/plain)
Delete this message
Reply to this message
Author: Zhen Feng
Date:  
To: yaffs
Subject: [Yaffs] Problems on "rm -rf" on Yaffs2
When I want to remove a directory using "rm -rf <dir>" command, a error message "The directory is not empty" occurs and serveral files in the directory are not deleted.

I traced into the code and found that yaffs_readdir() could be called serveral times by one time execution of "rm".Also, the file->f_pos are increased if a child(file) of this directory was found.

"rm" unlink the file read from directory entry:

rm->unlink()-> yaffs_unlink()-> yaffs_Unlink() ->yaffs_UnlinkWorker() -> yaffs_UnlinkFile()
->yaffs_ChangeObjectName()->yaffs_AddObjectToDirectory(), the unlinked file will be add to
"unlinked directory", in this case, this file is removed from its old parent directory's children list(obj->variant.directoryVariant.children) but added to the children of unlinked dir. (Is it right???)

The question is when "rm" has to call readdir() again because of low buffer, file->f_pos is not 0 but a
large number, the following code in yaffs_readdir() will bypass serveral files:
    
    offset = f->f_pos;
    ....
       curoffs = 1;
    list_for_each(i,&obj->variant.directoryVariant.children)
    {
        curoffs++;   
        if(curoffs >= offset)    
        {        


curoffs have to increase until it reaches f->f_pos, so readdir() miss serveral files in the front of obj->variant.directoryVariant.children


As a result, serveral files in the directory are not able to be unlinked, consequently, direcotry can not be removed.


When I delete a single file or directory with a small number of files, it is all right.
I wonder if my traces are right, how could I fix my problem ?

My arm Kernel is 2.4.18 running on samsung S3C2410. Nand Flash is samsung 128Mb with 2k Large page.

Thanks a Lot!!

--Zhen Feng