[Yaffs] Question about unliked and deleted directories for yaffs2

Charles Manning manningc2 at actrix.gen.nz
Sat Dec 10 05:43:49 GMT 2005


Hi Lance
Lance Ware wrote:
> Hello fellow yaffers,
>
>     I wanted to know what was the difference between and unlinked directory
> and a deleted directory. 

The difference between unlinked files and deleted files in YAFFS mirrors the 
difference between unlinked and deleted files in POSIX. A file can be 
unlinked, but still active:

Consider:

  f = open("x",...) // open file
  unlink(f)  // unlink file. It no longer has a name, but a handle is open
  write(f)   // you can still read/write it etc.
  read(f)
  close(f)   // but as soon as the last handle is closed it is deleted.

Files that are unlinked are still busy and are not deleted until they become 
no longer busy.

YAFFS tracks this state by using two fake directories (other fake directories 
are the root and lost+found). 

After a freshh mount, any files that were unlinked are set to deleted (since 
the handle must have been closed to unmount, or is no longer valid after a 
power cycle).

> The reason why I am asking is that I currently 
> testing a system with yaffs2 file system.  When I remove a file from the
> yaffs system, I look at the nFreeChunks variable under /proc/yaffs and see
> that the total space hasn't been totally recovered.  I seem to be losing a
> Chunks or pages with each file creation and deletion.  

A "chunk" is used to track that the file was deleted. This will later get 
freed up by garbage collection, but will be busy until then.


I better look at this to make sure it is being cleaned up properly.

-- Charles




More information about the yaffs mailing list