This is the mail archive of the ecos-discuss@sourceware.org mailing list for the eCos project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: blib node allocation problem with FAT FS


On Wed, Feb 27, 2008 at 06:56:07PM +0100, Andrew Lunn wrote:
> > I found the problem. The reference count was decrementing below 0. Here 
> > is a fix for fatfs_node_unref() in fatfs_ncache.c.
> >
> >  if (node->refcnt)
> >        node->refcnt--;
> 
> It could be that you have fixed the symptom and not the cause. Why is
> it being unreferenced more times than it is referenced? Maybe there is
> a missing ref() so you could get file corrupt?

In fact, i very much suspect this fix is wrong. Look at the code:

void
fatfs_node_unref(fatfs_disk_t *disk, fatfs_node_t *node)
{
    CYG_CHECK_DATA_PTRC(disk);
    CYG_CHECK_DATA_PTRC(node);
    CYG_TRACE2(TNC, "node='%s' refcnt=%d", node->dentry.filename, node->refcnt);
    CYG_ASSERT(node->refcnt > 0, "node->refcnt <= 0");

i.e, if you had asserts enabled, it would of thrown an assert failure.

You need to dig further and find the real problem. Turning on asserts
might make this easier to find.

    Andrew

-- 
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]