Changeset e47a032 in mainline for uspace/lib/device/src/hr.c


Ignore:
Timestamp:
2024-10-28T20:02:39Z (7 months ago)
Author:
Miroslav Cimerman <mc@…>
Children:
9fc1d36d
Parents:
066fed9
Message:

hr: base for status handling

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/device/src/hr.c

    r066fed9 re47a032  
    130130        printf("devname: %s\n", devname);
    131131
     132        printf("status: %s\n", hr_get_vol_status_msg(vol_info->status));
     133
    132134        printf("level: %d\n", vol_info->level);
    133135        if (vol_info->level == HR_LVL_0 || vol_info->level == HR_LVL_4) {
     
    150152        for (i = 0; i < vol_info->extent_no; i++) {
    151153                ext = &vol_info->extents[i];
    152                 rc = loc_service_get_name(ext->svc_id, &devname);
    153                 if (rc != EOK)
    154                         return rc;
     154                if (ext->status == HR_EXT_MISSING) {
     155                        devname = (char *) "MISSING-devname";
     156                } else {
     157                        rc = loc_service_get_name(ext->svc_id, &devname);
     158                        if (rc != EOK)
     159                                return rc;
     160                }
    155161                if (i == 0 && vol_info->level == HR_LVL_4)
    156                         printf("          P   %d        %zu       %s\n", ext->status, i, devname);
     162                        printf("          P   %s    %zu       %s\n", hr_get_ext_status_msg(ext->status), i, devname);
    157163                else if (vol_info->level == HR_LVL_4)
    158                         printf("              %d        %zu       %s\n", ext->status, i, devname);
     164                        printf("              %s    %zu       %s\n", hr_get_ext_status_msg(ext->status), i, devname);
    159165                else
    160                         printf("          %d        %zu       %s\n", ext->status, i, devname);
     166                        printf("          %s    %zu       %s\n", hr_get_ext_status_msg(ext->status), i, devname);
    161167        }
    162168        return EOK;
     
    262268}
    263269
     270const char *hr_get_vol_status_msg(hr_vol_status_t status)
     271{
     272        switch (status) {
     273        case HR_VOL_ONLINE:
     274                return "ONLINE";
     275        case HR_VOL_FAULTY:
     276                return "FAULTY";
     277        default:
     278                return "UNKNOWN";
     279        }
     280}
     281
     282const char *hr_get_ext_status_msg(hr_ext_status_t status)
     283{
     284        switch (status) {
     285        case HR_EXT_ONLINE:
     286                return "ONLINE";
     287        case HR_EXT_MISSING:
     288                return "MISSING";
     289        case HR_EXT_FAILED:
     290                return "FAILED";
     291        default:
     292                return "UNKNOWN";
     293        }
     294}
     295
    264296/** @}
    265297 */
Note: See TracChangeset for help on using the changeset viewer.