Changeset 095a989 in mainline for uspace/srv


Ignore:
Timestamp:
2024-09-05T22:34:53Z (18 months ago)
Author:
Miroslav Cimerman <mc@…>
Children:
ee83e9c
Parents:
e192339
git-author:
Miroslav Cimerman <mc@…> (2024-09-05 22:31:28)
git-committer:
Miroslav Cimerman <mc@…> (2024-09-05 22:34:53)
Message:

hr: add status printing

File:
1 edited

Legend:

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

    re192339 r095a989  
    136136}
    137137
     138static void hr_print_status_srv(ipc_call_t *icall)
     139{
     140        log_msg(LOG_DEFAULT, LVL_NOTE, "hr_status_srv()");
     141
     142        errno_t rc;
     143        size_t vol_cnt = 0;
     144        hr_vol_info_t info;
     145        ipc_call_t call;
     146        size_t size;
     147
     148        fibril_mutex_lock(&hr_volumes_lock);
     149
     150        vol_cnt = list_count(&hr_volumes);
     151
     152        if (!async_data_read_receive(&call, &size)) {
     153                rc = EREFUSED;
     154                goto error;
     155        }
     156
     157        if (size != sizeof(size_t)) {
     158                rc = EINVAL;
     159                goto error;
     160        }
     161
     162        rc = async_data_read_finalize(&call, &vol_cnt, size);
     163        if (rc != EOK)
     164                goto error;
     165
     166        list_foreach(hr_volumes, lvolumes, hr_volume_t, volume) {
     167                memcpy(info.extents, volume->devs,
     168                    sizeof(service_id_t) * HR_MAXDEVS);
     169                info.svc_id = volume->svc_id;
     170                info.extent_no = volume->dev_no;
     171                info.level = volume->level;
     172                info.nblocks = volume->nblocks;
     173                info.bsize = volume->bsize;
     174
     175                if (!async_data_read_receive(&call, &size)) {
     176                        rc = EREFUSED;
     177                        goto error;
     178                }
     179
     180                if (size != sizeof(hr_vol_info_t)) {
     181                        rc = EINVAL;
     182                        goto error;
     183                }
     184
     185                rc = async_data_read_finalize(&call, &info, size);
     186                if (rc != EOK)
     187                        goto error;
     188        }
     189
     190        fibril_mutex_unlock(&hr_volumes_lock);
     191        async_answer_0(icall, EOK);
     192        return;
     193error:
     194        fibril_mutex_unlock(&hr_volumes_lock);
     195        async_answer_0(&call, rc);
     196        async_answer_0(icall, rc);
     197}
     198
    138199static void hr_ctl_conn(ipc_call_t *icall, void *arg)
    139200{
     
    155216                case HR_CREATE:
    156217                        hr_create_srv(&call);
     218                        break;
     219                case HR_STATUS:
     220                        hr_print_status_srv(&call);
    157221                        break;
    158222                default:
Note: See TracChangeset for help on using the changeset viewer.