Changeset 1b20da0 in mainline for uspace/srv/fs/exfat
- Timestamp:
- 2018-02-28T17:52:03Z (8 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 3061bc1
- Parents:
- df6ded8
- git-author:
- Jiří Zárevúcky <zarevucky.jiri@…> (2018-02-28 17:26:03)
- git-committer:
- Jiří Zárevúcky <zarevucky.jiri@…> (2018-02-28 17:52:03)
- Location:
- uspace/srv/fs/exfat
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/fs/exfat/exfat.c
rdf6ded8 r1b20da0 31 31 /** @addtogroup fs 32 32 * @{ 33 */ 33 */ 34 34 35 35 /** -
uspace/srv/fs/exfat/exfat.h
rdf6ded8 r1b20da0 30 30 /** @addtogroup fs 31 31 * @{ 32 */ 32 */ 33 33 34 34 #ifndef EXFAT_EXFAT_H_ -
uspace/srv/fs/exfat/exfat_bitmap.c
rdf6ded8 r1b20da0 48 48 49 49 50 errno_t exfat_bitmap_is_free(exfat_bs_t *bs, service_id_t service_id, 50 errno_t exfat_bitmap_is_free(exfat_bs_t *bs, service_id_t service_id, 51 51 exfat_cluster_t clst) 52 52 { … … 89 89 } 90 90 91 errno_t exfat_bitmap_set_cluster(exfat_bs_t *bs, service_id_t service_id, 91 errno_t exfat_bitmap_set_cluster(exfat_bs_t *bs, service_id_t service_id, 92 92 exfat_cluster_t clst) 93 93 { … … 124 124 } 125 125 126 errno_t exfat_bitmap_clear_cluster(exfat_bs_t *bs, service_id_t service_id, 126 errno_t exfat_bitmap_clear_cluster(exfat_bs_t *bs, service_id_t service_id, 127 127 exfat_cluster_t clst) 128 128 { … … 160 160 } 161 161 162 errno_t exfat_bitmap_set_clusters(exfat_bs_t *bs, service_id_t service_id, 162 errno_t exfat_bitmap_set_clusters(exfat_bs_t *bs, service_id_t service_id, 163 163 exfat_cluster_t firstc, exfat_cluster_t count) 164 164 { … … 180 180 } 181 181 182 errno_t exfat_bitmap_clear_clusters(exfat_bs_t *bs, service_id_t service_id, 182 errno_t exfat_bitmap_clear_clusters(exfat_bs_t *bs, service_id_t service_id, 183 183 exfat_cluster_t firstc, exfat_cluster_t count) 184 184 { … … 196 196 } 197 197 198 errno_t exfat_bitmap_alloc_clusters(exfat_bs_t *bs, service_id_t service_id, 198 errno_t exfat_bitmap_alloc_clusters(exfat_bs_t *bs, service_id_t service_id, 199 199 exfat_cluster_t *firstc, exfat_cluster_t count) 200 200 { … … 217 217 218 218 219 errno_t exfat_bitmap_append_clusters(exfat_bs_t *bs, exfat_node_t *nodep, 219 errno_t exfat_bitmap_append_clusters(exfat_bs_t *bs, exfat_node_t *nodep, 220 220 exfat_cluster_t count) 221 221 { 222 222 if (nodep->firstc == 0) { 223 return exfat_bitmap_alloc_clusters(bs, nodep->idx->service_id, 223 return exfat_bitmap_alloc_clusters(bs, nodep->idx->service_id, 224 224 &nodep->firstc, count); 225 225 } else { … … 230 230 while (exfat_bitmap_is_free(bs, nodep->idx->service_id, clst) == EOK) { 231 231 if (clst - lastc == count){ 232 return exfat_bitmap_set_clusters(bs, nodep->idx->service_id, 232 return exfat_bitmap_set_clusters(bs, nodep->idx->service_id, 233 233 lastc + 1, count); 234 234 } else … … 240 240 241 241 242 errno_t exfat_bitmap_free_clusters(exfat_bs_t *bs, exfat_node_t *nodep, 242 errno_t exfat_bitmap_free_clusters(exfat_bs_t *bs, exfat_node_t *nodep, 243 243 exfat_cluster_t count) 244 244 { -
uspace/srv/fs/exfat/exfat_dentry.c
rdf6ded8 r1b20da0 29 29 /** @addtogroup fs 30 30 * @{ 31 */ 31 */ 32 32 33 33 /** … … 143 143 /** 144 144 * @} 145 */ 145 */ -
uspace/srv/fs/exfat/exfat_dentry.h
rdf6ded8 r1b20da0 29 29 /** @addtogroup fs 30 30 * @{ 31 */ 31 */ 32 32 33 33 #ifndef EXFAT_EXFAT_DENTRY_H_ … … 82 82 83 83 typedef struct { 84 uint8_t count; /* Always zero */ 84 uint8_t count; /* Always zero */ 85 85 uint16_t checksum; 86 86 uint16_t flags; -
uspace/srv/fs/exfat/exfat_directory.c
rdf6ded8 r1b20da0 29 29 /** @addtogroup fs 30 30 * @{ 31 */ 31 */ 32 32 33 33 /** … … 63 63 { 64 64 exfat_directory_init(di); 65 di->nodep = nodep; 65 di->nodep = nodep; 66 66 if (di->nodep->type != EXFAT_DIRECTORY) 67 67 return EINVAL; … … 76 76 } 77 77 78 errno_t exfat_directory_open_parent(exfat_directory_t *di, 78 errno_t exfat_directory_open_parent(exfat_directory_t *di, 79 79 service_id_t service_id, exfat_cluster_t firstc, bool fragmented) 80 80 { … … 213 213 214 214 215 errno_t exfat_directory_read_file(exfat_directory_t *di, char *name, size_t size, 215 errno_t exfat_directory_read_file(exfat_directory_t *di, char *name, size_t size, 216 216 exfat_file_dentry_t *df, exfat_stream_dentry_t *ds) 217 217 { … … 232 232 if (rc != EOK) 233 233 return rc; 234 rc = exfat_directory_get(di, &d); 234 rc = exfat_directory_get(di, &d); 235 235 if (rc != EOK) 236 236 return rc; … … 246 246 if (rc != EOK) 247 247 return rc; 248 rc = exfat_directory_get(di, &d); 248 rc = exfat_directory_get(di, &d); 249 249 if (rc != EOK) 250 250 return rc; … … 303 303 } 304 304 305 errno_t exfat_directory_sync_file(exfat_directory_t *di, exfat_file_dentry_t *df, 305 errno_t exfat_directory_sync_file(exfat_directory_t *di, exfat_file_dentry_t *df, 306 306 exfat_stream_dentry_t *ds) 307 307 { … … 388 388 389 389 uctable_chars = ALIGN_DOWN(uctablep->size, 390 sizeof(uint16_t)) / sizeof(uint16_t); 390 sizeof(uint16_t)) / sizeof(uint16_t); 391 391 uctable = (uint16_t *) malloc(uctable_chars * sizeof(uint16_t)); 392 392 rc = exfat_read_uctable(di->bs, uctablep, (uint8_t *)uctable); … … 403 403 ds.stream.data_size = 0; 404 404 ds.stream.name_size = utf16_wsize(wname); 405 ds.stream.hash = host2uint16_t_le(exfat_name_hash(wname, uctable, 405 ds.stream.hash = host2uint16_t_le(exfat_name_hash(wname, uctable, 406 406 uctable_chars)); 407 407 … … 409 409 df.type = EXFAT_TYPE_FILE; 410 410 df.file.attr = 0; 411 df.file.count = ROUND_UP(ds.stream.name_size, EXFAT_NAME_PART_LEN) / 411 df.file.count = ROUND_UP(ds.stream.name_size, EXFAT_NAME_PART_LEN) / 412 412 EXFAT_NAME_PART_LEN + 1; 413 413 df.file.checksum = 0; … … 553 553 } 554 554 } 555 } while (exfat_directory_next(di) == EOK); 555 } while (exfat_directory_next(di) == EOK); 556 556 } while (exfat_directory_expand(di) == EOK); 557 557 return ENOSPC; … … 561 561 /** 562 562 * @} 563 */ 563 */ -
uspace/srv/fs/exfat/exfat_fat.c
rdf6ded8 r1b20da0 74 74 */ 75 75 errno_t 76 exfat_cluster_walk(exfat_bs_t *bs, service_id_t service_id, 76 exfat_cluster_walk(exfat_bs_t *bs, service_id_t service_id, 77 77 exfat_cluster_t firstc, exfat_cluster_t *lastc, uint32_t *numc, 78 78 uint32_t max_clusters) … … 141 141 * when fortunately we have the last cluster number cached. 142 142 */ 143 return block_get(block, nodep->idx->service_id, DATA_FS(bs) + 144 (nodep->lastc_cached_value-EXFAT_CLST_FIRST)*SPC(bs) + 143 return block_get(block, nodep->idx->service_id, DATA_FS(bs) + 144 (nodep->lastc_cached_value-EXFAT_CLST_FIRST)*SPC(bs) + 145 145 (bn % SPC(bs)), flags); 146 146 } … … 187 187 */ 188 188 errno_t 189 exfat_block_get_by_clst(block_t **block, exfat_bs_t *bs, 189 exfat_block_get_by_clst(block_t **block, exfat_bs_t *bs, 190 190 service_id_t service_id, bool fragmented, exfat_cluster_t fcl, 191 191 exfat_cluster_t *clp, aoff64_t bn, int flags) … … 200 200 201 201 if (!fragmented) { 202 rc = block_get(block, service_id, DATA_FS(bs) + 202 rc = block_get(block, service_id, DATA_FS(bs) + 203 203 (fcl - EXFAT_CLST_FIRST)*SPC(bs) + bn, flags); 204 204 } else { … … 209 209 assert(clusters == max_clusters); 210 210 211 rc = block_get(block, service_id, DATA_FS(bs) + 211 rc = block_get(block, service_id, DATA_FS(bs) + 212 212 (c - EXFAT_CLST_FIRST) * SPC(bs) + (bn % SPC(bs)), flags); 213 213 -
uspace/srv/fs/exfat/exfat_idx.c
rdf6ded8 r1b20da0 29 29 /** @addtogroup fs 30 30 * @{ 31 */ 31 */ 32 32 33 33 /** … … 92 92 93 93 list_foreach(unused_list, link, unused_t, u) { 94 if (u->service_id == service_id) 94 if (u->service_id == service_id) 95 95 return u; 96 96 } … … 108 108 * The index structures are hashed by the service_id, parent node's first 109 109 * cluster and index within the parent directory. 110 */ 110 */ 111 111 static hash_table_t up_hash; 112 112 … … 211 211 u = unused_find(service_id, true); 212 212 if (!u) 213 return false; 213 return false; 214 214 215 215 if (list_empty(&u->freed_list)) { 216 if (u->remaining) { 216 if (u->remaining) { 217 217 /* 218 218 * There are no freed indices, allocate one directly … … 333 333 334 334 fidx = (exfat_idx_t *) malloc(sizeof(exfat_idx_t)); 335 if (!fidx) 335 if (!fidx) 336 336 return ENOMEM; 337 337 if (!exfat_index_alloc(service_id, &fidx->index)) { … … 470 470 errno_t exfat_idx_init(void) 471 471 { 472 if (!hash_table_create(&up_hash, 0, 0, &uph_ops)) 472 if (!hash_table_create(&up_hash, 0, 0, &uph_ops)) 473 473 return ENOMEM; 474 474 if (!hash_table_create(&ui_hash, 0, 0, &uih_ops)) { … … 536 536 * Remove this instance's index structure from up_hash and ui_hash. 537 537 * Process up_hash first and ui_hash second because the index structure 538 * is actually removed in idx_remove_callback(). 538 * is actually removed in idx_remove_callback(). 539 539 */ 540 540 fibril_mutex_lock(&used_lock); … … 557 557 free(f); 558 558 } 559 free(u); 559 free(u); 560 560 } 561 561 562 562 /** 563 563 * @} 564 */ 564 */ -
uspace/srv/fs/exfat/exfat_ops.c
rdf6ded8 r1b20da0 139 139 ds.data_size = node->size; 140 140 141 exfat_directory_open_parent(&di, node->idx->service_id, node->idx->pfc, 141 exfat_directory_open_parent(&di, node->idx->service_id, node->idx->pfc, 142 142 node->idx->parent_fragmented); 143 143 rc = exfat_directory_seek(&di, node->idx->pdi); … … 269 269 } 270 270 271 static errno_t exfat_node_get_new_by_pos(exfat_node_t **nodepp, 271 static errno_t exfat_node_get_new_by_pos(exfat_node_t **nodepp, 272 272 service_id_t service_id, exfat_cluster_t pfc, unsigned pdi) 273 273 { … … 320 320 return rc; 321 321 322 exfat_directory_open_parent(&di, idxp->service_id, idxp->pfc, 322 exfat_directory_open_parent(&di, idxp->service_id, idxp->pfc, 323 323 idxp->parent_fragmented); 324 324 rc = exfat_directory_seek(&di, idxp->pdi); … … 338 338 case EXFAT_DENTRY_FILE: 339 339 nodep->type = 340 (uint16_t_le2host(d->file.attr) & EXFAT_ATTR_SUBDIR) ? 340 (uint16_t_le2host(d->file.attr) & EXFAT_ATTR_SUBDIR) ? 341 341 EXFAT_DIRECTORY : EXFAT_FILE; 342 342 rc = exfat_directory_next(&di); … … 708 708 nodep->firstc); 709 709 else 710 rc = exfat_bitmap_free_clusters(bs, nodep, 710 rc = exfat_bitmap_free_clusters(bs, nodep, 711 711 ROUND_UP(nodep->size, BPC(bs)) / BPC(bs)); 712 } 712 } 713 713 714 714 exfat_idx_destroy(nodep->idx); … … 1060 1060 1061 1061 /* Initialize the root node. */ 1062 rc = exfat_node_get_new_by_pos(&rootp, service_id, EXFAT_ROOT_PAR, 1062 rc = exfat_node_get_new_by_pos(&rootp, service_id, EXFAT_ROOT_PAR, 1063 1063 EXFAT_ROOT_POS); 1064 1064 if (rc!=EOK) { … … 1110 1110 } 1111 1111 1112 rc = exfat_node_get_new_by_pos(&bitmapp, service_id, rootp->firstc, 1112 rc = exfat_node_get_new_by_pos(&bitmapp, service_id, rootp->firstc, 1113 1113 di.pos); 1114 1114 if (rc != EOK) { … … 1151 1151 } 1152 1152 1153 rc = exfat_node_get_new_by_pos(&uctablep, service_id, rootp->firstc, 1153 rc = exfat_node_get_new_by_pos(&uctablep, service_id, rootp->firstc, 1154 1154 di.pos); 1155 1155 if (rc != EOK) {
Note:
See TracChangeset
for help on using the changeset viewer.