Changeset a19d7fc4 in mainline for uspace/srv


Ignore:
Timestamp:
2024-09-06T14:56:46Z (18 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/srv/bd/hr/hr.c

    r09398589 ra19d7fc4  
    6161static service_id_t ctl_sid;
    6262
     63static hr_volume_t *hr_get_volume(service_id_t svc_id)
     64{
     65        log_msg(LOG_DEFAULT, LVL_DEBUG, "hr_get_volume(): (%" PRIun ")",
     66            svc_id);
     67
     68        fibril_mutex_lock(&hr_volumes_lock);
     69        list_foreach(hr_volumes, lvolumes, hr_volume_t, volume) {
     70                if (volume->svc_id == svc_id) {
     71                        fibril_mutex_unlock(&hr_volumes_lock);
     72                        return volume;
     73                }
     74        }
     75
     76        fibril_mutex_unlock(&hr_volumes_lock);
     77        return NULL;
     78}
     79
     80static errno_t hr_remove_volume(service_id_t svc_id)
     81{
     82        log_msg(LOG_DEFAULT, LVL_DEBUG, "hr_remove_volume(): (%" PRIun ")",
     83            svc_id);
     84
     85        fibril_mutex_lock(&hr_volumes_lock);
     86        list_foreach(hr_volumes, lvolumes, hr_volume_t, volume) {
     87                if (volume->svc_id == svc_id) {
     88                        hr_fini_devs(volume);
     89                        list_remove(&volume->lvolumes);
     90                        free(volume);
     91                        fibril_mutex_unlock(&hr_volumes_lock);
     92                        return EOK;
     93                }
     94        }
     95
     96        fibril_mutex_unlock(&hr_volumes_lock);
     97        return ENOENT;
     98}
     99
    63100static void hr_create_srv(ipc_call_t *icall)
    64101{
     
    262299}
    263300
     301static void hr_stop_srv(ipc_call_t *icall)
     302{
     303        log_msg(LOG_DEFAULT, LVL_NOTE, "hr_stop_srv()");
     304
     305        errno_t rc;
     306        service_id_t svc_id;
     307        hr_volume_t *vol;
     308
     309        svc_id = ipc_get_arg1(icall);
     310
     311        vol = hr_get_volume(svc_id);
     312        if (vol == NULL) {
     313                async_answer_0(icall, ENOENT);
     314                return;
     315        }
     316
     317        rc = hr_remove_volume(svc_id);
     318        if (rc != EOK) {
     319                async_answer_0(icall, rc);
     320                return;
     321        }
     322
     323        rc = loc_service_unregister(hr_srv, svc_id);
     324
     325        async_answer_0(icall, rc);
     326}
     327
    264328static void hr_print_status_srv(ipc_call_t *icall)
    265329{
     
    345409                        hr_create_srv(&call);
    346410                        break;
     411                case HR_ASSEMBLE:
     412                        hr_assemble_srv(&call);
     413                        break;
     414                case HR_STOP:
     415                        hr_stop_srv(&call);
     416                        break;
    347417                case HR_STATUS:
    348418                        hr_print_status_srv(&call);
    349419                        break;
    350                 case HR_ASSEMBLE:
    351                         hr_assemble_srv(&call);
    352                         break;
    353420                default:
    354421                        async_answer_0(&call, EINVAL);
    355422                }
    356423        }
    357 }
    358 
    359 static hr_volume_t *hr_get_volume(service_id_t svc_id)
    360 {
    361         log_msg(LOG_DEFAULT, LVL_DEBUG, "hr_get_volume(): (%" PRIun ")",
    362             svc_id);
    363 
    364         fibril_mutex_lock(&hr_volumes_lock);
    365         list_foreach(hr_volumes, lvolumes, hr_volume_t, volume) {
    366                 if (volume->svc_id == svc_id) {
    367                         fibril_mutex_unlock(&hr_volumes_lock);
    368                         return volume;
    369                 }
    370         }
    371 
    372         fibril_mutex_unlock(&hr_volumes_lock);
    373         return NULL;
    374424}
    375425
Note: See TracChangeset for help on using the changeset viewer.