Changeset 50e754e in mainline
- Timestamp:
- 2012-02-19T20:27:13Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 69c4172
- Parents:
- 3f6d4ea
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/mkexfat/mkexfat.c
r3f6d4ea r50e754e 41 41 #include <assert.h> 42 42 #include <errno.h> 43 #include <malloc.h> 43 44 #include <byteorder.h> 44 45 #include <align.h> … … 178 179 } 179 180 181 /** Writes the FAT on disk. 182 * 183 * @param cfg Pointer to the exfat_cfg structure. 184 * @return EOK on success or a negative error code. 185 */ 186 static int 187 fat_write(service_id_t service_id, exfat_cfg_t *cfg) 188 { 189 unsigned long i; 190 uint32_t *pfat; 191 int rc; 192 193 pfat = calloc(cfg->fat_sector_count, cfg->sector_size); 194 if (!pfat) 195 return ENOMEM; 196 197 pfat[0] = host2uint32_t_le(0xFFFFFFF8); 198 pfat[1] = host2uint32_t_le(0xFFFFFFFF); 199 200 rc = block_write_direct(service_id, FAT_SECTOR_START, 1, pfat); 201 if (rc != EOK) 202 goto error; 203 204 pfat[0] = pfat[1] = 0x00000000; 205 206 for (i = FAT_SECTOR_START + 1; i < cfg->fat_sector_count; ++i) { 207 rc = block_write_direct(service_id, i, 1, pfat); 208 if (rc != EOK) 209 goto error; 210 } 211 212 error: 213 free(pfat); 214 return rc; 215 } 216 180 217 /** Given a power-of-two number (n), returns the result of log2(n). 181 218 * … … 260 297 261 298 /* Write the VBR backup on disk */ 262 rc = block_write_direct(service_id, 1 , 1, &vbr);299 rc = block_write_direct(service_id, 12, 1, &vbr); 263 300 if (rc != EOK) { 264 301 printf(NAME ": Error, failed to write the VBR" \ … … 267 304 } 268 305 306 rc = fat_write(service_id, &cfg); 307 if (rc != EOK) { 308 printf(NAME ": Error, failed to write the FAT on disk\n"); 309 return 2; 310 } 311 269 312 return 0; 270 313 }
Note:
See TracChangeset
for help on using the changeset viewer.