Ignore:
File:
1 edited

Legend:

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

    rdb4ec8d r991f645  
    7070 *
    7171 * @param bs            Buffer holding the boot sector for the file.
    72  * @param dev_handle    Device handle of the device with the file.
     72 * @param devmap_handle Device handle of the device with the file.
    7373 * @param firstc        First cluster to start the walk with.
    7474 * @param lastc         If non-NULL, output argument hodling the last cluster
     
    8181 */
    8282int
    83 fat_cluster_walk(fat_bs_t *bs, dev_handle_t dev_handle, fat_cluster_t firstc,
     83fat_cluster_walk(fat_bs_t *bs, devmap_handle_t devmap_handle, fat_cluster_t firstc,
    8484    fat_cluster_t *lastc, uint16_t *numc, uint16_t max_clusters)
    8585{
     
    108108                fidx = clst % (BPS(bs) / sizeof(fat_cluster_t));
    109109                /* read FAT1 */
    110                 rc = block_get(&b, dev_handle, RSCNT(bs) + fsec,
     110                rc = block_get(&b, devmap_handle, RSCNT(bs) + fsec,
    111111                    BLOCK_FLAGS_NONE);
    112112                if (rc != EOK)
     
    159159                 * when fortunately we have the last cluster number cached.
    160160                 */
    161                 return block_get(block, nodep->idx->dev_handle,
     161                return block_get(block, nodep->idx->devmap_handle,
    162162                    CLBN2PBN(bs, nodep->lastc_cached_value, bn), flags);
    163163        }
     
    173173
    174174fall_through:
    175         rc = _fat_block_get(block, bs, nodep->idx->dev_handle, firstc,
     175        rc = _fat_block_get(block, bs, nodep->idx->devmap_handle, firstc,
    176176            &currc, relbn, flags);
    177177        if (rc != EOK)
     
    192192 * @param block         Pointer to a block pointer for storing result.
    193193 * @param bs            Buffer holding the boot sector of the file system.
    194  * @param dev_handle    Device handle of the file system.
     194 * @param devmap_handle Device handle of the file system.
    195195 * @param fcl           First cluster used by the file. Can be zero if the file
    196196 *                      is empty.
     
    204204 */
    205205int
    206 _fat_block_get(block_t **block, fat_bs_t *bs, dev_handle_t dev_handle,
     206_fat_block_get(block_t **block, fat_bs_t *bs, devmap_handle_t devmap_handle,
    207207    fat_cluster_t fcl, fat_cluster_t *clp, aoff64_t bn, int flags)
    208208{
     
    221221                /* root directory special case */
    222222                assert(bn < RDS(bs));
    223                 rc = block_get(block, dev_handle,
     223                rc = block_get(block, devmap_handle,
    224224                    RSCNT(bs) + FATCNT(bs) * SF(bs) + bn, flags);
    225225                return rc;
     
    227227
    228228        max_clusters = bn / SPC(bs);
    229         rc = fat_cluster_walk(bs, dev_handle, fcl, &c, &clusters, max_clusters);
     229        rc = fat_cluster_walk(bs, devmap_handle, fcl, &c, &clusters, max_clusters);
    230230        if (rc != EOK)
    231231                return rc;
    232232        assert(clusters == max_clusters);
    233233
    234         rc = block_get(block, dev_handle, CLBN2PBN(bs, c, bn), flags);
     234        rc = block_get(block, devmap_handle, CLBN2PBN(bs, c, bn), flags);
    235235
    236236        if (clp)
     
    280280        /* zero out the initial part of the new cluster chain */
    281281        for (o = boundary; o < pos; o += BPS(bs)) {
    282                 rc = _fat_block_get(&b, bs, nodep->idx->dev_handle, mcl,
     282                rc = _fat_block_get(&b, bs, nodep->idx->devmap_handle, mcl,
    283283                    NULL, (o - boundary) / BPS(bs), BLOCK_FLAGS_NOREAD);
    284284                if (rc != EOK)
     
    297297 *
    298298 * @param bs            Buffer holding the boot sector for the file system.
    299  * @param dev_handle    Device handle for the file system.
     299 * @param devmap_handle Device handle for the file system.
    300300 * @param clst          Cluster which to get.
    301301 * @param value         Output argument holding the value of the cluster.
     
    304304 */
    305305int
    306 fat_get_cluster(fat_bs_t *bs, dev_handle_t dev_handle, unsigned fatno,
     306fat_get_cluster(fat_bs_t *bs, devmap_handle_t devmap_handle, unsigned fatno,
    307307    fat_cluster_t clst, fat_cluster_t *value)
    308308{
     
    311311        int rc;
    312312
    313         rc = block_get(&b, dev_handle, RSCNT(bs) + SF(bs) * fatno +
     313        rc = block_get(&b, devmap_handle, RSCNT(bs) + SF(bs) * fatno +
    314314            (clst * sizeof(fat_cluster_t)) / BPS(bs), BLOCK_FLAGS_NONE);
    315315        if (rc != EOK)
     
    326326 *
    327327 * @param bs            Buffer holding the boot sector for the file system.
    328  * @param dev_handle    Device handle for the file system.
     328 * @param devmap_handle Device handle for the file system.
    329329 * @param fatno         Number of the FAT instance where to make the change.
    330330 * @param clst          Cluster which is to be set.
     
    334334 */
    335335int
    336 fat_set_cluster(fat_bs_t *bs, dev_handle_t dev_handle, unsigned fatno,
     336fat_set_cluster(fat_bs_t *bs, devmap_handle_t devmap_handle, unsigned fatno,
    337337    fat_cluster_t clst, fat_cluster_t value)
    338338{
     
    342342
    343343        assert(fatno < FATCNT(bs));
    344         rc = block_get(&b, dev_handle, RSCNT(bs) + SF(bs) * fatno +
     344        rc = block_get(&b, devmap_handle, RSCNT(bs) + SF(bs) * fatno +
    345345            (clst * sizeof(fat_cluster_t)) / BPS(bs), BLOCK_FLAGS_NONE);
    346346        if (rc != EOK)
     
    357357 *
    358358 * @param bs            Buffer holding the boot sector of the file system.
    359  * @param dev_handle    Device handle of the file system.
     359 * @param devmap_handle Device handle of the file system.
    360360 * @param lifo          Chain of allocated clusters.
    361361 * @param nclsts        Number of clusters in the lifo chain.
     
    363363 * @return              EOK on success or a negative error code.
    364364 */
    365 int fat_alloc_shadow_clusters(fat_bs_t *bs, dev_handle_t dev_handle,
     365int fat_alloc_shadow_clusters(fat_bs_t *bs, devmap_handle_t devmap_handle,
    366366    fat_cluster_t *lifo, unsigned nclsts)
    367367{
     
    372372        for (fatno = FAT1 + 1; fatno < bs->fatcnt; fatno++) {
    373373                for (c = 0; c < nclsts; c++) {
    374                         rc = fat_set_cluster(bs, dev_handle, fatno, lifo[c],
     374                        rc = fat_set_cluster(bs, devmap_handle, fatno, lifo[c],
    375375                            c == 0 ? FAT_CLST_LAST1 : lifo[c - 1]);
    376376                        if (rc != EOK)
     
    390390 *
    391391 * @param bs            Buffer holding the boot sector of the file system.
    392  * @param dev_handle    Device handle of the file system.
     392 * @param devmap_handle Device handle of the file system.
    393393 * @param nclsts        Number of clusters to allocate.
    394394 * @param mcl           Output parameter where the first cluster in the chain
     
    400400 */
    401401int
    402 fat_alloc_clusters(fat_bs_t *bs, dev_handle_t dev_handle, unsigned nclsts,
     402fat_alloc_clusters(fat_bs_t *bs, devmap_handle_t devmap_handle, unsigned nclsts,
    403403    fat_cluster_t *mcl, fat_cluster_t *lcl)
    404404{
     
    418418        fibril_mutex_lock(&fat_alloc_lock);
    419419        for (b = 0, cl = 0; b < SF(bs); b++) {
    420                 rc = block_get(&blk, dev_handle, RSCNT(bs) + b,
     420                rc = block_get(&blk, devmap_handle, RSCNT(bs) + b,
    421421                    BLOCK_FLAGS_NONE);
    422422                if (rc != EOK)
     
    457457                                        /* update the shadow copies of FAT */
    458458                                        rc = fat_alloc_shadow_clusters(bs,
    459                                             dev_handle, lifo, nclsts);
     459                                            devmap_handle, lifo, nclsts);
    460460                                        if (rc != EOK)
    461461                                                goto error;
     
    484484         */
    485485        while (found--) {
    486                 rc = fat_set_cluster(bs, dev_handle, FAT1, lifo[found],
     486                rc = fat_set_cluster(bs, devmap_handle, FAT1, lifo[found],
    487487                    FAT_CLST_RES0);
    488488                if (rc != EOK) {
     
    499499 *
    500500 * @param bs            Buffer hodling the boot sector of the file system.
    501  * @param dev_handle    Device handle of the file system.
     501 * @param devmap_handle Device handle of the file system.
    502502 * @param firstc        First cluster in the chain which is to be freed.
    503503 *
     
    505505 */
    506506int
    507 fat_free_clusters(fat_bs_t *bs, dev_handle_t dev_handle, fat_cluster_t firstc)
     507fat_free_clusters(fat_bs_t *bs, devmap_handle_t devmap_handle, fat_cluster_t firstc)
    508508{
    509509        unsigned fatno;
     
    514514        while (firstc < FAT_CLST_LAST1) {
    515515                assert(firstc >= FAT_CLST_FIRST && firstc < FAT_CLST_BAD);
    516                 rc = fat_get_cluster(bs, dev_handle, FAT1, firstc, &nextc);
     516                rc = fat_get_cluster(bs, devmap_handle, FAT1, firstc, &nextc);
    517517                if (rc != EOK)
    518518                        return rc;
    519519                for (fatno = FAT1; fatno < bs->fatcnt; fatno++) {
    520                         rc = fat_set_cluster(bs, dev_handle, fatno, firstc,
     520                        rc = fat_set_cluster(bs, devmap_handle, fatno, firstc,
    521521                            FAT_CLST_RES0);
    522522                        if (rc != EOK)
     
    543543    fat_cluster_t lcl)
    544544{
    545         dev_handle_t dev_handle = nodep->idx->dev_handle;
     545        devmap_handle_t devmap_handle = nodep->idx->devmap_handle;
    546546        fat_cluster_t lastc;
    547547        uint8_t fatno;
     
    557557                        nodep->lastc_cached_valid = false;
    558558                } else {
    559                         rc = fat_cluster_walk(bs, dev_handle, nodep->firstc,
     559                        rc = fat_cluster_walk(bs, devmap_handle, nodep->firstc,
    560560                            &lastc, NULL, (uint16_t) -1);
    561561                        if (rc != EOK)
     
    564564
    565565                for (fatno = FAT1; fatno < bs->fatcnt; fatno++) {
    566                         rc = fat_set_cluster(bs, nodep->idx->dev_handle, fatno,
     566                        rc = fat_set_cluster(bs, nodep->idx->devmap_handle, fatno,
    567567                            lastc, mcl);
    568568                        if (rc != EOK)
     
    590590{
    591591        int rc;
    592         dev_handle_t dev_handle = nodep->idx->dev_handle;
     592        devmap_handle_t devmap_handle = nodep->idx->devmap_handle;
    593593
    594594        /*
     
    601601        if (lcl == FAT_CLST_RES0) {
    602602                /* The node will have zero size and no clusters allocated. */
    603                 rc = fat_free_clusters(bs, dev_handle, nodep->firstc);
     603                rc = fat_free_clusters(bs, devmap_handle, nodep->firstc);
    604604                if (rc != EOK)
    605605                        return rc;
     
    610610                unsigned fatno;
    611611
    612                 rc = fat_get_cluster(bs, dev_handle, FAT1, lcl, &nextc);
     612                rc = fat_get_cluster(bs, devmap_handle, FAT1, lcl, &nextc);
    613613                if (rc != EOK)
    614614                        return rc;
     
    616616                /* Terminate the cluster chain in all copies of FAT. */
    617617                for (fatno = FAT1; fatno < bs->fatcnt; fatno++) {
    618                         rc = fat_set_cluster(bs, dev_handle, fatno, lcl,
     618                        rc = fat_set_cluster(bs, devmap_handle, fatno, lcl,
    619619                            FAT_CLST_LAST1);
    620620                        if (rc != EOK)
     
    623623
    624624                /* Free all following clusters. */
    625                 rc = fat_free_clusters(bs, dev_handle, nextc);
     625                rc = fat_free_clusters(bs, devmap_handle, nextc);
    626626                if (rc != EOK)
    627627                        return rc;
     
    638638
    639639int
    640 fat_zero_cluster(struct fat_bs *bs, dev_handle_t dev_handle, fat_cluster_t c)
     640fat_zero_cluster(struct fat_bs *bs, devmap_handle_t devmap_handle, fat_cluster_t c)
    641641{
    642642        int i;
     
    645645
    646646        for (i = 0; i < SPC(bs); i++) {
    647                 rc = _fat_block_get(&b, bs, dev_handle, c, NULL, i,
     647                rc = _fat_block_get(&b, bs, devmap_handle, c, NULL, i,
    648648                    BLOCK_FLAGS_NOREAD);
    649649                if (rc != EOK)
     
    665665 * does not contain a fat file system.
    666666 */
    667 int fat_sanity_check(fat_bs_t *bs, dev_handle_t dev_handle)
     667int fat_sanity_check(fat_bs_t *bs, devmap_handle_t devmap_handle)
    668668{
    669669        fat_cluster_t e0, e1;
     
    706706
    707707        for (fat_no = 0; fat_no < bs->fatcnt; fat_no++) {
    708                 rc = fat_get_cluster(bs, dev_handle, fat_no, 0, &e0);
     708                rc = fat_get_cluster(bs, devmap_handle, fat_no, 0, &e0);
    709709                if (rc != EOK)
    710710                        return EIO;
    711711
    712                 rc = fat_get_cluster(bs, dev_handle, fat_no, 1, &e1);
     712                rc = fat_get_cluster(bs, devmap_handle, fat_no, 1, &e1);
    713713                if (rc != EOK)
    714714                        return EIO;
Note: See TracChangeset for help on using the changeset viewer.