Rev 3510 | Rev 3513 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
| Rev 3510 | Rev 3512 | ||
|---|---|---|---|
| Line 283... | Line 283... | ||
| 283 | */ |
283 | */ |
| 284 | for (b = 0, cl = 0; b < sf; blk++) { |
284 | for (b = 0, cl = 0; b < sf; blk++) { |
| 285 | blk = block_get(dev_handle, rscnt + b, bps); |
285 | blk = block_get(dev_handle, rscnt + b, bps); |
| 286 | for (c = 0; c < bps / sizeof(fat_cluster_t); c++, cl++) { |
286 | for (c = 0; c < bps / sizeof(fat_cluster_t); c++, cl++) { |
| 287 | fat_cluster_t *clst = (fat_cluster_t *)blk->data + c; |
287 | fat_cluster_t *clst = (fat_cluster_t *)blk->data + c; |
| 288 | if (*clst == FAT_CLST_RES0) { |
288 | if (uint16_t_le2host(*clst) == FAT_CLST_RES0) { |
| 289 | /* |
289 | /* |
| 290 | * The cluster is free. Put it into our stack |
290 | * The cluster is free. Put it into our stack |
| 291 | * of found clusters and mark it as non-free. |
291 | * of found clusters and mark it as non-free. |
| 292 | */ |
292 | */ |
| 293 | lifo[found] = cl; |
293 | lifo[found] = cl; |
| 294 | if (found == 0) |
294 | *clst = (found == 0) ? |
| 295 | *clst = FAT_CLST_LAST1; |
295 | host2uint16_t_le(FAT_CLST_LAST1) : |
| 296 | else |
- | |
| 297 | *clst = lifo[found - 1]; |
296 | host2uint16_t_le(lifo[found - 1]); |
| 298 | blk->dirty = true; /* need to sync block */ |
297 | blk->dirty = true; /* need to sync block */ |
| 299 | if (++found == nclsts) { |
298 | if (++found == nclsts) { |
| 300 | /* we are almost done */ |
299 | /* we are almost done */ |
| 301 | block_put(blk); |
300 | block_put(blk); |
| 302 | /* update the shadow copies of FAT */ |
301 | /* update the shadow copies of FAT */ |