Changeset 746f623 in mainline
- Timestamp:
- 2010-07-25T22:00:10Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- ed6cf34b
- Parents:
- 377cce8
- Location:
- uspace/srv/fs/fat
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/fs/fat/fat_fat.c
r377cce8 r746f623 119 119 120 120 return EOK; 121 } 122 123 /** Read block from file located on a FAT file system. 124 * 125 * @param block Pointer to a block pointer for storing result. 126 * @param bs Buffer holding the boot sector of the file system. 127 * @param nodep FAT node. 128 * @param bn Block number. 129 * @param flags Flags passed to libblock. 130 * 131 * @return EOK on success or a negative error code. 132 */ 133 int 134 fat_block_get(block_t **block, struct fat_bs *bs, fat_node_t *nodep, 135 aoff64_t bn, int flags) 136 { 137 if (!nodep->size) 138 return ELIMIT; 139 140 if (((((nodep->size - 1) / bs->bps) / bs->spc) == bn / bs->spc) && 141 (nodep->lastc_cached_valid) && (nodep->firstc != FAT_CLST_ROOT)) { 142 /* 143 * This is a request to read a block within the last cluster 144 * when fortunately we have the last cluster number cached. 145 */ 146 fat_cluster_t lastc = nodep->lastc_cached_value; 147 unsigned bps; 148 unsigned rscnt; /* block address of the first FAT */ 149 unsigned rde; 150 unsigned rds; /* root directory size */ 151 unsigned sf; 152 unsigned ssa; /* size of the system area */ 153 154 bps = uint16_t_le2host(bs->bps); 155 rscnt = uint16_t_le2host(bs->rscnt); 156 rde = uint16_t_le2host(bs->root_ent_max); 157 sf = uint16_t_le2host(bs->sec_per_fat); 158 159 rds = (sizeof(fat_dentry_t) * rde) / bps; 160 rds += ((sizeof(fat_dentry_t) * rde) % bps != 0); 161 ssa = rscnt + bs->fatcnt * sf + rds; 162 163 return block_get(block, nodep->idx->dev_handle, 164 ssa + (lastc - FAT_CLST_FIRST) * bs->spc + bn % bs->spc, 165 flags); 166 } else { 167 return _fat_block_get(block, bs, nodep->idx->dev_handle, 168 nodep->firstc, bn, flags); 169 } 121 170 } 122 171 -
uspace/srv/fs/fat/fat_fat.h
r377cce8 r746f623 64 64 fat_cluster_t *, uint16_t *, uint16_t); 65 65 66 #define fat_block_get(b, bs, np, bn, flags) \ 67 _fat_block_get((b), (bs), (np)->idx->dev_handle, (np)->firstc, (bn), \ 68 (flags)) 69 66 extern int fat_block_get(block_t **, struct fat_bs *, struct fat_node *, 67 aoff64_t, int); 70 68 extern int _fat_block_get(block_t **, struct fat_bs *, dev_handle_t, 71 69 fat_cluster_t, aoff64_t, int);
Note:
See TracChangeset
for help on using the changeset viewer.