Changeset 8271ae37 in mainline
- Timestamp:
- 2012-02-26T13:05:51Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 528acda
- Parents:
- ff415f62
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/mkexfat/mkexfat.c
rff415f62 r8271ae37 67 67 /** First sector of the Main Boot Sector Backup */ 68 68 #define MBS_BACKUP_SECTOR 12 69 70 /** VBR Checksum sector */ 71 #define VBR_CHECKSUM_SECTOR 11 72 73 /** VBR Backup Checksum sector */ 74 #define VBR_BACKUP_CHECKSUM_SECTOR 23 69 75 70 76 /** Size of the Main Extended Boot Region */ … … 252 258 exfat_bs_t mbs; 253 259 uint32_t vbr_checksum; 254 uint32_t initial_checksum;260 uint32_t *chksum_sector; 255 261 int rc; 262 unsigned idx; 263 264 chksum_sector = calloc(cfg->sector_size, sizeof(uint8_t)); 265 if (!chksum_sector) 266 return ENOMEM; 256 267 257 268 vbr_checksum = vbr_initialize(&mbs, cfg); 258 initial_checksum = vbr_checksum;259 269 260 270 /* Write the Main Boot Sector to disk */ 261 271 rc = block_write_direct(service_id, MBS_SECTOR, 1, &mbs); 262 272 if (rc != EOK) 263 return rc;273 goto exit; 264 274 265 275 /* Write the Main extended boot sectors to disk */ 266 276 rc = ebs_write(service_id, cfg, EBS_SECTOR_START, &vbr_checksum); 267 277 if (rc != EOK) 268 return rc;278 goto exit; 269 279 270 280 /* Write the Main Boot Sector backup to disk */ 271 281 rc = block_write_direct(service_id, MBS_BACKUP_SECTOR, 1, &mbs); 272 282 if (rc != EOK) 273 return rc; 274 275 /* Restore the checksum to its initial value */ 276 vbr_checksum = initial_checksum; 283 goto exit; 284 285 /* Initialize the checksum sectors */ 286 for (idx = 0; idx < cfg->sector_size / sizeof(uint32_t); ++idx) 287 chksum_sector[idx] = host2uint32_t_le(vbr_checksum); 288 289 /* Write the main checksum sector to disk */ 290 rc = block_write_direct(service_id, 291 VBR_CHECKSUM_SECTOR, 1, chksum_sector); 292 if (rc != EOK) 293 goto exit; 294 295 /* Write the backup checksum sector to disk */ 296 rc = block_write_direct(service_id, 297 VBR_BACKUP_CHECKSUM_SECTOR, 1, chksum_sector); 298 if (rc != EOK) 299 goto exit; 277 300 278 301 /* Write the Main extended boot sectors backup to disk */ 279 r eturnebs_write(service_id, cfg,302 rc = ebs_write(service_id, cfg, 280 303 EBS_BACKUP_SECTOR_START, &vbr_checksum); 304 305 exit: 306 free(chksum_sector); 307 return rc; 281 308 } 282 309 … … 293 320 uint32_t *ebs = calloc(cfg->sector_size, sizeof(uint8_t)); 294 321 int i, rc; 295 unsigned idx;296 322 297 323 if (!ebs) … … 328 354 if (rc != EOK) 329 355 goto exit; 330 331 /* Write the checksum sector */332 for (idx = 0; idx < cfg->sector_size / sizeof(uint32_t); ++idx)333 ebs[idx] = host2uint32_t_le(*chksum);334 335 rc = block_write_direct(service_id, i + base, 1, ebs);336 356 337 357 exit: … … 526 546 start_sec + i, 1, buf); 527 547 if (rc != EOK) 528 break; 529 } 530 548 goto exit; 549 } 550 551 exit: 531 552 free(buf); 532 553 return rc;
Note:
See TracChangeset
for help on using the changeset viewer.