Subversion Repositories HelenOS

Compare Revisions

Ignore whitespace Rev 3512 → Rev 3513

/trunk/uspace/srv/fs/fat/fat_fat.c
108,11 → 108,14
*
* @param dev_handle Device handle of the device with the file.
* @param firstc First cluster of the file.
* @param lastc If non-NULL, output argument holding the
* last cluster.
*
* @return Number of blocks allocated to the file.
*/
uint16_t
_fat_blcks_get(dev_handle_t dev_handle, fat_cluster_t firstc)
_fat_blcks_get(dev_handle_t dev_handle, fat_cluster_t firstc,
fat_cluster_t *lastc)
{
block_t *bb;
block_t *b;
130,6 → 133,8
 
if (firstc == FAT_CLST_RES0) {
/* No space allocated to the file. */
if (lastc)
*lastc = firstc;
return 0;
}
 
138,6 → 143,8
unsigned fidx; /* FAT1 entry index */
 
assert(clst >= FAT_CLST_FIRST);
if (lastc)
*lastc = clst; /* remember the last cluster */
fsec = (clst * sizeof(fat_cluster_t)) / bps;
fidx = clst % (bps / sizeof(fat_cluster_t));
/* read FAT1 */
148,6 → 155,8
clusters++;
}
 
if (lastc)
*lastc = clst;
return clusters * spc;
}
 
324,6 → 333,22
 
void fat_append_clusters(fat_node_t *nodep, fat_cluster_t mcl)
{
block_t *bb;
fat_cluster_t lcl;
uint8_t fatcnt, fatno;
 
if (_fat_blcks_get(nodep->idx->dev_handle, nodep->firstc, &lcl) == 0) {
nodep->firstc = host2uint16_t_le(mcl);
nodep->dirty = true; /* need to sync node */
return;
}
 
bb = block_get(nodep->idx->dev_handle, BS_BLOCK, BS_SIZE);
fatcnt = FAT_BS(bb)->fatcnt;
block_put(bb);
 
for (fatno = FAT1; fatno < fatcnt; fatno++)
fat_mark_cluster(nodep->idx->dev_handle, fatno, lcl, mcl);
}
 
/**
/trunk/uspace/srv/fs/fat/fat_fat.h
61,7 → 61,7
_fat_block_get((np)->idx->dev_handle, (np)->firstc, (off))
extern struct block *_fat_block_get(dev_handle_t, fat_cluster_t, off_t);
extern uint16_t _fat_blcks_get(dev_handle_t, fat_cluster_t);
extern uint16_t _fat_blcks_get(dev_handle_t, fat_cluster_t, fat_cluster_t *);
extern uint16_t fat_bps_get(dev_handle_t);
extern void fat_append_clusters(struct fat_node *, fat_cluster_t);
/trunk/uspace/srv/fs/fat/fat_ops.c
200,7 → 200,7
* size of the directory by walking the FAT.
*/
nodep->size = bps * _fat_blcks_get(idxp->dev_handle,
uint16_t_le2host(d->firstc));
uint16_t_le2host(d->firstc), NULL);
} else {
nodep->type = FAT_FILE;
nodep->size = uint32_t_le2host(d->size);