Changeset 5d5863c in mainline
- Timestamp:
- 2011-08-14T09:23:46Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 25c60f4
- Parents:
- 5f0e16e4
- Location:
- uspace/srv/fs/exfat
- Files:
-
- 2 added
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/fs/exfat/Makefile
r5f0e16e4 r5d5863c 36 36 exfat.c \ 37 37 exfat_fat.c \ 38 exfat_bitmap.c \ 38 39 exfat_ops.c \ 39 40 exfat_idx.c \ -
uspace/srv/fs/exfat/exfat.h
r5f0e16e4 r5d5863c 62 62 #define VOL_FLAGS(bs) uint16_t_le2host(bs->volume_flags) 63 63 64 #define EXFAT_NODE(node) ((node) ? (exfat_node_t *) (node)->data : NULL) 65 #define FS_NODE(node) ((node) ? (node)->bp : NULL) 66 #define DPS(bs) (BPS((bs)) / sizeof(exfat_dentry_t)) 64 67 65 68 typedef struct exfat_bs { … … 178 181 extern void exfat_idx_fini_by_devmap_handle(devmap_handle_t); 179 182 183 extern int exfat_node_put(fs_node_t *); 184 extern int exfat_bitmap_get(fs_node_t **, devmap_handle_t); 185 /* 186 static int exfat_uctable_get(fs_node_t **, devmap_handle_t); 187 */ 188 189 180 190 #endif 181 191 -
uspace/srv/fs/exfat/exfat_fat.c
r5f0e16e4 r5d5863c 34 34 /** 35 35 * @file exfat_fat.c 36 * @brief Functions that manipulate the File Allocation Table s.36 * @brief Functions that manipulate the File Allocation Table. 37 37 */ 38 38 … … 169 169 } 170 170 171 /** Read block from file located on a FAT file system.171 /** Read block from file located on a exFAT file system. 172 172 * 173 173 * @param block Pointer to a block pointer for storing result. … … 476 476 } 477 477 478 int bitmap_is_free(exfat_bs_t *bs, devmap_handle_t devmap_handle,479 exfat_cluster_t clst)480 {481 /* TODO */482 return EOK;483 }484 485 int bitmap_set_cluster(exfat_bs_t *bs, devmap_handle_t devmap_handle,486 exfat_cluster_t firstc)487 {488 /* TODO */489 return EOK;490 }491 492 int bitmap_clear_cluster(exfat_bs_t *bs, devmap_handle_t devmap_handle,493 exfat_cluster_t firstc)494 {495 /* TODO */496 return EOK;497 }498 499 int bitmap_set_clusters(exfat_bs_t *bs, devmap_handle_t devmap_handle,500 exfat_cluster_t firstc, exfat_cluster_t count)501 {502 int rc;503 exfat_cluster_t clst;504 clst = firstc;505 506 while (clst < firstc+count ) {507 rc = bitmap_set_cluster(bs, devmap_handle, clst);508 if (rc != EOK) {509 if ((clst-firstc) > 0)510 (void) bitmap_clear_clusters(bs, devmap_handle, firstc, clst-firstc);511 return rc;512 }513 clst++;514 }515 return EOK;516 }517 518 int bitmap_clear_clusters(exfat_bs_t *bs, devmap_handle_t devmap_handle,519 exfat_cluster_t firstc, exfat_cluster_t count)520 {521 int rc;522 exfat_cluster_t clst;523 clst = firstc;524 525 while (clst < firstc+count ) {526 rc = bitmap_clear_cluster(bs, devmap_handle, clst);527 if (rc != EOK)528 return rc;529 clst++;530 }531 return EOK;532 }533 534 int bitmap_alloc_clusters(exfat_bs_t *bs, devmap_handle_t devmap_handle,535 exfat_cluster_t *firstc, exfat_cluster_t count)536 {537 exfat_cluster_t startc, endc;538 startc = EXFAT_CLST_FIRST;539 540 while (startc < DATA_CNT(bs)+2) {541 if (bitmap_is_free(bs, devmap_handle, startc) == EOK) {542 endc = startc+1;543 while (bitmap_is_free(bs, devmap_handle, endc) == EOK) {544 if ((endc - startc)+1 == count){545 *firstc = startc;546 return bitmap_set_clusters(bs, devmap_handle, startc, count);547 }548 else549 endc++;550 }551 startc = endc+1;552 }553 else554 startc++;555 }556 return ENOSPC;557 }558 559 560 int bitmap_append_clusters(exfat_bs_t *bs, exfat_node_t *nodep,561 exfat_cluster_t count)562 {563 if (nodep->firstc == 0) {564 return bitmap_alloc_clusters(bs, nodep->idx->devmap_handle,565 &nodep->firstc, count);566 } else {567 exfat_cluster_t lastc, clst;568 lastc = nodep->firstc + ROUND_UP(nodep->size, BPC(bs)) / BPC(bs) - 1;569 570 clst = lastc+1;571 while (bitmap_is_free(bs, nodep->idx->devmap_handle, clst) == EOK) {572 if ((clst - lastc) == count){573 return bitmap_set_clusters(bs, nodep->idx->devmap_handle,574 lastc+1, count);575 }576 else577 clst++;578 }579 return ENOSPC;580 }581 }582 583 584 int bitmap_free_clusters(exfat_bs_t *bs, exfat_node_t *nodep,585 exfat_cluster_t count)586 {587 exfat_cluster_t lastc;588 lastc = nodep->firstc + ROUND_UP(nodep->size, BPC(bs)) / BPC(bs) - 1;589 lastc -= count;590 591 return bitmap_clear_clusters(bs, nodep->idx->devmap_handle, lastc+1, count);592 }593 594 595 int bitmap_replicate_clusters(exfat_bs_t *bs, exfat_node_t *nodep)596 {597 int rc;598 exfat_cluster_t lastc, clst;599 devmap_handle_t devmap_handle = nodep->idx->devmap_handle;600 lastc = nodep->firstc + ROUND_UP(nodep->size, BPC(bs)) / BPC(bs) - 1;601 602 for (clst = nodep->firstc; clst < lastc; clst++) {603 rc = exfat_set_cluster(bs, devmap_handle, clst, clst+1);604 if (rc != EOK)605 return rc;606 }607 608 return exfat_set_cluster(bs, devmap_handle, lastc, EXFAT_CLST_EOF);609 }610 611 612 613 478 /** Perform basic sanity checks on the file system. 614 479 * … … 619 484 int exfat_sanity_check(exfat_bs_t *bs, devmap_handle_t devmap_handle) 620 485 { 486 /* TODO */ 621 487 return EOK; 622 488 } -
uspace/srv/fs/exfat/exfat_fat.h
r5f0e16e4 r5d5863c 76 76 extern int exfat_sanity_check(struct exfat_bs *, devmap_handle_t); 77 77 78 extern int bitmap_alloc_clusters(struct exfat_bs *bs, devmap_handle_t devmap_handle,79 exfat_cluster_t *firstc, exfat_cluster_t count);80 extern int bitmap_append_clusters(struct exfat_bs *bs, struct exfat_node *nodep,81 exfat_cluster_t count);82 extern int bitmap_free_clusters(struct exfat_bs *bs, struct exfat_node *nodep,83 exfat_cluster_t count);84 extern int bitmap_replicate_clusters(struct exfat_bs *bs, struct exfat_node *nodep);85 86 extern int bitmap_is_free(struct exfat_bs *bs, devmap_handle_t devmap_handle,87 exfat_cluster_t clst);88 extern int bitmap_set_cluster(struct exfat_bs *bs, devmap_handle_t devmap_handle,89 exfat_cluster_t firstc);90 extern int bitmap_clear_cluster(struct exfat_bs *bs, devmap_handle_t devmap_handle,91 exfat_cluster_t firstc);92 extern int bitmap_set_clusters(struct exfat_bs *bs, devmap_handle_t devmap_handle,93 exfat_cluster_t firstc, exfat_cluster_t count);94 extern int bitmap_clear_clusters(struct exfat_bs *bs, devmap_handle_t devmap_handle,95 exfat_cluster_t firstc, exfat_cluster_t count);96 97 78 extern int exfat_append_clusters(struct exfat_bs *, struct exfat_node *, 98 79 exfat_cluster_t, exfat_cluster_t); -
uspace/srv/fs/exfat/exfat_ops.c
r5f0e16e4 r5d5863c 41 41 #include "exfat_dentry.h" 42 42 #include "exfat_directory.h" 43 #include "exfat_bitmap.h" 43 44 #include "../../vfs/vfs.h" 44 45 #include <libfs.h> … … 60 61 #include <stdio.h> 61 62 62 #define EXFAT_NODE(node) ((node) ? (exfat_node_t *) (node)->data : NULL)63 #define FS_NODE(node) ((node) ? (node)->bp : NULL)64 #define DPS(bs) (BPS((bs)) / sizeof(exfat_dentry_t))65 66 63 /** Mutex protecting the list of cached free FAT nodes. */ 67 64 static FIBRIL_MUTEX_INITIALIZE(ffn_mutex); … … 73 70 * Forward declarations of FAT libfs operations. 74 71 */ 75 /* 76 static int exfat_bitmap_get(fs_node_t **, devmap_handle_t); 77 static int exfat_uctable_get(fs_node_t **, devmap_handle_t); 78 */ 72 79 73 static int exfat_root_get(fs_node_t **, devmap_handle_t); 80 74 static int exfat_match(fs_node_t **, fs_node_t *, const char *); 81 75 static int exfat_node_get(fs_node_t **, devmap_handle_t, fs_index_t); 82 76 static int exfat_node_open(fs_node_t *); 83 static int exfat_node_put(fs_node_t *); 77 /* static int exfat_node_put(fs_node_t *); */ 84 78 static int exfat_create_node(fs_node_t **, devmap_handle_t, int); 85 79 static int exfat_destroy_node(fs_node_t *); … … 459 453 } 460 454 461 /*462 455 int exfat_bitmap_get(fs_node_t **rfn, devmap_handle_t devmap_handle) 463 456 { 464 457 return exfat_node_get(rfn, devmap_handle, EXFAT_BITMAP_IDX); 465 458 } 466 */ 459 467 460 /* 468 461 int exfat_uctable_get(fs_node_t **rfn, devmap_handle_t devmap_handle)
Note:
See TracChangeset
for help on using the changeset viewer.