Changeset 552efe3 in mainline
- Timestamp:
- 2012-02-24T22:52:50Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 3467821
- Parents:
- 89a0a827
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/mkexfat/mkexfat.c
r89a0a827 r552efe3 77 77 /** Index of the first free cluster on the device */ 78 78 #define FIRST_FREE_CLUSTER 2 79 80 #define min(x, y) ((x) < (y) ? (x) : (y)) 79 81 80 82 typedef struct exfat_cfg { … … 474 476 upcase_table_write(service_id_t service_id, exfat_cfg_t *cfg) 475 477 { 476 int rc ;478 int rc = EOK; 477 479 aoff64_t start_sec, nsecs, i; 478 480 uint8_t *table_ptr; 481 uint8_t *buf; 482 size_t table_size = sizeof(upcase_table); 483 484 buf = malloc(cfg->sector_size); 485 if (!buf) 486 return ENOENT; 479 487 480 488 start_sec = cfg->data_start_sector; 481 start_sec += ( cfg->upcase_table_cluster* cfg->cluster_size) /489 start_sec += ((cfg->upcase_table_cluster - 2) * cfg->cluster_size) / 482 490 cfg->sector_size; 483 491 … … 485 493 table_ptr = (uint8_t *) upcase_table; 486 494 487 for (i = 0; i < nsecs; ++i, table_ptr += cfg->sector_size) { 495 for (i = 0; i < nsecs; ++i, 496 table_ptr += min(table_size, cfg->sector_size), 497 table_size -= cfg->sector_size) { 498 499 if (table_size < cfg->sector_size) 500 memset(buf, 0, cfg->sector_size); 501 memcpy(buf, table_ptr, min(table_size, cfg->sector_size)); 502 488 503 rc = block_write_direct(service_id, 489 start_sec + i, 1, table_ptr);504 start_sec + i, 1, buf); 490 505 if (rc != EOK) 491 return rc; 492 } 493 494 return EOK; 506 break; 507 } 508 509 free(buf); 510 return rc; 495 511 } 496 512
Note:
See TracChangeset
for help on using the changeset viewer.