Changeset e402382 in mainline
- Timestamp:
- 2009-09-03T13:24:36Z (15 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- dc87ad11
- Parents:
- 684b655
- Location:
- uspace/srv/fs/fat
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/fs/fat/fat_fat.c
r684b655 re402382 61 61 * @param dev_handle Device handle of the device with the file. 62 62 * @param firstc First cluster to start the walk with. 63 * @param lastc If non-NULL, output argument hodling the last cluster number visited. 63 * @param lastc If non-NULL, output argument hodling the last cluster 64 * number visited. 65 * @param numc If non-NULL, output argument holding the number of 66 * clusters seen during the walk. 64 67 * @param max_clusters Maximum number of clusters to visit. 65 68 * 66 * @return Number of clusters seen during the walk.67 */ 68 uint16_t69 * @return EOK on success or a negative error code. 70 */ 71 int 69 72 fat_cluster_walk(fat_bs_t *bs, dev_handle_t dev_handle, fat_cluster_t firstc, 70 fat_cluster_t *lastc, uint16_t max_clusters)73 fat_cluster_t *lastc, uint16_t *numc, uint16_t max_clusters) 71 74 { 72 75 block_t *b; … … 84 87 if (lastc) 85 88 *lastc = firstc; 86 return 0; 89 if (numc) 90 *numc = 0; 91 return EOK; 87 92 } 88 93 … … 98 103 /* read FAT1 */ 99 104 rc = block_get(&b, dev_handle, rscnt + fsec, BLOCK_FLAGS_NONE); 100 assert(rc == EOK); 105 if (rc != EOK) 106 return rc; 101 107 clst = uint16_t_le2host(((fat_cluster_t *)b->data)[fidx]); 102 108 assert(clst != FAT_CLST_BAD); 103 109 rc = block_put(b); 104 assert(rc == EOK); 110 if (rc != EOK) 111 return rc; 105 112 clusters++; 106 113 } … … 108 115 if (lastc && clst < FAT_CLST_LAST1) 109 116 *lastc = clst; 110 111 return clusters; 117 if (numc) 118 *numc = clusters; 119 120 return EOK; 112 121 } 113 122 … … 134 143 unsigned sf; 135 144 unsigned ssa; /* size of the system area */ 136 unsigned clusters, max_clusters; 145 uint16_t clusters; 146 unsigned max_clusters; 137 147 fat_cluster_t lastc; 138 148 int rc; … … 156 166 157 167 max_clusters = bn / bs->spc; 158 clusters = fat_cluster_walk(bs, dev_handle, firstc, &lastc,168 rc = fat_cluster_walk(bs, dev_handle, firstc, &lastc, &clusters, 159 169 max_clusters); 170 if (rc != EOK) 171 return rc; 160 172 assert(clusters == max_clusters); 161 173 … … 425 437 dev_handle_t dev_handle = nodep->idx->dev_handle; 426 438 fat_cluster_t lcl; 439 uint16_t numc; 427 440 uint8_t fatno; 428 429 if (fat_cluster_walk(bs, dev_handle, nodep->firstc, &lcl, 430 (uint16_t) -1) == 0) { 441 int rc; 442 443 rc = fat_cluster_walk(bs, dev_handle, nodep->firstc, &lcl, &numc, 444 (uint16_t) -1); 445 assert(rc == EOK); 446 447 if (numc == 0) { 431 448 /* No clusters allocated to the node yet. */ 432 449 nodep->firstc = mcl; -
uspace/srv/fs/fat/fat_fat.h
r684b655 re402382 59 59 typedef uint16_t fat_cluster_t; 60 60 61 #define fat_clusters_get( bs, dh, fc) \62 fat_cluster_walk((bs), (dh), (fc), NULL, ( uint16_t) -1)63 extern uint16_t fat_cluster_walk(struct fat_bs *, dev_handle_t, fat_cluster_t,64 fat_cluster_t *, uint16_t );61 #define fat_clusters_get(numc, bs, dh, fc) \ 62 fat_cluster_walk((bs), (dh), (fc), NULL, (numc), (uint16_t) -1) 63 extern int fat_cluster_walk(struct fat_bs *, dev_handle_t, fat_cluster_t, 64 fat_cluster_t *, uint16_t *, uint16_t); 65 65 66 66 #define fat_block_get(b, bs, np, bn, flags) \ -
uspace/srv/fs/fat/fat_ops.c
r684b655 re402382 220 220 * size of the directory by walking the FAT. 221 221 */ 222 nodep->size = bps * spc * fat_clusters_get(bs, idxp->dev_handle, 222 uint16_t clusters; 223 rc = fat_clusters_get(&clusters, bs, idxp->dev_handle, 223 224 uint16_t_le2host(d->firstc)); 225 assert(rc == EOK); 226 nodep->size = bps * spc * clusters; 224 227 } else { 225 228 nodep->type = FAT_FILE; … … 1189 1192 } else { 1190 1193 fat_cluster_t lastc; 1191 (void) fat_cluster_walk(bs, dev_handle, nodep->firstc, 1192 &lastc, (size - 1) / bpc); 1194 rc = fat_cluster_walk(bs, dev_handle, nodep->firstc, 1195 &lastc, NULL, (size - 1) / bpc); 1196 if (rc != EOK) 1197 goto out; 1193 1198 fat_chop_clusters(bs, nodep, lastc); 1194 1199 } … … 1197 1202 rc = EOK; 1198 1203 } 1204 out: 1199 1205 fat_node_put(fn); 1200 1206 ipc_answer_0(rid, rc);
Note:
See TracChangeset
for help on using the changeset viewer.