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

Changeset 6da81e0 in mainline


Ignore:
Timestamp:
2010-07-28T10:12:43Z (11 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master
Children:
dba4a23
Parents:
7a23d60
Message:

Modify _fat_block_get() to return the "current" cluster number to the caller.

Location:
uspace/srv/fs/fat
Files:
3 edited

Legend:

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

    r7a23d60 r6da81e0  
    160160fall_through:
    161161        return _fat_block_get(block, bs, nodep->idx->dev_handle, nodep->firstc,
    162             bn, flags);
     162            NULL, bn, flags);
    163163}
    164164
     
    168168 * @param bs            Buffer holding the boot sector of the file system.
    169169 * @param dev_handle    Device handle of the file system.
    170  * @param firstc        First cluster used by the file. Can be zero if the file
     170 * @param fcl           First cluster used by the file. Can be zero if the file
    171171 *                      is empty.
     172 * @param clp           If not NULL, address where the cluster containing bn
     173 *                      will be stored.
     174 *                      stored
    172175 * @param bn            Block number.
    173176 * @param flags         Flags passed to libblock.
     
    177180int
    178181_fat_block_get(block_t **block, fat_bs_t *bs, dev_handle_t dev_handle,
    179     fat_cluster_t firstc, aoff64_t bn, int flags)
     182    fat_cluster_t fcl, fat_cluster_t *clp, aoff64_t bn, int flags)
    180183{
    181184        uint16_t clusters;
    182185        unsigned max_clusters;
    183         fat_cluster_t lastc;
     186        fat_cluster_t c;
    184187        int rc;
    185188
     
    187190         * This function can only operate on non-zero length files.
    188191         */
    189         if (firstc == FAT_CLST_RES0)
     192        if (fcl == FAT_CLST_RES0)
    190193                return ELIMIT;
    191194
    192         if (firstc == FAT_CLST_ROOT) {
     195        if (fcl == FAT_CLST_ROOT) {
    193196                /* root directory special case */
    194197                assert(bn < RDS(bs));
     
    199202
    200203        max_clusters = bn / SPC(bs);
    201         rc = fat_cluster_walk(bs, dev_handle, firstc, &lastc, &clusters,
    202             max_clusters);
     204        rc = fat_cluster_walk(bs, dev_handle, fcl, &c, &clusters, max_clusters);
    203205        if (rc != EOK)
    204206                return rc;
    205207        assert(clusters == max_clusters);
    206208
    207         rc = block_get(block, dev_handle, CLBN2PBN(bs, lastc, bn), flags);
     209        rc = block_get(block, dev_handle, CLBN2PBN(bs, c, bn), flags);
     210
     211        if (clp)
     212                *clp = c;
    208213
    209214        return rc;
     
    251256        for (o = boundary; o < pos; o += BPS(bs)) {
    252257                rc = _fat_block_get(&b, bs, nodep->idx->dev_handle, mcl,
    253                     (o - boundary) / BPS(bs), BLOCK_FLAGS_NOREAD);
     258                    NULL, (o - boundary) / BPS(bs), BLOCK_FLAGS_NOREAD);
    254259                if (rc != EOK)
    255260                        return rc;
     
    606611
    607612        for (i = 0; i < SPC(bs); i++) {
    608                 rc = _fat_block_get(&b, bs, dev_handle, c, i,
     613                rc = _fat_block_get(&b, bs, dev_handle, c, NULL, i,
    609614                    BLOCK_FLAGS_NOREAD);
    610615                if (rc != EOK)
  • uspace/srv/fs/fat/fat_fat.h

    r7a23d60 r6da81e0  
    6767    aoff64_t, int);
    6868extern int _fat_block_get(block_t **, struct fat_bs *, dev_handle_t,
    69     fat_cluster_t, aoff64_t, int);
     69    fat_cluster_t, fat_cluster_t *, aoff64_t, int);
    7070
    7171extern int fat_append_clusters(struct fat_bs *, struct fat_node *,
  • uspace/srv/fs/fat/fat_ops.c

    r7a23d60 r6da81e0  
    121121        /* Read the block that contains the dentry of interest. */
    122122        rc = _fat_block_get(&b, bs, node->idx->dev_handle, node->idx->pfc,
    123             (node->idx->pdi * sizeof(fat_dentry_t)) / BPS(bs),
     123            NULL, (node->idx->pdi * sizeof(fat_dentry_t)) / BPS(bs),
    124124            BLOCK_FLAGS_NONE);
    125125        if (rc != EOK)
     
    299299
    300300        /* Read the block that contains the dentry of interest. */
    301         rc = _fat_block_get(&b, bs, idxp->dev_handle, idxp->pfc,
     301        rc = _fat_block_get(&b, bs, idxp->dev_handle, idxp->pfc, NULL,
    302302            (idxp->pdi * sizeof(fat_dentry_t)) / BPS(bs), BLOCK_FLAGS_NONE);
    303303        if (rc != EOK) {
     
    799799
    800800        rc = _fat_block_get(&b, bs, childp->idx->dev_handle, childp->idx->pfc,
    801             (childp->idx->pdi * sizeof(fat_dentry_t)) / BPS(bs),
     801            NULL, (childp->idx->pdi * sizeof(fat_dentry_t)) / BPS(bs),
    802802            BLOCK_FLAGS_NONE);
    803803        if (rc != EOK)
     
    13811381                        return;
    13821382                }
    1383                 rc = _fat_block_get(&b, bs, dev_handle, lcl,
     1383                rc = _fat_block_get(&b, bs, dev_handle, lcl, NULL,
    13841384                    (pos / BPS(bs)) % SPC(bs), flags);
    13851385                if (rc != EOK) {
Note: See TracChangeset for help on using the changeset viewer.