Changeset 9a3eec1 in mainline for uspace/srv/bd/hr/util.c


Ignore:
Timestamp:
2025-05-15T19:23:42Z (4 weeks ago)
Author:
Miroslav Cimerman <mc@…>
Children:
c9ce6d22
Parents:
287b2ea
Message:

hr: util: hr_get_volume_svcs()

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/bd/hr/util.c

    r287b2ea r9a3eec1  
    173173}
    174174
     175errno_t hr_get_volume_svcs(size_t *rcnt, service_id_t **rsvcs)
     176{
     177        size_t i;
     178        service_id_t *vol_svcs;
     179
     180        if (rcnt == NULL || rsvcs == NULL)
     181                return EINVAL;
     182
     183        fibril_rwlock_read_lock(&hr_volumes_lock);
     184
     185        size_t vol_cnt = list_count(&hr_volumes);
     186        vol_svcs = malloc(vol_cnt * sizeof(service_id_t));
     187        if (vol_svcs == NULL) {
     188                fibril_rwlock_read_unlock(&hr_volumes_lock);
     189                return ENOMEM;
     190        }
     191
     192        i = 0;
     193        list_foreach(hr_volumes, lvolumes, hr_volume_t, iter)
     194                vol_svcs[i++] = iter->svc_id;
     195
     196        fibril_rwlock_read_unlock(&hr_volumes_lock);
     197
     198        *rcnt = vol_cnt;
     199        *rsvcs = vol_svcs;
     200
     201        return EOK;
     202}
     203
    175204hr_volume_t *hr_get_volume(service_id_t svc_id)
    176205{
Note: See TracChangeset for help on using the changeset viewer.