Changeset e402382 in mainline for uspace/srv/fs/fat/fat_fat.c
- 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
- File:
-
- 1 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;
Note:
See TracChangeset
for help on using the changeset viewer.