Changeset 9a3d5f0 in mainline for uspace/srv/fs/fat/fat_ops.c


Ignore:
Timestamp:
2008-11-09T21:13:30Z (16 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
adb5fe3
Parents:
ac49f5d1
Message:

Move common code to dedicated functions so that it can be easily reused.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/fs/fat/fat_ops.c

    rac49f5d1 r9a3d5f0  
    103103}
    104104
    105 /** Internal version of fat_node_get().
    106  *
    107  * @param idxp          Locked index structure.
    108  */
    109 static void *fat_node_get_core(fat_idx_t *idxp)
    110 {
    111         block_t *b;
    112         fat_bs_t *bs;
    113         fat_dentry_t *d;
    114         fat_node_t *nodep = NULL;
    115         unsigned bps;
    116         unsigned spc;
    117         unsigned dps;
    118 
    119         if (idxp->nodep) {
    120                 /*
    121                  * We are lucky.
    122                  * The node is already instantiated in memory.
    123                  */
    124                 futex_down(&idxp->nodep->lock);
    125                 if (!idxp->nodep->refcnt++)
    126                         list_remove(&idxp->nodep->ffn_link);
    127                 futex_up(&idxp->nodep->lock);
    128                 return idxp->nodep;
    129         }
    130 
    131         /*
    132          * We must instantiate the node from the file system.
    133          */
    134        
    135         assert(idxp->pfc);
     105static fat_node_t *fat_node_get_new(void)
     106{
     107        fat_node_t *nodep;
    136108
    137109        futex_down(&ffn_futex);
     
    163135        }
    164136        fat_node_initialize(nodep);
     137       
     138        return nodep;
     139}
     140
     141/** Internal version of fat_node_get().
     142 *
     143 * @param idxp          Locked index structure.
     144 */
     145static void *fat_node_get_core(fat_idx_t *idxp)
     146{
     147        block_t *b;
     148        fat_bs_t *bs;
     149        fat_dentry_t *d;
     150        fat_node_t *nodep = NULL;
     151        unsigned bps;
     152        unsigned spc;
     153        unsigned dps;
     154
     155        if (idxp->nodep) {
     156                /*
     157                 * We are lucky.
     158                 * The node is already instantiated in memory.
     159                 */
     160                futex_down(&idxp->nodep->lock);
     161                if (!idxp->nodep->refcnt++)
     162                        list_remove(&idxp->nodep->ffn_link);
     163                futex_up(&idxp->nodep->lock);
     164                return idxp->nodep;
     165        }
     166
     167        /*
     168         * We must instantiate the node from the file system.
     169         */
     170       
     171        assert(idxp->pfc);
     172
     173        nodep = fat_node_get_new();
     174        if (!nodep)
     175                return NULL;
    165176
    166177        bs = block_bb_get(idxp->dev_handle);
Note: See TracChangeset for help on using the changeset viewer.