Changeset c91f2d1b in mainline


Ignore:
Timestamp:
2009-08-27T18:31:27Z (15 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
cd688d9
Parents:
02ee6bf5
Message:

Enable the block_get() and block_put() APIs to return error.

Location:
uspace
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • uspace/app/bdsh/cmds/modules/bdd/bdd.c

    r02ee6bf5 rc91f2d1b  
    4040#include <devmap.h>
    4141#include <errno.h>
     42#include <assert.h>
    4243
    4344#define BLOCK_SIZE      512
     
    110111
    111112        while (size > 0) {
    112                 block = block_get(handle, boff, 0);
     113                rc = block_get(&block, handle, boff, 0);
     114                assert(rc == EOK);
    113115                blk = (uint8_t *) block->data;
    114116
     
    139141                }
    140142
    141                 block_put(block);
     143                rc = block_put(block);
     144                assert(rc == EOK);
    142145
    143146                if (size > rows * BPR)
  • uspace/lib/libblock/libblock.c

    r02ee6bf5 rc91f2d1b  
    313313/** Instantiate a block in memory and get a reference to it.
    314314 *
     315 * @param block                 Pointer to where the function will store the
     316 *                              block pointer on success.
    315317 * @param dev_handle            Device handle of the block device.
    316318 * @param boff                  Block offset.
     
    319321 *                              device.
    320322 *
    321  * @return                      Block structure.
    322  */
    323 block_t *block_get(dev_handle_t dev_handle, bn_t boff, int flags)
     323 * @return                      EOK on success or a negative error code.
     324 */
     325int block_get(block_t **block, dev_handle_t dev_handle, bn_t boff, int flags)
    324326{
    325327        devcon_t *devcon;
     
    450452                fibril_mutex_unlock(&b->lock);
    451453        }
    452         return b;
     454        *block = b;
     455        return EOK;
    453456}
    454457
     
    458461 *
    459462 * @param block         Block of which a reference is to be released.
    460  */
    461 void block_put(block_t *block)
     463 *
     464 * @return              EOK on success or a negative error code.
     465 */
     466int block_put(block_t *block)
    462467{
    463468        devcon_t *devcon = devcon_search(block->dev_handle);
     
    546551        fibril_mutex_unlock(&block->lock);
    547552        fibril_mutex_unlock(&cache->lock);
     553
     554        return EOK;
    548555}
    549556
  • uspace/lib/libblock/libblock.h

    r02ee6bf5 rc91f2d1b  
    101101extern int block_cache_init(dev_handle_t, size_t, unsigned, enum cache_mode);
    102102
    103 extern block_t *block_get(dev_handle_t, bn_t, int);
    104 extern void block_put(block_t *);
     103extern int block_get(block_t **, dev_handle_t, bn_t, int);
     104extern int block_put(block_t *);
    105105
    106106extern int block_seqread(dev_handle_t, off_t *, size_t *, off_t *, void *,
  • uspace/srv/fs/fat/fat_fat.c

    r02ee6bf5 rc91f2d1b  
    7575        uint16_t clusters = 0;
    7676        fat_cluster_t clst = firstc;
     77        int rc;
    7778
    7879        bps = uint16_t_le2host(bs->bps);
     
    9697                fidx = clst % (bps / sizeof(fat_cluster_t));
    9798                /* read FAT1 */
    98                 b = block_get(dev_handle, rscnt + fsec, BLOCK_FLAGS_NONE);
     99                rc = block_get(&b, dev_handle, rscnt + fsec, BLOCK_FLAGS_NONE);
     100                assert(rc == EOK);
    99101                clst = uint16_t_le2host(((fat_cluster_t *)b->data)[fidx]);
    100102                assert(clst != FAT_CLST_BAD);
    101                 block_put(b);
     103                rc = block_put(b);
     104                assert(rc == EOK);
    102105                clusters++;
    103106        }
     
    133136        unsigned clusters, max_clusters;
    134137        fat_cluster_t lastc;
     138        int rc;
    135139
    136140        bps = uint16_t_le2host(bs->bps);
     
    146150                /* root directory special case */
    147151                assert(bn < rds);
    148                 b = block_get(dev_handle, rscnt + bs->fatcnt * sf + bn, flags);
     152                rc = block_get(&b, dev_handle, rscnt + bs->fatcnt * sf + bn,
     153                    flags);
     154                assert(rc == EOK);
    149155                return b;
    150156        }
     
    155161        assert(clusters == max_clusters);
    156162
    157         b = block_get(dev_handle, ssa + (lastc - FAT_CLST_FIRST) * bs->spc +
    158             bn % bs->spc, flags);
     163        rc = block_get(&b, dev_handle, ssa +
     164            (lastc - FAT_CLST_FIRST) * bs->spc + bn % bs->spc, flags);
     165        assert(rc == EOK);
    159166
    160167        return b;
     
    177184        block_t *b;
    178185        off_t o, boundary;
     186        int rc;
    179187
    180188        bps = uint16_t_le2host(bs->bps);
     
    191199                memset(b->data + o % bps, 0, bps - o % bps);
    192200                b->dirty = true;                /* need to sync node */
    193                 block_put(b);
     201                rc = block_put(b);
     202                assert(rc == EOK);
    194203        }
    195204       
     
    203212                memset(b->data, 0, min(bps, pos - o));
    204213                b->dirty = true;                /* need to sync node */
    205                 block_put(b);
     214                rc = block_put(b);
     215                assert(rc == EOK);
    206216        }
    207217}
     
    222232        uint16_t rscnt;
    223233        fat_cluster_t *cp, value;
     234        int rc;
    224235
    225236        bps = uint16_t_le2host(bs->bps);
    226237        rscnt = uint16_t_le2host(bs->rscnt);
    227238
    228         b = block_get(dev_handle, rscnt + (clst * sizeof(fat_cluster_t)) / bps,
    229             BLOCK_FLAGS_NONE);
     239        rc = block_get(&b, dev_handle, rscnt +
     240            (clst * sizeof(fat_cluster_t)) / bps, BLOCK_FLAGS_NONE);
     241        assert(rc == EOK);
    230242        cp = (fat_cluster_t *)b->data + clst % (bps / sizeof(fat_cluster_t));
    231243        value = uint16_t_le2host(*cp);
    232         block_put(b);
     244        rc = block_put(b);
     245        assert(rc == EOK);
    233246       
    234247        return value;
     
    252265        uint16_t sf;
    253266        fat_cluster_t *cp;
     267        int rc;
    254268
    255269        bps = uint16_t_le2host(bs->bps);
     
    258272
    259273        assert(fatno < bs->fatcnt);
    260         b = block_get(dev_handle, rscnt + sf * fatno +
     274        rc = block_get(&b, dev_handle, rscnt + sf * fatno +
    261275            (clst * sizeof(fat_cluster_t)) / bps, BLOCK_FLAGS_NONE);
     276        assert(rc == EOK);
    262277        cp = (fat_cluster_t *)b->data + clst % (bps / sizeof(fat_cluster_t));
    263278        *cp = host2uint16_t_le(value);
    264279        b->dirty = true;                /* need to sync block */
    265         block_put(b);
     280        rc = block_put(b);
     281        assert(rc == EOK);
    266282}
    267283
     
    315331        unsigned found = 0;     /* top of the free cluster number stack */
    316332        unsigned b, c, cl;
     333        int rc;
    317334
    318335        lifo = (fat_cluster_t *) malloc(nclsts * sizeof(fat_cluster_t));
     
    329346        fibril_mutex_lock(&fat_alloc_lock);
    330347        for (b = 0, cl = 0; b < sf; b++) {
    331                 blk = block_get(dev_handle, rscnt + b, BLOCK_FLAGS_NONE);
     348                rc = block_get(&blk, dev_handle, rscnt + b, BLOCK_FLAGS_NONE);
    332349                for (c = 0; c < bps / sizeof(fat_cluster_t); c++, cl++) {
    333350                        fat_cluster_t *clst = (fat_cluster_t *)blk->data + c;
     
    344361                                if (++found == nclsts) {
    345362                                        /* we are almost done */
    346                                         block_put(blk);
     363                                        rc = block_put(blk);
     364                                        assert(rc == EOK);
    347365                                        /* update the shadow copies of FAT */
    348366                                        fat_alloc_shadow_clusters(bs,
     
    356374                        }
    357375                }
    358                 block_put(blk);
     376                rc = block_put(blk);
     377                assert(rc == EOK);
    359378        }
    360379        fibril_mutex_unlock(&fat_alloc_lock);
     
    457476        block_t *b;
    458477        unsigned bps;
     478        int rc;
    459479
    460480        bps = uint16_t_le2host(bs->bps);
     
    464484                memset(b->data, 0, bps);
    465485                b->dirty = true;
    466                 block_put(b);
     486                rc = block_put(b);
     487                assert(rc == EOK);
    467488        }
    468489}
  • uspace/srv/fs/fat/fat_ops.c

    r02ee6bf5 rc91f2d1b  
    8585        uint16_t bps;
    8686        unsigned dps;
     87        int rc;
    8788       
    8889        assert(node->dirty);
     
    108109       
    109110        b->dirty = true;                /* need to sync block */
    110         block_put(b);
     111        rc = block_put(b);
     112        assert(rc == EOK);
    111113}
    112114
     
    170172        unsigned spc;
    171173        unsigned dps;
     174        int rc;
    172175
    173176        if (idxp->nodep) {
     
    226229        nodep->refcnt = 1;
    227230
    228         block_put(b);
     231        rc = block_put(b);
     232        assert(rc == EOK);
    229233
    230234        /* Link the idx structure with the node structure. */
     
    443447                        }
    444448                }
    445                 block_put(b);
     449                rc = block_put(b);
     450                assert(rc == EOK);
    446451        }
    447452        j = 0;
     
    477482        fat_dentry_name_set(d, name);
    478483        b->dirty = true;                /* need to sync block */
    479         block_put(b);
     484        rc = block_put(b);
     485        assert(rc == EOK);
    480486        fibril_mutex_unlock(&parentp->idx->lock);
    481487
     
    512518        }
    513519        b->dirty = true;                /* need to sync block */
    514         block_put(b);
     520        rc = block_put(b);
     521        assert(rc == EOK);
    515522
    516523        childp->idx->pfc = parentp->firstc;
     
    539546        uint16_t bps;
    540547        block_t *b;
     548        int rc;
    541549
    542550        if (!parentp)
     
    561569        d->name[0] = FAT_DENTRY_ERASED;
    562570        b->dirty = true;                /* need to sync block */
    563         block_put(b);
     571        rc = block_put(b);
     572        assert(rc == EOK);
    564573
    565574        /* remove the index structure from the position hash */
     
    588597        fat_dentry_t *d;
    589598        block_t *b;
     599        int rc;
    590600
    591601        fibril_mutex_lock(&parentp->idx->lock);
     
    603613                                continue;
    604614                        case FAT_DENTRY_LAST:
    605                                 block_put(b);
     615                                rc = block_put(b);
     616                                assert(rc == EOK);
    606617                                fibril_mutex_unlock(&parentp->idx->lock);
    607618                                return NULL;
     
    629640                                         * run out of 32-bit indices.
    630641                                         */
    631                                         block_put(b);
     642                                        rc = block_put(b);
     643                                        assert(rc == EOK);
    632644                                        return NULL;
    633645                                }
    634646                                nodep = fat_node_get_core(idx);
    635647                                fibril_mutex_unlock(&idx->lock);
    636                                 block_put(b);
     648                                rc = block_put(b);
     649                                assert(rc == EOK);
    637650                                return FS_NODE(nodep);
    638651                        }
    639652                }
    640                 block_put(b);
     653                rc = block_put(b);
     654                assert(rc == EOK);
    641655        }
    642656
     
    669683        block_t *b;
    670684        unsigned i, j;
     685        int rc;
    671686
    672687        if (nodep->type != FAT_DIRECTORY)
     
    691706                                continue;
    692707                        case FAT_DENTRY_LAST:
    693                                 block_put(b);
     708                                rc = block_put(b);
     709                                assert(rc == EOK);
    694710                                fibril_mutex_unlock(&nodep->idx->lock);
    695711                                return false;
    696712                        default:
    697713                        case FAT_DENTRY_VALID:
    698                                 block_put(b);
     714                                rc = block_put(b);
     715                                assert(rc == EOK);
    699716                                fibril_mutex_unlock(&nodep->idx->lock);
    700717                                return true;
    701718                        }
    702                         block_put(b);
     719                        rc = block_put(b);
     720                        assert(rc == EOK);
    703721                        fibril_mutex_unlock(&nodep->idx->lock);
    704722                        return true;
    705723                }
    706                 block_put(b);
     724                rc = block_put(b);
     725                assert(rc == EOK);
    707726        }
    708727
     
    901920        size_t bytes;
    902921        block_t *b;
     922        int rc;
    903923
    904924        if (!fn) {
     
    937957                        (void) ipc_data_read_finalize(callid, b->data + pos % bps,
    938958                            bytes);
    939                         block_put(b);
     959                        rc = block_put(b);
     960                        assert(rc == EOK);
    940961                }
    941962        } else {
     
    969990                                        continue;
    970991                                case FAT_DENTRY_LAST:
    971                                         block_put(b);
     992                                        rc = block_put(b);
     993                                        assert(rc == EOK);
    972994                                        goto miss;
    973995                                default:
    974996                                case FAT_DENTRY_VALID:
    975997                                        fat_dentry_name_get(d, name);
    976                                         block_put(b);
     998                                        rc == block_put(b);
     999                                        assert(rc == EOK);
    9771000                                        goto hit;
    9781001                                }
    9791002                        }
    980                         block_put(b);
     1003                        rc = block_put(b);
     1004                        assert(rc == EOK);
    9811005                        bnum++;
    9821006                }
     
    10101034        off_t boundary;
    10111035        int flags = BLOCK_FLAGS_NONE;
     1036        int rc;
    10121037       
    10131038        if (!fn) {
     
    10551080                    bytes);
    10561081                b->dirty = true;                /* need to sync block */
    1057                 block_put(b);
     1082                rc = block_put(b);
     1083                assert(rc == EOK);
    10581084                if (pos + bytes > nodep->size) {
    10591085                        nodep->size = pos + bytes;
     
    10891115                    bytes);
    10901116                b->dirty = true;                /* need to sync block */
    1091                 block_put(b);
     1117                rc = block_put(b);
     1118                assert(rc == EOK);
    10921119                /*
    10931120                 * Append the cluster chain starting in mcl to the end of the
Note: See TracChangeset for help on using the changeset viewer.