Changeset 689f036 in mainline
- Timestamp:
- 2008-06-07T14:52:29Z (16 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- f1fa2657
- Parents:
- a4dfcd2
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/fs/fat/fat_ops.c
ra4dfcd2 r689f036 113 113 114 114 #define FAT_CLST_RES0 0x0000 115 #define FAT_CLST_RES1 0x0001 /* internally used to mark root directory */115 #define FAT_CLST_RES1 0x0001 116 116 #define FAT_CLST_FIRST 0x0002 117 117 #define FAT_CLST_BAD 0xfff7 118 118 #define FAT_CLST_LAST1 0xfff8 119 119 #define FAT_CLST_LAST8 0xffff 120 121 /* internally used to mark root directory's parent */ 122 #define FAT_CLST_ROOTPAR FAT_CLST_RES0 123 /* internally used to mark root directory */ 124 #define FAT_CLST_ROOT FAT_CLST_RES1 120 125 121 126 #define fat_block_get(np, off) \ … … 152 157 ssa = rscnt + fatcnt * sf + rds; 153 158 154 if (firstc == FAT_CLST_R ES1) {159 if (firstc == FAT_CLST_ROOT) { 155 160 /* root directory special case */ 156 161 assert(offset < rds); … … 522 527 static void *fat_root_get(dev_handle_t dev_handle) 523 528 { 524 return NULL; /* TODO */529 return fat_node_get(dev_handle, 0); 525 530 } 526 531 … … 562 567 { 563 568 dev_handle_t dev_handle = (dev_handle_t) IPC_GET_ARG1(*request); 569 block_t *bb; 570 uint16_t rde; 564 571 int rc; 572 573 /* Read the number of root directory entries. */ 574 bb = block_get(dev_handle, BS_BLOCK); 575 rde = uint16_t_le2host(FAT_BS(bb)->root_ent_max); 576 block_put(bb); 565 577 566 578 rc = fat_idx_init_by_dev_handle(dev_handle); … … 570 582 } 571 583 584 /* Initialize the root node. */ 585 fat_node_t *rootp = (fat_node_t *)malloc(sizeof(fat_node_t)); 586 if (!rootp) { 587 fat_idx_fini_by_dev_handle(dev_handle); 588 ipc_answer_0(rid, ENOMEM); 589 return; 590 } 591 fat_node_initialize(rootp); 592 593 fat_idx_t *ridxp = fat_idx_get_by_pos(dev_handle, FAT_CLST_ROOTPAR, 0); 594 if (!ridxp) { 595 free(rootp); 596 fat_idx_fini_by_dev_handle(dev_handle); 597 ipc_answer_0(rid, ENOMEM); 598 return; 599 } 600 assert(ridxp->index == 0); 601 /* ridxp->lock held */ 602 603 rootp->type = FAT_DIRECTORY; 604 rootp->firstc = FAT_CLST_ROOT; 605 rootp->refcnt = 1; 606 rootp->size = rde * sizeof(fat_dentry_t); 607 rootp->idx = ridxp; 608 ridxp->nodep = rootp; 609 610 futex_up(&ridxp->lock); 611 572 612 ipc_answer_0(rid, EOK); 573 613 }
Note:
See TracChangeset
for help on using the changeset viewer.