src/kernel/fs/fat32.c
/*!
 * @note get a idle entry with holding it`s write lock.
 *       generally invoking by entry_new.
 * @return idle entry or NULL when idle entry not find.
 */
@note get a idle entry with holding it`s write lock.
generally invoking by entry_new.
@return idle entry or NULL when idle entry not find.
@note get a idle entry with holding it ` s write lock . generally invoking by entry_new . @return idle entry or NULL when idle entry not find .
entry_t * _entry_get_idle_write(){
    entry_t * ret = NULL;
    fs_stub_rw_w_lock_acquire(&entry_cache.rw_lock);
    entry_cache.dirty = true;
    for(dnode_t * probe = entry_cache.dlink.head;probe!=NULL;probe=probe->next){
        entry_t * entry = probe->data;
        fs_stub_rw_w_lock_acquire(&entry->rw_lock);
        if(entry->ref_cnt == 0){
            if(entry->parent!=NULL){
                fs_stub_rw_w_lock_acquire(&entry->parent->rw_lock);
                entry->parent->dirty = true;
                _entry_flush(entry);
                entry->parent->ref_cnt--;
                fs_stub_rw_w_lock_release(&entry->parent->rw_lock);
            }
            ret = entry;
            break;
        }
        fs_stub_rw_w_lock_release(&entry->rw_lock);
    }
    fs_stub_rw_w_lock_release(&entry_cache.rw_lock);
    return ret;
}
entry_t * _entry_get_idle_write ( ) { entry_t * ret = NULL ; fs_stub_rw_w_lock_acquire ( & entry_cache . rw_lock ) ; entry_cache . dirty = true ; for ( dnode_t * probe = entry_cache . dlink . head ; probe != NULL ; probe = probe -> next ) { entry_t * entry = probe -> data ; fs_stub_rw_w_lock_acquire ( & entry -> rw_lock ) ; if ( entry -> ref_cnt == 0 ) { if ( entry -> parent != NULL ) { fs_stub_rw_w_lock_acquire ( & entry -> parent -> rw_lock ) ; entry -> parent -> dirty = true ; _entry_flush ( entry ) ; entry -> parent -> ref_cnt -- ; fs_stub_rw_w_lock_release ( & entry -> parent -> rw_lock ) ; } ret = entry ; break ; } fs_stub_rw_w_lock_release ( & entry -> rw_lock ) ; } fs_stub_rw_w_lock_release ( & entry_cache . rw_lock ) ; return ret ; }
@note get a idle entry with holding it`s write lock.
@note get a idle entry with holding it ` s write lock .
// get entry write lock // get idle