Changeset e17d986 in mainline


Ignore:
Timestamp:
2008-10-26T19:49:14Z (16 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
cb682eb
Parents:
a429bfb
Message:

Implementation of fat_append_clusters().

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

Legend:

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

    ra429bfb re17d986  
    109109 * @param dev_handle    Device handle of the device with the file.
    110110 * @param firstc        First cluster of the file.
     111 * @param lastc         If non-NULL, output argument holding the
     112 *                      last cluster.
    111113 *
    112114 * @return              Number of blocks allocated to the file.
    113115 */
    114116uint16_t
    115 _fat_blcks_get(dev_handle_t dev_handle, fat_cluster_t firstc)
     117_fat_blcks_get(dev_handle_t dev_handle, fat_cluster_t firstc,
     118    fat_cluster_t *lastc)
    116119{
    117120        block_t *bb;
     
    131134        if (firstc == FAT_CLST_RES0) {
    132135                /* No space allocated to the file. */
     136                if (lastc)
     137                        *lastc = firstc;
    133138                return 0;
    134139        }
     
    139144
    140145                assert(clst >= FAT_CLST_FIRST);
     146                if (lastc)
     147                        *lastc = clst;          /* remember the last cluster */
    141148                fsec = (clst * sizeof(fat_cluster_t)) / bps;
    142149                fidx = clst % (bps / sizeof(fat_cluster_t));
     
    149156        }
    150157
     158        if (lastc)
     159                *lastc = clst;
    151160        return clusters * spc;
    152161}
     
    325334void fat_append_clusters(fat_node_t *nodep, fat_cluster_t mcl)
    326335{
     336        block_t *bb;
     337        fat_cluster_t lcl;
     338        uint8_t fatcnt, fatno;
     339
     340        if (_fat_blcks_get(nodep->idx->dev_handle, nodep->firstc, &lcl) == 0) {
     341                nodep->firstc = host2uint16_t_le(mcl);
     342                nodep->dirty = true;            /* need to sync node */
     343                return;
     344        }
     345
     346        bb = block_get(nodep->idx->dev_handle, BS_BLOCK, BS_SIZE);
     347        fatcnt = FAT_BS(bb)->fatcnt;
     348        block_put(bb);
     349
     350        for (fatno = FAT1; fatno < fatcnt; fatno++)
     351                fat_mark_cluster(nodep->idx->dev_handle, fatno, lcl, mcl);
    327352}
    328353
  • uspace/srv/fs/fat/fat_fat.h

    ra429bfb re17d986  
    6262   
    6363extern struct block *_fat_block_get(dev_handle_t, fat_cluster_t, off_t);
    64 extern uint16_t _fat_blcks_get(dev_handle_t, fat_cluster_t);
     64extern uint16_t _fat_blcks_get(dev_handle_t, fat_cluster_t, fat_cluster_t *);
    6565extern uint16_t fat_bps_get(dev_handle_t);
    6666 
  • uspace/srv/fs/fat/fat_ops.c

    ra429bfb re17d986  
    201201                 */
    202202                nodep->size = bps * _fat_blcks_get(idxp->dev_handle,
    203                     uint16_t_le2host(d->firstc));
     203                    uint16_t_le2host(d->firstc), NULL);
    204204        } else {
    205205                nodep->type = FAT_FILE;
Note: See TracChangeset for help on using the changeset viewer.