|
34 | 34 | #include <string.h> |
35 | 35 | #include <time.h> |
36 | 36 | #include <errno.h> |
| 37 | + |
| 38 | +#ifdef __linux__ |
37 | 39 | #include <linux/raid/md_p.h> |
| 40 | +#endif |
38 | 41 |
|
39 | 42 | #include "genimage.h" |
40 | 43 |
|
| 44 | +#ifdef __linux__ |
| 45 | + |
41 | 46 | #define DATA_OFFSET_SECTORS (2048) |
42 | 47 | #define DATA_OFFSET_BYTES (DATA_OFFSET_SECTORS * 512) |
43 | 48 | #define BITMAP_SECTORS_MAX 256 |
@@ -486,3 +491,48 @@ struct image_handler mdraid_handler = { |
486 | 491 | .generate = mdraid_generate, |
487 | 492 | .opts = mdraid_opts, |
488 | 493 | }; |
| 494 | + |
| 495 | +#else /* !__linux__ */ |
| 496 | + |
| 497 | +/* Stub implementation for non-Linux systems */ |
| 498 | +static int mdraid_parse(struct image *image, cfg_t *cfg) |
| 499 | +{ |
| 500 | + image_error(image, "MDRAID is only supported on Linux\n"); |
| 501 | + return -1; |
| 502 | +} |
| 503 | + |
| 504 | +static int mdraid_generate(struct image *image) |
| 505 | +{ |
| 506 | + image_error(image, "MDRAID is only supported on Linux\n"); |
| 507 | + return -1; |
| 508 | +} |
| 509 | + |
| 510 | +static int mdraid_setup(struct image *image, cfg_t *cfg) |
| 511 | +{ |
| 512 | + image_error(image, "MDRAID is only supported on Linux\n"); |
| 513 | + return -1; |
| 514 | +} |
| 515 | + |
| 516 | +static cfg_opt_t mdraid_opts[] = { |
| 517 | + CFG_STR("label", "any:42", CFGF_NONE), |
| 518 | + CFG_INT("level", 1, CFGF_NONE), |
| 519 | + CFG_INT("devices", 1, CFGF_NONE), |
| 520 | + CFG_INT("role", -1, CFGF_NONE), |
| 521 | + CFG_INT("timestamp", -1, CFGF_NONE), |
| 522 | + CFG_STR("raid-uuid", NULL, CFGF_NONE), |
| 523 | + CFG_STR("disk-uuid", NULL, CFGF_NONE), |
| 524 | + CFG_STR("image", NULL, CFGF_NONE), |
| 525 | + CFG_STR("parent", NULL, CFGF_NONE), |
| 526 | + CFG_END() |
| 527 | +}; |
| 528 | + |
| 529 | +struct image_handler mdraid_handler = { |
| 530 | + .type = "mdraid", |
| 531 | + .no_rootpath = cfg_true, |
| 532 | + .parse = mdraid_parse, |
| 533 | + .setup = mdraid_setup, |
| 534 | + .generate = mdraid_generate, |
| 535 | + .opts = mdraid_opts, |
| 536 | +}; |
| 537 | + |
| 538 | +#endif /* __linux__ */ |
0 commit comments