Changeset 0dbe5ac in mainline
- Timestamp:
- 2011-08-26T21:19:24Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 5d95f02
- Parents:
- ff0c270
- Location:
- uspace/srv/fs/exfat
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/fs/exfat/exfat_directory.c
rff0c270 r0dbe5ac 147 147 if (di->pos > 0) { 148 148 di->pos -= 1; 149 rc=exfat_directory_block_load(di); 150 } 151 else 149 rc = exfat_directory_block_load(di); 150 } else 152 151 return ENOENT; 153 152 154 if (rc !=EOK)153 if (rc != EOK) 155 154 di->pos += 1; 156 155 … … 281 280 return rc; 282 281 count = de->file.count + 1; 283 array = (exfat_dentry_t *) malloc(count *sizeof(exfat_dentry_t));282 array = (exfat_dentry_t *) malloc(count * sizeof(exfat_dentry_t)); 284 283 if (!array) 285 284 return ENOMEM; … … 290 289 array[i] = *de; 291 290 rc = exfat_directory_next(di); 292 if (rc !=EOK) {291 if (rc != EOK) { 293 292 free(array); 294 293 return rc; … … 378 377 379 378 /* Looking for set of free entries */ 380 rc = exfat_directory_lookup_free(di, df.file.count +1);379 rc = exfat_directory_lookup_free(di, df.file.count + 1); 381 380 if (rc != EOK) 382 381 return rc; -
uspace/srv/fs/exfat/exfat_fat.c
rff0c270 r0dbe5ac 135 135 if (nodep->fragmented) { 136 136 if (((((nodep->size - 1) / BPS(bs)) / SPC(bs)) == bn / SPC(bs)) && 137 138 139 * This is a request to read a block within the last cluster140 * when fortunately we have the last cluster number cached.141 */137 nodep->lastc_cached_valid) { 138 /* 139 * This is a request to read a block within the last cluster 140 * when fortunately we have the last cluster number cached. 141 */ 142 142 return block_get(block, nodep->idx->service_id, DATA_FS(bs) + 143 143 (nodep->lastc_cached_value-EXFAT_CLST_FIRST)*SPC(bs) + … … 195 195 int rc; 196 196 197 if (fcl < EXFAT_CLST_FIRST || fcl > DATA_CNT(bs) +2)197 if (fcl < EXFAT_CLST_FIRST || fcl > DATA_CNT(bs) + 2) 198 198 return ELIMIT; 199 199 200 200 if (!fragmented) { 201 201 rc = block_get(block, service_id, DATA_FS(bs) + 202 (fcl -EXFAT_CLST_FIRST)*SPC(bs) + bn, flags);202 (fcl - EXFAT_CLST_FIRST)*SPC(bs) + bn, flags); 203 203 } else { 204 204 max_clusters = bn / SPC(bs); … … 209 209 210 210 rc = block_get(block, service_id, DATA_FS(bs) + 211 (c -EXFAT_CLST_FIRST)*SPC(bs) + (bn % SPC(bs)), flags);211 (c - EXFAT_CLST_FIRST) * SPC(bs) + (bn % SPC(bs)), flags); 212 212 213 213 if (clp) … … 310 310 311 311 fibril_mutex_lock(&exfat_alloc_lock); 312 for (clst=EXFAT_CLST_FIRST; clst < DATA_CNT(bs)+2 && found < nclsts; clst++) { 312 for (clst = EXFAT_CLST_FIRST; clst < DATA_CNT(bs) + 2 && found < nclsts; 313 clst++) { 313 314 /* Need to rewrite because of multiple exfat_bitmap_get calls */ 314 if (bitmap_is_free(bs, service_id, clst) ==EOK) {315 316 * The cluster is free. Put it into our stack317 * of found clusters and mark it as non-free.318 */315 if (bitmap_is_free(bs, service_id, clst) == EOK) { 316 /* 317 * The cluster is free. Put it into our stack 318 * of found clusters and mark it as non-free. 319 */ 319 320 lifo[found] = clst; 320 321 rc = exfat_set_cluster(bs, service_id, clst, 321 322 (found == 0) ? EXFAT_CLST_EOF : lifo[found - 1]); 322 323 if (rc != EOK) 323 324 break; … … 339 340 340 341 /* If something wrong - free the clusters */ 341 if (found > 0) { 342 while (found--) { 343 (void) bitmap_clear_cluster(bs, service_id, lifo[found]); 344 (void) exfat_set_cluster(bs, service_id, lifo[found], 0); 345 } 342 while (found--) { 343 (void) bitmap_clear_cluster(bs, service_id, lifo[found]); 344 (void) exfat_set_cluster(bs, service_id, lifo[found], 0); 346 345 } 347 346 … … 490 489 491 490 for (i = 0; i < SPC(bs); i++) { 492 rc = exfat_block_get_by_clst(&b, bs, service_id, false, c, NULL, i,493 BLOCK_FLAGS_NOREAD);491 rc = exfat_block_get_by_clst(&b, bs, service_id, false, c, NULL, 492 i, BLOCK_FLAGS_NOREAD); 494 493 if (rc != EOK) 495 494 return rc; … … 517 516 if (rc != EOK) 518 517 return rc; 519 if (i == blocks -1)520 count = nodep->size - i *BPS(bs);518 if (i == blocks - 1) 519 count = nodep->size - i * BPS(bs); 521 520 memcpy(uctable, b->data, count); 522 521 uctable += count; -
uspace/srv/fs/exfat/exfat_fat.h
rff0c270 r0dbe5ac 58 58 typedef uint32_t exfat_cluster_t; 59 59 60 61 60 #define exfat_clusters_get(numc, bs, sid, fc) \ 62 61 exfat_cluster_walk((bs), (sid), (fc), NULL, (numc), (uint32_t) -1) 63 extern int exfat_cluster_walk(struct exfat_bs *bs, service_id_t service_id,64 exfat_cluster_t firstc, exfat_cluster_t *lastc, uint32_t *numc,65 uint32_t max_clusters);66 extern int exfat_block_get(block_t **block, struct exfat_bs *bs,67 struct exfat_node *nodep, aoff64_t bn, int flags);68 extern int exfat_block_get_by_clst(block_t **block, struct exfat_bs *bs,69 service_id_t service_id, bool fragmented, exfat_cluster_t fcl,70 exfat_cluster_t *clp, aoff64_t bn, int flags);71 62 72 extern int exfat_get_cluster(struct exfat_bs *bs, service_id_t service_id, 73 exfat_cluster_t clst, exfat_cluster_t *value); 74 extern int exfat_set_cluster(struct exfat_bs *bs, service_id_t service_id, 75 exfat_cluster_t clst, exfat_cluster_t value); 63 extern int exfat_cluster_walk(struct exfat_bs *, service_id_t, 64 exfat_cluster_t, exfat_cluster_t *, uint32_t *, uint32_t); 65 extern int exfat_block_get(block_t **, struct exfat_bs *, struct exfat_node *, 66 aoff64_t, int); 67 extern int exfat_block_get_by_clst(block_t **, struct exfat_bs *, service_id_t, 68 bool, exfat_cluster_t, exfat_cluster_t *, aoff64_t, int); 69 70 extern int exfat_get_cluster(struct exfat_bs *, service_id_t, exfat_cluster_t, 71 exfat_cluster_t *); 72 extern int exfat_set_cluster(struct exfat_bs *, service_id_t, exfat_cluster_t, 73 exfat_cluster_t); 76 74 extern int exfat_sanity_check(struct exfat_bs *, service_id_t); 77 75 … … 83 81 exfat_cluster_t *, exfat_cluster_t *); 84 82 extern int exfat_free_clusters(struct exfat_bs *, service_id_t, exfat_cluster_t); 85 extern int exfat_zero_cluster(struct exfat_bs * bs, service_id_t service_id, 86 exfat_cluster_t mcl); 83 extern int exfat_zero_cluster(struct exfat_bs *, service_id_t, exfat_cluster_t); 87 84 88 extern int exfat_read_uctable(struct exfat_bs * bs, struct exfat_node *nodep,89 uint8_t * uctable);85 extern int exfat_read_uctable(struct exfat_bs *, struct exfat_node *, 86 uint8_t *); 90 87 91 88 #endif -
uspace/srv/fs/exfat/exfat_ops.c
rff0c270 r0dbe5ac 34 34 /** 35 35 * @file exfat_ops.c 36 * @brief Implementation of VFS operations for the exFAT file system server. 36 * @brief Implementation of VFS operations for the exFAT file system 37 * server. 37 38 */ 38 39 … … 335 336 switch (exfat_classify_dentry(d)) { 336 337 case EXFAT_DENTRY_FILE: 337 nodep->type = (uint16_t_le2host(d->file.attr) & EXFAT_ATTR_SUBDIR)? 338 nodep->type = 339 (uint16_t_le2host(d->file.attr) & EXFAT_ATTR_SUBDIR) ? 338 340 EXFAT_DIRECTORY : EXFAT_FILE; 339 341 rc = exfat_directory_next(&di); … … 395 397 } 396 398 397 int exfat_node_expand(service_id_t service_id, exfat_node_t *nodep, exfat_cluster_t clusters) 399 int exfat_node_expand(service_id_t service_id, exfat_node_t *nodep, 400 exfat_cluster_t clusters) 398 401 { 399 402 exfat_bs_t *bs; … … 439 442 } 440 443 441 static int exfat_node_shrink(service_id_t service_id, exfat_node_t *nodep, aoff64_t size) 444 static int exfat_node_shrink(service_id_t service_id, exfat_node_t *nodep, 445 aoff64_t size) 442 446 { 443 447 exfat_bs_t *bs; … … 505 509 { 506 510 exfat_node_t *parentp = EXFAT_NODE(pfn); 507 char name[EXFAT_FILENAME_LEN +1];511 char name[EXFAT_FILENAME_LEN + 1]; 508 512 exfat_file_dentry_t df; 509 513 exfat_stream_dentry_t ds; … … 520 524 return rc; 521 525 522 while (exfat_directory_read_file(&di, name, EXFAT_FILENAME_LEN, 523 &d f, &ds) == EOK) {526 while (exfat_directory_read_file(&di, name, EXFAT_FILENAME_LEN, &df, 527 &ds) == EOK) { 524 528 if (stricmp(name, component) == 0) { 525 529 /* hit */ 526 530 exfat_node_t *nodep; 527 aoff64_t o = di.pos % (BPS(di.bs) / sizeof(exfat_dentry_t)); 531 aoff64_t o = di.pos % 532 (BPS(di.bs) / sizeof(exfat_dentry_t)); 528 533 exfat_idx_t *idx = exfat_idx_get_by_pos(service_id, 529 534 parentp->firstc, di.bnum * DPS(di.bs) + o); … … 734 739 */ 735 740 rc = exfat_directory_write_file(&di, name); 736 if (rc !=EOK)741 if (rc != EOK) 737 742 return rc; 738 743 rc = exfat_directory_close(&di); 739 if (rc !=EOK)744 if (rc != EOK) 740 745 return rc; 741 746 … … 962 967 { 963 968 int rc; 964 exfat_node_t *rootp =NULL, *bitmapp=NULL, *uctablep=NULL;969 exfat_node_t *rootp = NULL, *bitmapp = NULL, *uctablep = NULL; 965 970 enum cache_mode cmode; 966 971 exfat_bs_t *bs; … … 1062 1067 rc = exfat_node_get_new_by_pos(&bitmapp, service_id, rootp->firstc, 1063 1068 di.pos); 1064 if (rc !=EOK) {1069 if (rc != EOK) { 1065 1070 free(rootp); 1066 1071 (void) block_cache_fini(service_id); … … 1103 1108 rc = exfat_node_get_new_by_pos(&uctablep, service_id, rootp->firstc, 1104 1109 di.pos); 1105 if (rc !=EOK) {1110 if (rc != EOK) { 1106 1111 free(rootp); 1107 1112 free(bitmapp); … … 1123 1128 1124 1129 rc = exfat_directory_close(&di); 1125 if (rc !=EOK) {1130 if (rc != EOK) { 1126 1131 free(rootp); 1127 1132 free(bitmapp); … … 1188 1193 exfat_node_t *nodep; 1189 1194 exfat_bs_t *bs; 1190 size_t bytes =0;1195 size_t bytes = 0; 1191 1196 block_t *b; 1192 1197 int rc; … … 1244 1249 1245 1250 aoff64_t spos = pos; 1246 char name[EXFAT_FILENAME_LEN +1];1251 char name[EXFAT_FILENAME_LEN + 1]; 1247 1252 exfat_file_dentry_t df; 1248 1253 exfat_stream_dentry_t ds; … … 1260 1265 } 1261 1266 1262 rc = exfat_directory_read_file(&di, name, EXFAT_FILENAME_LEN, &df, &ds); 1263 if (rc == EOK) goto hit; 1264 if (rc == ENOENT) goto miss; 1267 rc = exfat_directory_read_file(&di, name, EXFAT_FILENAME_LEN, 1268 &df, &ds); 1269 if (rc == EOK) 1270 goto hit; 1271 if (rc == ENOENT) 1272 goto miss; 1265 1273 1266 1274 err: … … 1281 1289 pos = di.pos; 1282 1290 rc = exfat_directory_close(&di); 1283 if (rc !=EOK)1291 if (rc != EOK) 1284 1292 goto err; 1285 (void) async_data_read_finalize(callid, name, str_size(name) + 1); 1286 bytes = (pos - spos)+1; 1293 (void) async_data_read_finalize(callid, name, 1294 str_size(name) + 1); 1295 bytes = (pos - spos) + 1; 1287 1296 } 1288 1297 … … 1395 1404 return rc; 1396 1405 } 1397 1398 1406 1399 1407 *wbytes = bytes; … … 1477 1485 }; 1478 1486 1479 1480 1487 /** 1481 1488 * @}
Note:
See TracChangeset
for help on using the changeset viewer.