Changeset f455de0 in mainline
- Timestamp:
- 2025-02-13T20:22:38Z (2 days ago)
- Parents:
- 32254d6 (diff), 4a3a5a0 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - git-author:
- Miroslav Cimerman <70661600+mcimerman@…> (2025-02-13 20:22:38)
- git-committer:
- GitHub <noreply@…> (2025-02-13 20:22:38)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/ext4/src/superblock.c
r32254d6 rf455de0 1215 1215 uint64_t first_block = EXT4_SUPERBLOCK_OFFSET / phys_block_size; 1216 1216 1217 /* 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++; 1223 1224 /* Write data */ 1225 return block_write_direct(service_id, first_block, block_count, sb); 1217 if (phys_block_size <= EXT4_SUPERBLOCK_SIZE) { 1218 /* Superblock is a multiple of physical block sizes */ 1219 size_t block_count = EXT4_SUPERBLOCK_SIZE / phys_block_size; 1220 return block_write_direct(service_id, first_block, block_count, sb); 1221 } 1222 1223 /* 1224 * Superblock fills only a part of the physical block, 1225 * but we can only overwrite an entire physical block. 1226 */ 1227 void *tmp_sb = malloc(phys_block_size); 1228 if (tmp_sb == NULL) 1229 return ENOMEM; 1230 1231 /* Preserve physical block data */ 1232 rc = block_read_direct(service_id, first_block, 1, tmp_sb); 1233 if (rc == EOK) { 1234 /* Write the superblock */ 1235 void *sb_pos = tmp_sb + EXT4_SUPERBLOCK_OFFSET % phys_block_size; 1236 memcpy(sb_pos, sb, EXT4_SUPERBLOCK_SIZE); 1237 1238 /* Write physical block to device */ 1239 rc = block_write_direct(service_id, first_block, 1, tmp_sb); 1240 } 1241 1242 free(tmp_sb); 1243 return rc; 1226 1244 } 1227 1245
Note:
See TracChangeset
for help on using the changeset viewer.