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


Ignore:
Timestamp:
2008-10-27T12:45:08Z (16 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
0ec862d
Parents:
e17d986
Message:

Pass the buffer holding the boot sector to the internal functions so that it
doesn't have to be block_get()'ed in each function. The idea is that the boot
block should be read by the top-level functions in fat_ops.c and passed down the
call chain.

File:
1 edited

Legend:

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

    re17d986 rcb682eb  
    126126static void *fat_node_get_core(fat_idx_t *idxp)
    127127{
    128         block_t *b;
     128        block_t *bb, *b;
    129129        fat_dentry_t *d;
    130130        fat_node_t *nodep = NULL;
     
    179179        fat_node_initialize(nodep);
    180180
    181         bps = fat_bps_get(idxp->dev_handle);
     181        bb = block_get(idxp->dev_handle, BS_BLOCK, BS_SIZE);
     182        bps = uint16_t_le2host(FAT_BS(bb)->bps);
    182183        dps = bps / sizeof(fat_dentry_t);
    183184
    184185        /* Read the block that contains the dentry of interest. */
    185         b = _fat_block_get(idxp->dev_handle, idxp->pfc,
     186        b = _fat_block_get(bb->data, idxp->dev_handle, idxp->pfc,
    186187            (idxp->pdi * sizeof(fat_dentry_t)) / bps);
    187188        assert(b);
     
    200201                 * size of the directory by walking the FAT.
    201202                 */
    202                 nodep->size = bps * _fat_blcks_get(idxp->dev_handle,
     203                nodep->size = bps * _fat_blcks_get(bb->data, idxp->dev_handle,
    203204                    uint16_t_le2host(d->firstc), NULL);
    204205        } else {
     
    211212
    212213        block_put(b);
     214        block_put(bb);
    213215
    214216        /* Link the idx structure with the node structure. */
     
    276278        unsigned blocks;
    277279        fat_dentry_t *d;
    278         block_t *b;
     280        block_t *bb, *b;
    279281
    280282        futex_down(&parentp->idx->lock);
    281         bps = fat_bps_get(parentp->idx->dev_handle);
     283        bb = block_get(parentp->idx->dev_handle, BS_BLOCK, BS_SIZE);
     284        bps = uint16_t_le2host(FAT_BS(bb)->bps);
    282285        dps = bps / sizeof(fat_dentry_t);
    283286        blocks = parentp->size / bps + (parentp->size % bps != 0);
     
    285288                unsigned dentries;
    286289               
    287                 b = fat_block_get(parentp, i);
     290                b = fat_block_get(bb->data, parentp, i);
    288291                dentries = (i == blocks - 1) ?
    289292                    parentp->size % sizeof(fat_dentry_t) :
     
    296299                        case FAT_DENTRY_LAST:
    297300                                block_put(b);
     301                                block_put(bb);
    298302                                futex_up(&parentp->idx->lock);
    299303                                return NULL;
     
    322326                                         */
    323327                                        block_put(b);
     328                                        block_put(bb);
    324329                                        return NULL;
    325330                                }
     
    327332                                futex_up(&idx->lock);
    328333                                block_put(b);
     334                                block_put(bb);
    329335                                return node;
    330336                        }
     
    332338                block_put(b);
    333339        }
     340        block_put(bb);
     341
    334342        futex_up(&parentp->idx->lock);
    335343        return NULL;
     
    360368        unsigned dps;
    361369        unsigned blocks;
    362         block_t *b;
     370        block_t *bb, *b;
    363371        unsigned i, j;
    364372
     
    367375
    368376        futex_down(&nodep->idx->lock);
    369         bps = fat_bps_get(nodep->idx->dev_handle);
     377        bb = block_get(nodep->idx->dev_handle, BS_BLOCK, BS_SIZE);
     378        bps = uint16_t_le2host(FAT_BS(bb)->bps);
    370379        dps = bps / sizeof(fat_dentry_t);
    371380
     
    376385                fat_dentry_t *d;
    377386       
    378                 b = fat_block_get(nodep, i);
     387                b = fat_block_get(bb->data, nodep, i);
    379388                dentries = (i == blocks - 1) ?
    380389                    nodep->size % sizeof(fat_dentry_t) :
     
    387396                        case FAT_DENTRY_LAST:
    388397                                block_put(b);
     398                                block_put(bb);
    389399                                futex_up(&nodep->idx->lock);
    390400                                return false;
     
    392402                        case FAT_DENTRY_VALID:
    393403                                block_put(b);
     404                                block_put(bb);
    394405                                futex_up(&nodep->idx->lock);
    395406                                return true;
    396407                        }
    397408                        block_put(b);
     409                        block_put(bb);
    398410                        futex_up(&nodep->idx->lock);
    399411                        return true;
     
    401413                block_put(b);
    402414        }
     415        block_put(bb);
    403416
    404417        futex_up(&nodep->idx->lock);
     
    553566        off_t pos = (off_t)IPC_GET_ARG3(*request);
    554567        fat_node_t *nodep = (fat_node_t *)fat_node_get(dev_handle, index);
    555         uint16_t bps = fat_bps_get(dev_handle);
     568        uint16_t bps;
    556569        size_t bytes;
    557         block_t *b;
     570        block_t *bb, *b;
    558571
    559572        if (!nodep) {
     
    570583                return;
    571584        }
     585
     586        bb = block_get(dev_handle, BS_BLOCK, BS_SIZE);
     587        bps = uint16_t_le2host(FAT_BS(bb)->bps);
    572588
    573589        if (nodep->type == FAT_FILE) {
     
    578594                 */
    579595                bytes = min(len, bps - pos % bps);
    580                 b = fat_block_get(nodep, pos / bps);
     596                b = fat_block_get(bb->data, nodep, pos / bps);
    581597                (void) ipc_data_read_finalize(callid, b->data + pos % bps,
    582598                    bytes);
     
    602618                        off_t o;
    603619
    604                         b = fat_block_get(nodep, bnum);
     620                        b = fat_block_get(bb->data, nodep, bnum);
    605621                        for (o = pos % (bps / sizeof(fat_dentry_t));
    606622                            o < bps / sizeof(fat_dentry_t);
     
    625641miss:
    626642                fat_node_put(nodep);
     643                block_put(bb);
    627644                ipc_answer_0(callid, ENOENT);
    628645                ipc_answer_1(rid, ENOENT, 0);
     
    634651
    635652        fat_node_put(nodep);
     653        block_put(bb);
    636654        ipc_answer_1(rid, EOK, (ipcarg_t)bytes);
    637655}
     
    682700        bps = uint16_t_le2host(FAT_BS(bb)->bps);
    683701        spc = FAT_BS(bb)->spc;
    684         block_put(bb);
    685702       
    686703        boundary = ROUND_UP(nodep->size, bps * spc);
     
    692709                 * next block size boundary.
    693710                 */
    694                 fat_fill_gap(nodep, FAT_CLST_RES0, pos);
    695                 b = fat_block_get(nodep, pos / bps);
     711                fat_fill_gap(bb->data, nodep, FAT_CLST_RES0, pos);
     712                b = fat_block_get(bb->data, nodep, pos / bps);
    696713                (void) ipc_data_write_finalize(callid, b->data + pos % bps,
    697714                    bytes);
     
    703720                }
    704721                fat_node_put(nodep);
     722                block_put(bb);
    705723                ipc_answer_1(rid, EOK, bytes); 
    706724                return;
     
    717735                    bps * spc;
    718736                /* create an independent chain of nclsts clusters in all FATs */
    719                 status = fat_alloc_clusters(dev_handle, nclsts, &mcl, &lcl);
     737                status = fat_alloc_clusters(bb->data, dev_handle, nclsts, &mcl,
     738                    &lcl);
    720739                if (status != EOK) {
    721740                        /* could not allocate a chain of nclsts clusters */
    722741                        fat_node_put(nodep);
     742                        block_put(bb);
    723743                        ipc_answer_0(callid, status);
    724744                        ipc_answer_0(rid, status);
     
    726746                }
    727747                /* zero fill any gaps */
    728                 fat_fill_gap(nodep, mcl, pos);
    729                 b = _fat_block_get(dev_handle, lcl, (pos / bps) % spc);
     748                fat_fill_gap(bb->data, nodep, mcl, pos);
     749                b = _fat_block_get(bb->data, dev_handle, lcl,
     750                    (pos / bps) % spc);
    730751                (void) ipc_data_write_finalize(callid, b->data + pos % bps,
    731752                    bytes);
     
    736757                 * node's cluster chain.
    737758                 */
    738                 fat_append_clusters(nodep, mcl);
     759                fat_append_clusters(bb->data, nodep, mcl);
    739760                nodep->size = pos + bytes;
    740761                nodep->dirty = true;            /* need to sync node */
    741762                fat_node_put(nodep);
     763                block_put(bb);
    742764                ipc_answer_1(rid, EOK, bytes);
    743765                return;
Note: See TracChangeset for help on using the changeset viewer.