Changeset 6d57e1c in mainline
- Timestamp:
- 2011-06-27T19:39:06Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 620a367
- Parents:
- efa8ed93
- Location:
- uspace/srv/fs/exfat
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/fs/exfat/exfat.c
refa8ed93 r6d57e1c 98 98 return; 99 99 case VFS_OUT_MOUNTED: 100 /* exfat_mounted(callid, &call); */ 101 async_answer_0(callid, ENOTSUP); 100 exfat_mounted(callid, &call); 102 101 break; 103 102 case VFS_OUT_MOUNT: 104 /* exfat_mount(callid, &call); */ 105 async_answer_0(callid, ENOTSUP); 103 exfat_mount(callid, &call); 106 104 break; 107 105 case VFS_OUT_UNMOUNTED: 108 /* exfat_unmounted(callid, &call); */ 109 async_answer_0(callid, ENOTSUP); 106 exfat_unmounted(callid, &call); 110 107 break; 111 108 case VFS_OUT_UNMOUNT: 112 /* exfat_unmount(callid, &call); */ 113 async_answer_0(callid, ENOTSUP); 109 exfat_unmount(callid, &call); 114 110 break; 115 111 case VFS_OUT_LOOKUP: -
uspace/srv/fs/exfat/exfat.h
refa8ed93 r6d57e1c 49 49 #define BS_SIZE 512 50 50 51 #define BPS(bs) (1 << (bs->bytes_per_sector)) 52 #define SPC(bs) (1 << (bs->sec_per_cluster)) 53 #define VOL_ST(bs) uint64_t_le2host(bs->volume_start) 54 #define VOL_CNT(bs) uint64_t_le2host(bs->volume_count) 55 #define FAT_ST(bs) uint32_t_le2host(bs->fat_sector_start) 56 #define FAT_CNT(bs) uint32_t_le2host(bs->fat_sector_count) 57 #define DATA_ST(bs) uint32_t_le2host(bs->data_start_sector) 58 #define DATA_CNT(bs) uint32_t_le2host(bs->data_clusters) 59 #define ROOT_ST(bs) uint32_t_le2host(bs->rootdir_cluster) 60 #define VOL_FLAGS uint16_t_le2host(bs->volume_flags) 51 61 52 62 63 typedef struct exfat_bs { 64 uint8_t jump[3]; /* 0x00 jmp and nop instructions */ 65 uint8_t oem_name[8]; /* 0x03 "EXFAT " */ 66 uint8_t __reserved[53]; /* 0x0B always 0 */ 67 uint64_t volume_start; /* 0x40 partition first sector */ 68 uint64_t volume_count; /* 0x48 partition sectors count */ 69 uint32_t fat_sector_start; /* 0x50 FAT first sector */ 70 uint32_t fat_sector_count; /* 0x54 FAT sectors count */ 71 uint32_t data_start_sector; /* 0x58 Data region first cluster sector */ 72 uint32_t data_clusters; /* 0x5C total clusters count */ 73 uint32_t rootdir_cluster; /* 0x60 first cluster of the root dir */ 74 uint32_t volume_serial; /* 0x64 volume serial number */ 75 struct { /* 0x68 FS version */ 76 uint8_t minor; 77 uint8_t major; 78 } __attribute__ ((packed)) version; 79 uint16_t volume_flags; /* 0x6A volume state flags */ 80 uint8_t bytes_per_sector; /* 0x6C sector size as (1 << n) */ 81 uint8_t sec_per_cluster; /* 0x6D sectors per cluster as (1 << n) */ 82 uint8_t fat_count; /* 0x6E always 1 */ 83 uint8_t drive_no; /* 0x6F always 0x80 */ 84 uint8_t allocated_percent; /* 0x70 percentage of allocated space */ 85 uint8_t _reserved2[7]; /* 0x71 reserved */ 86 uint8_t bootcode[390]; /* Boot code */ 87 uint16_t signature; /* the value of 0xAA55 */ 88 } __attribute__((__packed__)) exfat_bs_t; 89 90 91 extern fs_reg_t exfat_reg; 92 93 extern void exfat_mounted(ipc_callid_t, ipc_call_t *); 94 extern void exfat_mount(ipc_callid_t, ipc_call_t *); 95 extern void exfat_unmounted(ipc_callid_t, ipc_call_t *); 96 extern void exfat_unmount(ipc_callid_t, ipc_call_t *); 53 97 54 98 #endif -
uspace/srv/fs/exfat/exfat_ops.c
refa8ed93 r6d57e1c 56 56 #include <malloc.h> 57 57 58 /** libfs operations */ 59 60 libfs_ops_t exfat_libfs_ops; 61 /* 62 libfs_ops_t exfat_libfs_ops = { 63 .root_get = exfat_root_get, 64 .match = exfat_match, 65 .node_get = exfat_node_get, 66 .node_open = exfat_node_open, 67 .node_put = exfat_node_put, 68 .create = exfat_create_node, 69 .destroy = exfat_destroy_node, 70 .link = exfat_link, 71 .unlink = exfat_unlink, 72 .has_children = exfat_has_children, 73 .index_get = exfat_index_get, 74 .size_get = exfat_size_get, 75 .lnkcnt_get = exfat_lnkcnt_get, 76 .plb_get_char = exfat_plb_get_char, 77 .is_directory = exfat_is_directory, 78 .is_file = exfat_is_file, 79 .device_get = exfat_device_get 80 }; 81 */ 82 83 /* 84 * VFS operations. 85 */ 86 87 void exfat_mounted(ipc_callid_t rid, ipc_call_t *request) 88 { 89 devmap_handle_t devmap_handle = (devmap_handle_t) IPC_GET_ARG1(*request); 90 enum cache_mode cmode; 91 exfat_bs_t *bs; 92 93 /* Accept the mount options */ 94 char *opts; 95 int rc = async_data_write_accept((void **) &opts, true, 0, 0, 0, NULL); 96 97 if (rc != EOK) { 98 async_answer_0(rid, rc); 99 return; 100 } 101 102 /* Check for option enabling write through. */ 103 if (str_cmp(opts, "wtcache") == 0) 104 cmode = CACHE_MODE_WT; 105 else 106 cmode = CACHE_MODE_WB; 107 108 free(opts); 109 110 /* initialize libblock */ 111 rc = block_init(devmap_handle, BS_SIZE); 112 if (rc != EOK) { 113 async_answer_0(rid, rc); 114 return; 115 } 116 117 /* prepare the boot block */ 118 rc = block_bb_read(devmap_handle, BS_BLOCK); 119 if (rc != EOK) { 120 block_fini(devmap_handle); 121 async_answer_0(rid, rc); 122 return; 123 } 124 125 /* get the buffer with the boot sector */ 126 bs = block_bb_get(devmap_handle); 127 128 (void) bs; 129 130 /* Initialize the block cache */ 131 rc = block_cache_init(devmap_handle, BS_SIZE, 0 /* XXX */, cmode); 132 if (rc != EOK) { 133 block_fini(devmap_handle); 134 async_answer_0(rid, rc); 135 return; 136 } 137 138 async_answer_0(rid, EOK); 139 /* async_answer_3(rid, EOK, ridxp->index, rootp->size, rootp->lnkcnt); */ 140 } 141 142 void exfat_mount(ipc_callid_t rid, ipc_call_t *request) 143 { 144 libfs_mount(&exfat_libfs_ops, exfat_reg.fs_handle, rid, request); 145 } 146 147 void exfat_unmounted(ipc_callid_t rid, ipc_call_t *request) 148 { 149 devmap_handle_t devmap_handle = (devmap_handle_t) IPC_GET_ARG1(*request); 150 151 /* 152 * Perform cleanup of the node structures, index structures and 153 * associated data. Write back this file system's dirty blocks and 154 * stop using libblock for this instance. 155 */ 156 (void) block_cache_fini(devmap_handle); 157 block_fini(devmap_handle); 158 159 async_answer_0(rid, EOK); 160 } 161 162 void exfat_unmount(ipc_callid_t rid, ipc_call_t *request) 163 { 164 libfs_unmount(&exfat_libfs_ops, rid, request); 165 } 58 166 59 167
Note:
See TracChangeset
for help on using the changeset viewer.