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


Ignore:
Timestamp:
2024-09-06T14:56:46Z (8 months ago)
Author:
Miroslav Cimerman <mc@…>
Children:
4a2a6b8b
Parents:
09398589
git-author:
Miroslav Cimerman <mc@…> (2024-09-06 14:54:21)
git-committer:
Miroslav Cimerman <mc@…> (2024-09-06 14:56:46)
Message:

hr: add option (-T, —stop) for removing an active array

File:
1 edited

Legend:

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

    r09398589 ra19d7fc4  
    180180}
    181181
     182errno_t hr_stop(const char *devname)
     183{
     184        hr_t *hr;
     185        errno_t rc;
     186        async_exch_t *exch;
     187        service_id_t svc_id;
     188
     189        rc = loc_service_get_id(devname, &svc_id, 0);
     190        if (rc != EOK)
     191                return rc;
     192
     193        rc = hr_sess_init(&hr);
     194        if (rc != EOK)
     195                return rc;
     196
     197        exch = async_exchange_begin(hr->sess);
     198        if (exch == NULL) {
     199                rc = EINVAL;
     200                goto error;
     201        }
     202        rc = async_req_1_0(exch, HR_STOP, svc_id);
     203        async_exchange_end(exch);
     204
     205        if (rc != EOK)
     206                goto error;
     207error:
     208        hr_sess_destroy(hr);
     209        return rc;
     210}
     211
    182212errno_t hr_print_status(void)
    183213{
     
    187217        aid_t req;
    188218        size_t size, i;
    189         hr_vol_info_t *vols;
     219        hr_vol_info_t *vols = NULL;
    190220
    191221        rc = hr_sess_init(&hr);
     
    194224
    195225        exch = async_exchange_begin(hr->sess);
    196         if (exch == NULL)
    197                 return EINVAL;
     226        if (exch == NULL) {
     227                rc = EINVAL;
     228                goto error;
     229        }
    198230
    199231        req = async_send_0(exch, HR_STATUS, NULL);
    200 
    201232        rc = async_data_read_start(exch, &size, sizeof(size_t));
    202233        if (rc != EOK) {
     
    230261        }
    231262
     263        if (size == 0) {
     264                printf("no active arrays\n");
     265                goto error;
     266        }
     267
    232268        for (i = 0; i < size; i++) {
    233269                rc = print_vol_info(i, &vols[i]);
     
    237273
    238274error:
     275        hr_sess_destroy(hr);
    239276        if (vols != NULL)
    240277                free(vols);
Note: See TracChangeset for help on using the changeset viewer.