Fork us on GitHub Follow us on Facebook Follow us on Twitter

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


Ignore:
Timestamp:
2010-11-18T18:23:43Z (11 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master
Children:
3f0a7971, a7811f17, cb569e6
Parents:
51a268f (diff), c63e70c (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge changes that aim to do a better job in differentiating between
dev_handle_t and device_handle_t, respectively, by renaming these types to
devmap_handle_t and devman_handle_t, respectively.

File:
1 edited

Legend:

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

    r51a268f r45f04f8  
    7272 * Forward declarations of FAT libfs operations.
    7373 */
    74 static int fat_root_get(fs_node_t **, dev_handle_t);
     74static int fat_root_get(fs_node_t **, devmap_handle_t);
    7575static int fat_match(fs_node_t **, fs_node_t *, const char *);
    76 static int fat_node_get(fs_node_t **, dev_handle_t, fs_index_t);
     76static int fat_node_get(fs_node_t **, devmap_handle_t, fs_index_t);
    7777static int fat_node_open(fs_node_t *);
    7878static int fat_node_put(fs_node_t *);
    79 static int fat_create_node(fs_node_t **, dev_handle_t, int);
     79static int fat_create_node(fs_node_t **, devmap_handle_t, int);
    8080static int fat_destroy_node(fs_node_t *);
    8181static int fat_link(fs_node_t *, fs_node_t *, const char *);
     
    8888static bool fat_is_directory(fs_node_t *);
    8989static bool fat_is_file(fs_node_t *node);
    90 static dev_handle_t fat_device_get(fs_node_t *node);
     90static devmap_handle_t fat_device_get(fs_node_t *node);
    9191
    9292/*
     
    120120        assert(node->dirty);
    121121
    122         bs = block_bb_get(node->idx->dev_handle);
     122        bs = block_bb_get(node->idx->devmap_handle);
    123123       
    124124        /* Read the block that contains the dentry of interest. */
    125         rc = _fat_block_get(&b, bs, node->idx->dev_handle, node->idx->pfc,
     125        rc = _fat_block_get(&b, bs, node->idx->devmap_handle, node->idx->pfc,
    126126            NULL, (node->idx->pdi * sizeof(fat_dentry_t)) / BPS(bs),
    127127            BLOCK_FLAGS_NONE);
     
    145145}
    146146
    147 static int fat_node_fini_by_dev_handle(dev_handle_t dev_handle)
     147static int fat_node_fini_by_devmap_handle(devmap_handle_t devmap_handle)
    148148{
    149149        link_t *lnk;
     
    170170                        goto restart;
    171171                }
    172                 if (nodep->idx->dev_handle != dev_handle) {
     172                if (nodep->idx->devmap_handle != devmap_handle) {
    173173                        fibril_mutex_unlock(&nodep->idx->lock);
    174174                        fibril_mutex_unlock(&nodep->lock);
     
    299299                return rc;
    300300
    301         bs = block_bb_get(idxp->dev_handle);
     301        bs = block_bb_get(idxp->devmap_handle);
    302302
    303303        /* Read the block that contains the dentry of interest. */
    304         rc = _fat_block_get(&b, bs, idxp->dev_handle, idxp->pfc, NULL,
     304        rc = _fat_block_get(&b, bs, idxp->devmap_handle, idxp->pfc, NULL,
    305305            (idxp->pdi * sizeof(fat_dentry_t)) / BPS(bs), BLOCK_FLAGS_NONE);
    306306        if (rc != EOK) {
     
    323323                 */
    324324                uint16_t clusters;
    325                 rc = fat_clusters_get(&clusters, bs, idxp->dev_handle,
     325                rc = fat_clusters_get(&clusters, bs, idxp->devmap_handle,
    326326                    uint16_t_le2host(d->firstc));
    327327                if (rc != EOK) {
     
    356356 */
    357357
    358 int fat_root_get(fs_node_t **rfn, dev_handle_t dev_handle)
    359 {
    360         return fat_node_get(rfn, dev_handle, 0);
     358int fat_root_get(fs_node_t **rfn, devmap_handle_t devmap_handle)
     359{
     360        return fat_node_get(rfn, devmap_handle, 0);
    361361}
    362362
     
    369369        unsigned blocks;
    370370        fat_dentry_t *d;
    371         dev_handle_t dev_handle;
     371        devmap_handle_t devmap_handle;
    372372        block_t *b;
    373373        int rc;
    374374
    375375        fibril_mutex_lock(&parentp->idx->lock);
    376         dev_handle = parentp->idx->dev_handle;
     376        devmap_handle = parentp->idx->devmap_handle;
    377377        fibril_mutex_unlock(&parentp->idx->lock);
    378378
    379         bs = block_bb_get(dev_handle);
     379        bs = block_bb_get(devmap_handle);
    380380        blocks = parentp->size / BPS(bs);
    381381        for (i = 0; i < blocks; i++) {
     
    402402                                /* hit */
    403403                                fat_node_t *nodep;
    404                                 fat_idx_t *idx = fat_idx_get_by_pos(dev_handle,
     404                                fat_idx_t *idx = fat_idx_get_by_pos(devmap_handle,
    405405                                    parentp->firstc, i * DPS(bs) + j);
    406406                                if (!idx) {
     
    435435
    436436/** Instantiate a FAT in-core node. */
    437 int fat_node_get(fs_node_t **rfn, dev_handle_t dev_handle, fs_index_t index)
     437int fat_node_get(fs_node_t **rfn, devmap_handle_t devmap_handle, fs_index_t index)
    438438{
    439439        fat_node_t *nodep;
     
    441441        int rc;
    442442
    443         idxp = fat_idx_get_by_index(dev_handle, index);
     443        idxp = fat_idx_get_by_index(devmap_handle, index);
    444444        if (!idxp) {
    445445                *rfn = NULL;
     
    492492}
    493493
    494 int fat_create_node(fs_node_t **rfn, dev_handle_t dev_handle, int flags)
     494int fat_create_node(fs_node_t **rfn, devmap_handle_t devmap_handle, int flags)
    495495{
    496496        fat_idx_t *idxp;
     
    500500        int rc;
    501501
    502         bs = block_bb_get(dev_handle);
     502        bs = block_bb_get(devmap_handle);
    503503        if (flags & L_DIRECTORY) {
    504504                /* allocate a cluster */
    505                 rc = fat_alloc_clusters(bs, dev_handle, 1, &mcl, &lcl);
     505                rc = fat_alloc_clusters(bs, devmap_handle, 1, &mcl, &lcl);
    506506                if (rc != EOK)
    507507                        return rc;
    508508                /* populate the new cluster with unused dentries */
    509                 rc = fat_zero_cluster(bs, dev_handle, mcl);
     509                rc = fat_zero_cluster(bs, devmap_handle, mcl);
    510510                if (rc != EOK) {
    511                         (void) fat_free_clusters(bs, dev_handle, mcl);
     511                        (void) fat_free_clusters(bs, devmap_handle, mcl);
    512512                        return rc;
    513513                }
     
    516516        rc = fat_node_get_new(&nodep);
    517517        if (rc != EOK) {
    518                 (void) fat_free_clusters(bs, dev_handle, mcl);
     518                (void) fat_free_clusters(bs, devmap_handle, mcl);
    519519                return rc;
    520520        }
    521         rc = fat_idx_get_new(&idxp, dev_handle);
    522         if (rc != EOK) {
    523                 (void) fat_free_clusters(bs, dev_handle, mcl); 
     521        rc = fat_idx_get_new(&idxp, devmap_handle);
     522        if (rc != EOK) {
     523                (void) fat_free_clusters(bs, devmap_handle, mcl);       
    524524                (void) fat_node_put(FS_NODE(nodep));
    525525                return rc;
     
    570570        assert(!has_children);
    571571
    572         bs = block_bb_get(nodep->idx->dev_handle);
     572        bs = block_bb_get(nodep->idx->devmap_handle);
    573573        if (nodep->firstc != FAT_CLST_RES0) {
    574574                assert(nodep->size);
    575575                /* Free all clusters allocated to the node. */
    576                 rc = fat_free_clusters(bs, nodep->idx->dev_handle,
     576                rc = fat_free_clusters(bs, nodep->idx->devmap_handle,
    577577                    nodep->firstc);
    578578        }
     
    620620       
    621621        fibril_mutex_lock(&parentp->idx->lock);
    622         bs = block_bb_get(parentp->idx->dev_handle);
     622        bs = block_bb_get(parentp->idx->devmap_handle);
    623623
    624624        blocks = parentp->size / BPS(bs);
     
    659659                return ENOSPC;
    660660        }
    661         rc = fat_alloc_clusters(bs, parentp->idx->dev_handle, 1, &mcl, &lcl);
     661        rc = fat_alloc_clusters(bs, parentp->idx->devmap_handle, 1, &mcl, &lcl);
    662662        if (rc != EOK) {
    663663                fibril_mutex_unlock(&parentp->idx->lock);
    664664                return rc;
    665665        }
    666         rc = fat_zero_cluster(bs, parentp->idx->dev_handle, mcl);
    667         if (rc != EOK) {
    668                 (void) fat_free_clusters(bs, parentp->idx->dev_handle, mcl);
     666        rc = fat_zero_cluster(bs, parentp->idx->devmap_handle, mcl);
     667        if (rc != EOK) {
     668                (void) fat_free_clusters(bs, parentp->idx->devmap_handle, mcl);
    669669                fibril_mutex_unlock(&parentp->idx->lock);
    670670                return rc;
     
    672672        rc = fat_append_clusters(bs, parentp, mcl, lcl);
    673673        if (rc != EOK) {
    674                 (void) fat_free_clusters(bs, parentp->idx->dev_handle, mcl);
     674                (void) fat_free_clusters(bs, parentp->idx->devmap_handle, mcl);
    675675                fibril_mutex_unlock(&parentp->idx->lock);
    676676                return rc;
     
    789789        assert(childp->lnkcnt == 1);
    790790        fibril_mutex_lock(&childp->idx->lock);
    791         bs = block_bb_get(childp->idx->dev_handle);
    792 
    793         rc = _fat_block_get(&b, bs, childp->idx->dev_handle, childp->idx->pfc,
     791        bs = block_bb_get(childp->idx->devmap_handle);
     792
     793        rc = _fat_block_get(&b, bs, childp->idx->devmap_handle, childp->idx->pfc,
    794794            NULL, (childp->idx->pdi * sizeof(fat_dentry_t)) / BPS(bs),
    795795            BLOCK_FLAGS_NONE);
     
    840840       
    841841        fibril_mutex_lock(&nodep->idx->lock);
    842         bs = block_bb_get(nodep->idx->dev_handle);
     842        bs = block_bb_get(nodep->idx->devmap_handle);
    843843
    844844        blocks = nodep->size / BPS(bs);
     
    914914}
    915915
    916 dev_handle_t fat_device_get(fs_node_t *node)
     916devmap_handle_t fat_device_get(fs_node_t *node)
    917917{
    918918        return 0;
     
    946946void fat_mounted(ipc_callid_t rid, ipc_call_t *request)
    947947{
    948         dev_handle_t dev_handle = (dev_handle_t) IPC_GET_ARG1(*request);
     948        devmap_handle_t devmap_handle = (devmap_handle_t) IPC_GET_ARG1(*request);
    949949        enum cache_mode cmode;
    950950        fat_bs_t *bs;
     
    968968
    969969        /* initialize libblock */
    970         rc = block_init(dev_handle, BS_SIZE);
     970        rc = block_init(devmap_handle, BS_SIZE);
    971971        if (rc != EOK) {
    972972                ipc_answer_0(rid, rc);
     
    975975
    976976        /* prepare the boot block */
    977         rc = block_bb_read(dev_handle, BS_BLOCK);
    978         if (rc != EOK) {
    979                 block_fini(dev_handle);
     977        rc = block_bb_read(devmap_handle, BS_BLOCK);
     978        if (rc != EOK) {
     979                block_fini(devmap_handle);
    980980                ipc_answer_0(rid, rc);
    981981                return;
     
    983983
    984984        /* get the buffer with the boot sector */
    985         bs = block_bb_get(dev_handle);
     985        bs = block_bb_get(devmap_handle);
    986986       
    987987        if (BPS(bs) != BS_SIZE) {
    988                 block_fini(dev_handle);
     988                block_fini(devmap_handle);
    989989                ipc_answer_0(rid, ENOTSUP);
    990990                return;
     
    992992
    993993        /* Initialize the block cache */
    994         rc = block_cache_init(dev_handle, BPS(bs), 0 /* XXX */, cmode);
    995         if (rc != EOK) {
    996                 block_fini(dev_handle);
     994        rc = block_cache_init(devmap_handle, BPS(bs), 0 /* XXX */, cmode);
     995        if (rc != EOK) {
     996                block_fini(devmap_handle);
    997997                ipc_answer_0(rid, rc);
    998998                return;
     
    10001000
    10011001        /* Do some simple sanity checks on the file system. */
    1002         rc = fat_sanity_check(bs, dev_handle);
    1003         if (rc != EOK) {
    1004                 (void) block_cache_fini(dev_handle);
    1005                 block_fini(dev_handle);
     1002        rc = fat_sanity_check(bs, devmap_handle);
     1003        if (rc != EOK) {
     1004                (void) block_cache_fini(devmap_handle);
     1005                block_fini(devmap_handle);
    10061006                ipc_answer_0(rid, rc);
    10071007                return;
    10081008        }
    10091009
    1010         rc = fat_idx_init_by_dev_handle(dev_handle);
    1011         if (rc != EOK) {
    1012                 (void) block_cache_fini(dev_handle);
    1013                 block_fini(dev_handle);
     1010        rc = fat_idx_init_by_devmap_handle(devmap_handle);
     1011        if (rc != EOK) {
     1012                (void) block_cache_fini(devmap_handle);
     1013                block_fini(devmap_handle);
    10141014                ipc_answer_0(rid, rc);
    10151015                return;
     
    10191019        fs_node_t *rfn = (fs_node_t *)malloc(sizeof(fs_node_t));
    10201020        if (!rfn) {
    1021                 (void) block_cache_fini(dev_handle);
    1022                 block_fini(dev_handle);
    1023                 fat_idx_fini_by_dev_handle(dev_handle);
     1021                (void) block_cache_fini(devmap_handle);
     1022                block_fini(devmap_handle);
     1023                fat_idx_fini_by_devmap_handle(devmap_handle);
    10241024                ipc_answer_0(rid, ENOMEM);
    10251025                return;
     
    10291029        if (!rootp) {
    10301030                free(rfn);
    1031                 (void) block_cache_fini(dev_handle);
    1032                 block_fini(dev_handle);
    1033                 fat_idx_fini_by_dev_handle(dev_handle);
     1031                (void) block_cache_fini(devmap_handle);
     1032                block_fini(devmap_handle);
     1033                fat_idx_fini_by_devmap_handle(devmap_handle);
    10341034                ipc_answer_0(rid, ENOMEM);
    10351035                return;
     
    10371037        fat_node_initialize(rootp);
    10381038
    1039         fat_idx_t *ridxp = fat_idx_get_by_pos(dev_handle, FAT_CLST_ROOTPAR, 0);
     1039        fat_idx_t *ridxp = fat_idx_get_by_pos(devmap_handle, FAT_CLST_ROOTPAR, 0);
    10401040        if (!ridxp) {
    10411041                free(rfn);
    10421042                free(rootp);
    1043                 (void) block_cache_fini(dev_handle);
    1044                 block_fini(dev_handle);
    1045                 fat_idx_fini_by_dev_handle(dev_handle);
     1043                (void) block_cache_fini(devmap_handle);
     1044                block_fini(devmap_handle);
     1045                fat_idx_fini_by_devmap_handle(devmap_handle);
    10461046                ipc_answer_0(rid, ENOMEM);
    10471047                return;
     
    10721072void fat_unmounted(ipc_callid_t rid, ipc_call_t *request)
    10731073{
    1074         dev_handle_t dev_handle = (dev_handle_t) IPC_GET_ARG1(*request);
     1074        devmap_handle_t devmap_handle = (devmap_handle_t) IPC_GET_ARG1(*request);
    10751075        fs_node_t *fn;
    10761076        fat_node_t *nodep;
    10771077        int rc;
    10781078
    1079         rc = fat_root_get(&fn, dev_handle);
     1079        rc = fat_root_get(&fn, devmap_handle);
    10801080        if (rc != EOK) {
    10811081                ipc_answer_0(rid, rc);
     
    11051105         * stop using libblock for this instance.
    11061106         */
    1107         (void) fat_node_fini_by_dev_handle(dev_handle);
    1108         fat_idx_fini_by_dev_handle(dev_handle);
    1109         (void) block_cache_fini(dev_handle);
    1110         block_fini(dev_handle);
     1107        (void) fat_node_fini_by_devmap_handle(devmap_handle);
     1108        fat_idx_fini_by_devmap_handle(devmap_handle);
     1109        (void) block_cache_fini(devmap_handle);
     1110        block_fini(devmap_handle);
    11111111
    11121112        ipc_answer_0(rid, EOK);
     
    11251125void fat_read(ipc_callid_t rid, ipc_call_t *request)
    11261126{
    1127         dev_handle_t dev_handle = (dev_handle_t) IPC_GET_ARG1(*request);
     1127        devmap_handle_t devmap_handle = (devmap_handle_t) IPC_GET_ARG1(*request);
    11281128        fs_index_t index = (fs_index_t) IPC_GET_ARG2(*request);
    11291129        aoff64_t pos =
     
    11361136        int rc;
    11371137
    1138         rc = fat_node_get(&fn, dev_handle, index);
     1138        rc = fat_node_get(&fn, devmap_handle, index);
    11391139        if (rc != EOK) {
    11401140                ipc_answer_0(rid, rc);
     
    11561156        }
    11571157
    1158         bs = block_bb_get(dev_handle);
     1158        bs = block_bb_get(devmap_handle);
    11591159
    11601160        if (nodep->type == FAT_FILE) {
     
    12621262void fat_write(ipc_callid_t rid, ipc_call_t *request)
    12631263{
    1264         dev_handle_t dev_handle = (dev_handle_t) IPC_GET_ARG1(*request);
     1264        devmap_handle_t devmap_handle = (devmap_handle_t) IPC_GET_ARG1(*request);
    12651265        fs_index_t index = (fs_index_t) IPC_GET_ARG2(*request);
    12661266        aoff64_t pos =
     
    12751275        int rc;
    12761276       
    1277         rc = fat_node_get(&fn, dev_handle, index);
     1277        rc = fat_node_get(&fn, devmap_handle, index);
    12781278        if (rc != EOK) {
    12791279                ipc_answer_0(rid, rc);
     
    12951295        }
    12961296
    1297         bs = block_bb_get(dev_handle);
     1297        bs = block_bb_get(devmap_handle);
    12981298
    12991299        /*
     
    13571357                nclsts = (ROUND_UP(pos + bytes, BPC(bs)) - boundary) / BPC(bs);
    13581358                /* create an independent chain of nclsts clusters in all FATs */
    1359                 rc = fat_alloc_clusters(bs, dev_handle, nclsts, &mcl, &lcl);
     1359                rc = fat_alloc_clusters(bs, devmap_handle, nclsts, &mcl, &lcl);
    13601360                if (rc != EOK) {
    13611361                        /* could not allocate a chain of nclsts clusters */
     
    13681368                rc = fat_fill_gap(bs, nodep, mcl, pos);
    13691369                if (rc != EOK) {
    1370                         (void) fat_free_clusters(bs, dev_handle, mcl);
     1370                        (void) fat_free_clusters(bs, devmap_handle, mcl);
    13711371                        (void) fat_node_put(fn);
    13721372                        ipc_answer_0(callid, rc);
     
    13741374                        return;
    13751375                }
    1376                 rc = _fat_block_get(&b, bs, dev_handle, lcl, NULL,
     1376                rc = _fat_block_get(&b, bs, devmap_handle, lcl, NULL,
    13771377                    (pos / BPS(bs)) % SPC(bs), flags);
    13781378                if (rc != EOK) {
    1379                         (void) fat_free_clusters(bs, dev_handle, mcl);
     1379                        (void) fat_free_clusters(bs, devmap_handle, mcl);
    13801380                        (void) fat_node_put(fn);
    13811381                        ipc_answer_0(callid, rc);
     
    13881388                rc = block_put(b);
    13891389                if (rc != EOK) {
    1390                         (void) fat_free_clusters(bs, dev_handle, mcl);
     1390                        (void) fat_free_clusters(bs, devmap_handle, mcl);
    13911391                        (void) fat_node_put(fn);
    13921392                        ipc_answer_0(rid, rc);
     
    13991399                rc = fat_append_clusters(bs, nodep, mcl, lcl);
    14001400                if (rc != EOK) {
    1401                         (void) fat_free_clusters(bs, dev_handle, mcl);
     1401                        (void) fat_free_clusters(bs, devmap_handle, mcl);
    14021402                        (void) fat_node_put(fn);
    14031403                        ipc_answer_0(rid, rc);
     
    14141414void fat_truncate(ipc_callid_t rid, ipc_call_t *request)
    14151415{
    1416         dev_handle_t dev_handle = (dev_handle_t) IPC_GET_ARG1(*request);
     1416        devmap_handle_t devmap_handle = (devmap_handle_t) IPC_GET_ARG1(*request);
    14171417        fs_index_t index = (fs_index_t) IPC_GET_ARG2(*request);
    14181418        aoff64_t size =
     
    14231423        int rc;
    14241424
    1425         rc = fat_node_get(&fn, dev_handle, index);
     1425        rc = fat_node_get(&fn, devmap_handle, index);
    14261426        if (rc != EOK) {
    14271427                ipc_answer_0(rid, rc);
     
    14341434        nodep = FAT_NODE(fn);
    14351435
    1436         bs = block_bb_get(dev_handle);
     1436        bs = block_bb_get(devmap_handle);
    14371437
    14381438        if (nodep->size == size) {
     
    14611461                } else {
    14621462                        fat_cluster_t lastc;
    1463                         rc = fat_cluster_walk(bs, dev_handle, nodep->firstc,
     1463                        rc = fat_cluster_walk(bs, devmap_handle, nodep->firstc,
    14641464                            &lastc, NULL, (size - 1) / BPC(bs));
    14651465                        if (rc != EOK)
     
    14861486void fat_destroy(ipc_callid_t rid, ipc_call_t *request)
    14871487{
    1488         dev_handle_t dev_handle = (dev_handle_t)IPC_GET_ARG1(*request);
     1488        devmap_handle_t devmap_handle = (devmap_handle_t)IPC_GET_ARG1(*request);
    14891489        fs_index_t index = (fs_index_t)IPC_GET_ARG2(*request);
    14901490        fs_node_t *fn;
    14911491        int rc;
    14921492
    1493         rc = fat_node_get(&fn, dev_handle, index);
     1493        rc = fat_node_get(&fn, devmap_handle, index);
    14941494        if (rc != EOK) {
    14951495                ipc_answer_0(rid, rc);
     
    15171517void fat_sync(ipc_callid_t rid, ipc_call_t *request)
    15181518{
    1519         dev_handle_t dev_handle = (dev_handle_t) IPC_GET_ARG1(*request);
     1519        devmap_handle_t devmap_handle = (devmap_handle_t) IPC_GET_ARG1(*request);
    15201520        fs_index_t index = (fs_index_t) IPC_GET_ARG2(*request);
    15211521       
    15221522        fs_node_t *fn;
    1523         int rc = fat_node_get(&fn, dev_handle, index);
     1523        int rc = fat_node_get(&fn, devmap_handle, index);
    15241524        if (rc != EOK) {
    15251525                ipc_answer_0(rid, rc);
Note: See TracChangeset for help on using the changeset viewer.