Changeset fb06476f in mainline for uspace/lib


Ignore:
Timestamp:
2025-04-21T13:20:05Z (6 months ago)
Author:
Miroslav Cimerman <mc@…>
Children:
c6d2af8
Parents:
5cb1631
Message:

hr: use enum for RAID layouts

Location:
uspace/lib/device
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/device/include/hr.h

    r5cb1631 rfb06476f  
    5555} hr_level_t;
    5656
    57 /*
    58  * SNIA
    59  * Common RAID Disk Data Format
    60  * Specification
    61  * Version 2.0 Revision 19
    62  */
    63 #define HR_RLQ_RAID4_0  0x00 /* RAID-4 Non-Rotating Parity 0 */
    64 #define HR_RLQ_RAID4_N  0x01 /* RAID-4 Non-Rotating Parity N */
    65 #define HR_RLQ_RAID5_0R 0x00 /* RAID-5 Rotating Parity 0 with Data Restart */
    66 #define HR_RLQ_RAID5_NR 0x02 /* RAID-5 Rotating Parity N with Data Restart */
    67 #define HR_RLQ_RAID5_NC 0x03 /* RAID-5 Rotating Parity N with Data Continuation */
     57typedef enum hr_layout {
     58        HR_RLQ_NONE     = 0,
     59        HR_RLQ_RAID4_0,         /* RAID-4 Non-Rotating Parity 0 */
     60        HR_RLQ_RAID4_N,         /* RAID-4 Non-Rotating Parity N */
     61        HR_RLQ_RAID5_0R,        /* RAID-5 Rotating Parity 0 with Data Restart */
     62        HR_RLQ_RAID5_NR,        /* RAID-5 Rotating Parity N with Data Restart */
     63        HR_RLQ_RAID5_NC         /* RAID-5 Rotating Parity N with Data Continuation */
     64} hr_layout_t;
    6865
    6966typedef enum hr_vol_status {
     
    119116        HR_METADATA_GEOM_MIRROR = 1,
    120117        HR_METADATA_GEOM_STRIPE = 2,
    121         HR_METADATA_LAST_DUMMY  = 3
     118        HR_METADATA_LAST_DUMMY
    122119} hr_metadata_type_t;
    123120
     
    132129extern const char       *hr_get_vol_status_msg(hr_vol_status_t);
    133130extern const char       *hr_get_ext_status_msg(hr_ext_status_t);
    134 extern const char       *hr_get_layout_str(hr_level_t, uint8_t);
     131extern const char       *hr_get_layout_str(hr_layout_t);
    135132extern const char       *hr_get_metadata_type_str(hr_metadata_type_t);
    136133
  • uspace/lib/device/src/hr.c

    r5cb1631 rfb06476f  
    207207        if (vol_info->level == HR_LVL_4 || vol_info->level == HR_LVL_5) {
    208208                printf("layout: %s\n",
    209                     hr_get_layout_str(vol_info->level, vol_info->layout));
     209                    hr_get_layout_str(vol_info->layout));
    210210        }
    211211        if (vol_info->level == HR_LVL_0 || vol_info->level == HR_LVL_4) {
     
    428428}
    429429
    430 const char *hr_get_layout_str(hr_level_t level, uint8_t layout)
    431 {
    432         switch (level) {
    433         case HR_LVL_4:
    434                 switch (layout) {
    435                 case HR_RLQ_RAID4_0:
    436                         return "RAID-4 Non-Rotating Parity 0";
    437                 case HR_RLQ_RAID4_N:
    438                         return "RAID-4 Non-Rotating Parity N";
    439                 default:
    440                         return "Invalid RAID 4 layout";
    441                 }
    442         case HR_LVL_5:
    443                 switch (layout) {
    444                 case HR_RLQ_RAID5_0R:
    445                         return "RAID-5 Rotating Parity 0 with Data Restart";
    446                 case HR_RLQ_RAID5_NR:
    447                         return "RAID-5 Rotating Parity N with Data Restart";
    448                 case HR_RLQ_RAID5_NC:
    449                         return "RAID-5 Rotating Parity N with Data Continuation";
    450                 default:
    451                         return "Invalid RAID 5 layout";
    452                 }
     430const char *hr_get_layout_str(hr_layout_t layout)
     431{
     432        switch (layout) {
     433        case HR_RLQ_NONE:
     434                return "RAID layout not set";
     435        case HR_RLQ_RAID4_0:
     436                return "RAID-4 Non-Rotating Parity 0";
     437        case HR_RLQ_RAID4_N:
     438                return "RAID-4 Non-Rotating Parity N";
     439        case HR_RLQ_RAID5_0R:
     440                return "RAID-5 Rotating Parity 0 with Data Restart";
     441        case HR_RLQ_RAID5_NR:
     442                return "RAID-5 Rotating Parity N with Data Restart";
     443        case HR_RLQ_RAID5_NC:
     444                return "RAID-5 Rotating Parity N with Data Continuation";
    453445        default:
    454                 return "Invalid RAID level";
     446                return "Invalid RAID layout";
    455447        }
    456448}
Note: See TracChangeset for help on using the changeset viewer.