Changeset cb747b3 in mainline
- Timestamp:
- 2025-01-27T15:10:46Z (5 days ago)
- Children:
- ea50e671
- Parents:
- eff458d
- git-author:
- Miroslav Cimerman <mc@…> (2025-01-25 18:23:55)
- git-committer:
- Miroslav Cimerman <mc@…> (2025-01-27 15:10:46)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/ext4/src/superblock.c
reff458d rcb747b3 1206 1206 errno_t ext4_superblock_write_direct(service_id_t service_id, ext4_superblock_t *sb) 1207 1207 { 1208 void *tmp_sb = sb; 1209 1208 1210 /* Load physical block size from block device */ 1209 1211 size_t phys_block_size; … … 1216 1218 1217 1219 /* Compute number of block to write */ 1218 size_t block_count = EXT4_SUPERBLOCK_SIZE / phys_block_size; 1219 1220 /* Check alignment */ 1221 if (EXT4_SUPERBLOCK_SIZE % phys_block_size) 1222 block_count++; 1220 size_t block_count; 1221 if (phys_block_size <= EXT4_SUPERBLOCK_SIZE) { 1222 block_count = EXT4_SUPERBLOCK_SIZE / phys_block_size; 1223 /* Check alignment */ 1224 if (EXT4_SUPERBLOCK_SIZE % phys_block_size) 1225 block_count++; 1226 } else { 1227 block_count = 1; 1228 tmp_sb = malloc(phys_block_size); 1229 if (tmp_sb == NULL) 1230 return ENOMEM; 1231 /* Preserve block data */ 1232 rc = block_read_direct(service_id, first_block, 1, tmp_sb); 1233 if (rc != EOK) { 1234 free(tmp_sb); 1235 return rc; 1236 } 1237 void *sb_pos = (uint8_t *)tmp_sb + EXT4_SUPERBLOCK_OFFSET; 1238 memcpy(sb_pos, sb, EXT4_SUPERBLOCK_SIZE); 1239 } 1223 1240 1224 1241 /* Write data */ 1225 return block_write_direct(service_id, first_block, block_count, sb); 1242 rc = block_write_direct(service_id, first_block, block_count, tmp_sb); 1243 1244 if (phys_block_size > EXT4_SUPERBLOCK_SIZE) 1245 free(tmp_sb); 1246 return rc; 1226 1247 } 1227 1248
Note:
See TracChangeset
for help on using the changeset viewer.