Changeset 0dbd4a9 in mainline
- Timestamp:
- 2025-06-28T22:52:18Z (3 months ago)
- Children:
- 9c9955ab
- Parents:
- 2192a01
- Location:
- uspace/srv/bd/hr
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/bd/hr/metadata/foreign/geom/g_mirror.h
r2192a01 r0dbd4a9 172 172 173 173 bcopy(data, md->md_magic, 16); 174 if (str_lcmp(md->md_magic, G_MIRROR_MAGIC, 16) != 0) 175 return (EINVAL); 176 174 177 md->md_version = le32dec(data + 16); 175 178 switch (md->md_version) { -
uspace/srv/bd/hr/metadata/foreign/geom/hr_g_mirror.c
r2192a01 r0dbd4a9 60 60 static errno_t meta_gmirror_get_block(service_id_t, void **); 61 61 /* static errno_t meta_gmirror_write_block(service_id_t, const void *); */ 62 static bool meta_gmirror_has_valid_magic(const void *);63 62 64 63 static errno_t meta_gmirror_probe(service_id_t, void **); … … 116 115 goto error; 117 116 118 if (!meta_gmirror_has_valid_magic(metadata_struct)) {119 rc = ENOFS;120 goto error;121 }122 123 117 *rmd = metadata_struct; 124 118 return EOK; … … 126 120 error: 127 121 free(metadata_struct); 128 return ENOFS;122 return rc; 129 123 } 130 124 … … 401 395 #endif 402 396 403 static bool meta_gmirror_has_valid_magic(const void *md_v)404 {405 HR_DEBUG("%s()", __func__);406 407 const struct g_mirror_metadata *md = md_v;408 409 if (str_lcmp(md->md_magic, G_MIRROR_MAGIC, 16) != 0)410 return false;411 412 return true;413 }414 415 397 /** @} 416 398 */ -
uspace/srv/bd/hr/metadata/foreign/geom/hr_g_stripe.c
r2192a01 r0dbd4a9 60 60 static errno_t meta_gstripe_get_block(service_id_t, void **); 61 61 /* static errno_t meta_gstripe_write_block(service_id_t, const void *); */ 62 static bool meta_gstripe_has_valid_magic(const void *);63 62 64 63 static errno_t meta_gstripe_probe(service_id_t, void **); … … 116 115 goto error; 117 116 118 if (!meta_gstripe_has_valid_magic(metadata_struct)) {119 rc = ENOFS;120 goto error;121 }122 123 117 *rmd = metadata_struct; 124 118 return EOK; … … 126 120 error: 127 121 free(metadata_struct); 128 return ENOFS;122 return rc; 129 123 } 130 124 … … 318 312 HR_DEBUG("%s()", __func__); 319 313 320 stripe_metadata_decode(block, md_v); 314 struct g_stripe_metadata *md = md_v; 315 316 stripe_metadata_decode(block, md); 317 318 if (str_lcmp(md->md_magic, G_STRIPE_MAGIC, 16) != 0) 319 return EINVAL; 321 320 322 321 return EOK; … … 397 396 #endif 398 397 399 static bool meta_gstripe_has_valid_magic(const void *md_v)400 {401 HR_DEBUG("%s()", __func__);402 403 const struct g_stripe_metadata *md = md_v;404 405 if (str_lcmp(md->md_magic, G_STRIPE_MAGIC, 16) != 0)406 return false;407 408 return true;409 }410 411 398 /** @} 412 399 */ -
uspace/srv/bd/hr/metadata/foreign/md/hr_md.c
r2192a01 r0dbd4a9 59 59 static errno_t meta_md_get_block(service_id_t, void **); 60 60 /* static errno_t meta_md_write_block(service_id_t, const void *); */ 61 static bool meta_md_has_valid_magic(const void *);62 61 63 62 static errno_t meta_md_probe(service_id_t, void **); … … 115 114 goto error; 116 115 117 if (!meta_md_has_valid_magic(metadata_struct)) {118 rc = ENOFS;119 goto error;120 }121 122 116 *rmd = metadata_struct; 123 117 return EOK; … … 125 119 error: 126 120 free(metadata_struct); 127 return ENOFS;121 return rc; 128 122 } 129 123 … … 610 604 #endif 611 605 612 static bool meta_md_has_valid_magic(const void *md_v)613 {614 HR_DEBUG("%s()", __func__);615 616 const struct mdp_superblock_1 *md = md_v;617 618 if (md->magic != MD_MAGIC)619 return false;620 621 return true;622 }623 624 606 /** @} 625 607 */ -
uspace/srv/bd/hr/metadata/foreign/softraid/hr_softraid.c
r2192a01 r0dbd4a9 60 60 static errno_t meta_softraid_get_block(service_id_t, void **); 61 61 /* static errno_t meta_softraid_write_block(service_id_t, const void *); */ 62 static bool meta_softraid_has_valid_magic(const void *);63 62 64 63 static errno_t meta_softraid_probe(service_id_t, void **); … … 116 115 goto error; 117 116 118 if (!meta_softraid_has_valid_magic(metadata_struct)) {119 rc = ENOFS;120 goto error;121 }122 123 117 *rmd = metadata_struct; 124 118 return EOK; … … 126 120 error: 127 121 free(metadata_struct); 128 return ENOFS;122 return rc; 129 123 } 130 124 … … 539 533 #endif 540 534 541 static bool meta_softraid_has_valid_magic(const void *md_v)542 {543 HR_DEBUG("%s()", __func__);544 545 const struct sr_metadata *md = md_v;546 547 if (md->ssdi.ssd_magic != SR_MAGIC)548 return false;549 550 return true;551 }552 553 535 /** @} 554 536 */ -
uspace/srv/bd/hr/metadata/native.c
r2192a01 r0dbd4a9 116 116 goto error; 117 117 118 if (!meta_native_has_valid_magic(metadata_struct)) {119 rc = ENOFS;120 goto error;121 }122 123 118 *rmd = metadata_struct; 124 119 return EOK; … … 126 121 error: 127 122 free(metadata_struct); 128 return ENOFS;123 return rc; 129 124 } 130 125 … … 440 435 441 436 memcpy(metadata->magic, scratch_md.magic, HR_NATIVE_MAGIC_SIZE); 437 if (!meta_native_has_valid_magic(metadata)) 438 return EINVAL; 439 442 440 memcpy(metadata->uuid, scratch_md.uuid, HR_NATIVE_UUID_LEN); 443 441 -
uspace/srv/bd/hr/superblock.c
r2192a01 r0dbd4a9 96 96 97 97 rc = meta_ops->probe(svc_id, &metadata_struct); 98 if (rc != EOK) {99 if (rc != ENOFS)100 return rc;98 if (rc == ENOMEM) 99 return ENOMEM; 100 if (rc != EOK) 101 101 continue; 102 }103 102 104 103 *rmetadata = metadata_struct;
Note:
See TracChangeset
for help on using the changeset viewer.