[1356f85a] | 1 | /*
|
---|
[4c6fd56] | 2 | * Copyright (c) 2023 Jiri Svoboda
|
---|
[1356f85a] | 3 | * All rights reserved.
|
---|
| 4 | *
|
---|
| 5 | * Redistribution and use in source and binary forms, with or without
|
---|
| 6 | * modification, are permitted provided that the following conditions
|
---|
| 7 | * are met:
|
---|
| 8 | *
|
---|
| 9 | * - Redistributions of source code must retain the above copyright
|
---|
| 10 | * notice, this list of conditions and the following disclaimer.
|
---|
| 11 | * - Redistributions in binary form must reproduce the above copyright
|
---|
| 12 | * notice, this list of conditions and the following disclaimer in the
|
---|
| 13 | * documentation and/or other materials provided with the distribution.
|
---|
| 14 | * - The name of the author may not be used to endorse or promote products
|
---|
| 15 | * derived from this software without specific prior written permission.
|
---|
| 16 | *
|
---|
| 17 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
---|
| 18 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
---|
| 19 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
---|
| 20 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
---|
| 21 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
---|
| 22 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
---|
| 23 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
---|
| 24 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
---|
| 25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
---|
| 26 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
---|
| 27 | */
|
---|
| 28 |
|
---|
[22fb7ab] | 29 | /** @addtogroup vbd
|
---|
[1356f85a] | 30 | * @{
|
---|
| 31 | */
|
---|
| 32 | /**
|
---|
| 33 | * @file
|
---|
| 34 | */
|
---|
| 35 |
|
---|
| 36 | #include <async.h>
|
---|
| 37 | #include <errno.h>
|
---|
[c1694b6b] | 38 | #include <str_error.h>
|
---|
[1356f85a] | 39 | #include <io/log.h>
|
---|
| 40 | #include <ipc/services.h>
|
---|
[22fb7ab] | 41 | #include <ipc/vbd.h>
|
---|
[5772aa1] | 42 | #include <label/label.h>
|
---|
[1356f85a] | 43 | #include <loc.h>
|
---|
[1626cd4] | 44 | #include <macros.h>
|
---|
[1356f85a] | 45 | #include <stdio.h>
|
---|
| 46 | #include <stdlib.h>
|
---|
| 47 | #include <task.h>
|
---|
[6a0d4ce2] | 48 | #include <vbd.h>
|
---|
[1356f85a] | 49 |
|
---|
[28ed0d95] | 50 | #include "disk.h"
|
---|
[22fb7ab] | 51 | #include "types/vbd.h"
|
---|
| 52 |
|
---|
[1356f85a] | 53 | #define NAME "vbd"
|
---|
| 54 |
|
---|
[984a9ba] | 55 | static void vbds_client_conn(ipc_call_t *, void *);
|
---|
[1356f85a] | 56 |
|
---|
[78d50bd] | 57 | static service_id_t ctl_sid;
|
---|
| 58 |
|
---|
[b7fd2a0] | 59 | static errno_t vbds_init(void)
|
---|
[1356f85a] | 60 | {
|
---|
[b7fd2a0] | 61 | errno_t rc;
|
---|
[55f8c6e7] | 62 | log_msg(LOG_DEFAULT, LVL_DEBUG, "vbds_init()");
|
---|
[1356f85a] | 63 |
|
---|
[372df8f] | 64 | rc = vbds_disks_init();
|
---|
| 65 | if (rc != EOK)
|
---|
| 66 | return rc;
|
---|
| 67 |
|
---|
[ff381a7] | 68 | async_set_fallback_port_handler(vbds_client_conn, NULL);
|
---|
[1356f85a] | 69 |
|
---|
[4c6fd56] | 70 | rc = loc_server_register(NAME, &vbds_srv);
|
---|
[1356f85a] | 71 | if (rc != EOK) {
|
---|
[c1694b6b] | 72 | log_msg(LOG_DEFAULT, LVL_ERROR, "Failed registering server: %s.", str_error(rc));
|
---|
[1356f85a] | 73 | return EEXIST;
|
---|
| 74 | }
|
---|
| 75 |
|
---|
[4c6fd56] | 76 | rc = loc_service_register(vbds_srv, SERVICE_NAME_VBD, &ctl_sid);
|
---|
[1356f85a] | 77 | if (rc != EOK) {
|
---|
[c1694b6b] | 78 | log_msg(LOG_DEFAULT, LVL_ERROR, "Failed registering service: %s.", str_error(rc));
|
---|
[1356f85a] | 79 | return EEXIST;
|
---|
| 80 | }
|
---|
| 81 |
|
---|
[89204a23] | 82 | rc = vbds_disk_discovery_start();
|
---|
| 83 | if (rc != EOK)
|
---|
| 84 | return rc;
|
---|
| 85 |
|
---|
[1356f85a] | 86 | return EOK;
|
---|
| 87 | }
|
---|
| 88 |
|
---|
[984a9ba] | 89 | static void vbds_get_disks_srv(ipc_call_t *icall)
|
---|
[22fb7ab] | 90 | {
|
---|
[984a9ba] | 91 | ipc_call_t call;
|
---|
[372df8f] | 92 | size_t size;
|
---|
| 93 | size_t act_size;
|
---|
[b7fd2a0] | 94 | errno_t rc;
|
---|
[22fb7ab] | 95 |
|
---|
[984a9ba] | 96 | if (!async_data_read_receive(&call, &size)) {
|
---|
| 97 | async_answer_0(&call, EREFUSED);
|
---|
| 98 | async_answer_0(icall, EREFUSED);
|
---|
[372df8f] | 99 | return;
|
---|
| 100 | }
|
---|
[28ed0d95] | 101 |
|
---|
[372df8f] | 102 | service_id_t *id_buf = (service_id_t *) malloc(size);
|
---|
| 103 | if (id_buf == NULL) {
|
---|
[984a9ba] | 104 | async_answer_0(&call, ENOMEM);
|
---|
| 105 | async_answer_0(icall, ENOMEM);
|
---|
[372df8f] | 106 | return;
|
---|
| 107 | }
|
---|
[22fb7ab] | 108 |
|
---|
[372df8f] | 109 | rc = vbds_disk_get_ids(id_buf, size, &act_size);
|
---|
| 110 | if (rc != EOK) {
|
---|
[da3bc0e] | 111 | free(id_buf);
|
---|
[984a9ba] | 112 | async_answer_0(&call, rc);
|
---|
| 113 | async_answer_0(icall, rc);
|
---|
[372df8f] | 114 | return;
|
---|
| 115 | }
|
---|
[28ed0d95] | 116 |
|
---|
[984a9ba] | 117 | errno_t retval = async_data_read_finalize(&call, id_buf, size);
|
---|
[372df8f] | 118 | free(id_buf);
|
---|
[28ed0d95] | 119 |
|
---|
[984a9ba] | 120 | async_answer_1(icall, retval, act_size);
|
---|
[22fb7ab] | 121 | }
|
---|
| 122 |
|
---|
[984a9ba] | 123 | static void vbds_disk_info_srv(ipc_call_t *icall)
|
---|
[22fb7ab] | 124 | {
|
---|
[28ed0d95] | 125 | service_id_t disk_sid;
|
---|
[b7a4d06] | 126 | vbd_disk_info_t dinfo;
|
---|
[b7fd2a0] | 127 | errno_t rc;
|
---|
[28ed0d95] | 128 |
|
---|
[55f8c6e7] | 129 | log_msg(LOG_DEFAULT, LVL_DEBUG, "vbds_disk_info_srv()");
|
---|
[28ed0d95] | 130 |
|
---|
[fafb8e5] | 131 | disk_sid = ipc_get_arg1(icall);
|
---|
[28ed0d95] | 132 | rc = vbds_disk_info(disk_sid, &dinfo);
|
---|
[1626cd4] | 133 | if (rc != EOK) {
|
---|
[984a9ba] | 134 | async_answer_0(icall, rc);
|
---|
[1626cd4] | 135 | return;
|
---|
| 136 | }
|
---|
| 137 |
|
---|
[984a9ba] | 138 | ipc_call_t call;
|
---|
[1626cd4] | 139 | size_t size;
|
---|
[984a9ba] | 140 | if (!async_data_read_receive(&call, &size)) {
|
---|
| 141 | async_answer_0(&call, EREFUSED);
|
---|
| 142 | async_answer_0(icall, EREFUSED);
|
---|
[1626cd4] | 143 | return;
|
---|
| 144 | }
|
---|
| 145 |
|
---|
[b7a4d06] | 146 | if (size != sizeof(vbd_disk_info_t)) {
|
---|
[984a9ba] | 147 | async_answer_0(&call, EINVAL);
|
---|
| 148 | async_answer_0(icall, EINVAL);
|
---|
[1626cd4] | 149 | return;
|
---|
| 150 | }
|
---|
| 151 |
|
---|
[984a9ba] | 152 | rc = async_data_read_finalize(&call, &dinfo,
|
---|
[1626cd4] | 153 | min(size, sizeof(dinfo)));
|
---|
| 154 | if (rc != EOK) {
|
---|
[984a9ba] | 155 | async_answer_0(&call, rc);
|
---|
| 156 | async_answer_0(icall, rc);
|
---|
[1626cd4] | 157 | return;
|
---|
| 158 | }
|
---|
| 159 |
|
---|
[984a9ba] | 160 | async_answer_0(icall, EOK);
|
---|
[22fb7ab] | 161 | }
|
---|
| 162 |
|
---|
[984a9ba] | 163 | static void vbds_label_create_srv(ipc_call_t *icall)
|
---|
[22fb7ab] | 164 | {
|
---|
| 165 | service_id_t disk_sid;
|
---|
[28ed0d95] | 166 | label_type_t ltype;
|
---|
[b7fd2a0] | 167 | errno_t rc;
|
---|
[22fb7ab] | 168 |
|
---|
[55f8c6e7] | 169 | log_msg(LOG_DEFAULT, LVL_DEBUG, "vbds_label_create_srv()");
|
---|
[22fb7ab] | 170 |
|
---|
[fafb8e5] | 171 | disk_sid = ipc_get_arg1(icall);
|
---|
| 172 | ltype = ipc_get_arg2(icall);
|
---|
[28ed0d95] | 173 | rc = vbds_label_create(disk_sid, ltype);
|
---|
[984a9ba] | 174 | async_answer_0(icall, rc);
|
---|
[22fb7ab] | 175 | }
|
---|
| 176 |
|
---|
[984a9ba] | 177 | static void vbds_label_delete_srv(ipc_call_t *icall)
|
---|
[22fb7ab] | 178 | {
|
---|
| 179 | service_id_t disk_sid;
|
---|
[b7fd2a0] | 180 | errno_t rc;
|
---|
[22fb7ab] | 181 |
|
---|
[55f8c6e7] | 182 | log_msg(LOG_DEFAULT, LVL_DEBUG, "vbds_label_delete_srv()");
|
---|
[22fb7ab] | 183 |
|
---|
[fafb8e5] | 184 | disk_sid = ipc_get_arg1(icall);
|
---|
[28ed0d95] | 185 | rc = vbds_label_delete(disk_sid);
|
---|
[984a9ba] | 186 | async_answer_0(icall, rc);
|
---|
[22fb7ab] | 187 | }
|
---|
| 188 |
|
---|
[984a9ba] | 189 | static void vbds_label_get_parts_srv(ipc_call_t *icall)
|
---|
[22fb7ab] | 190 | {
|
---|
[984a9ba] | 191 | ipc_call_t call;
|
---|
[1626cd4] | 192 | size_t size;
|
---|
| 193 | size_t act_size;
|
---|
| 194 | service_id_t sid;
|
---|
[b7fd2a0] | 195 | errno_t rc;
|
---|
[28ed0d95] | 196 |
|
---|
[55f8c6e7] | 197 | log_msg(LOG_DEFAULT, LVL_DEBUG, "vbds_label_get_parts_srv()");
|
---|
[28ed0d95] | 198 |
|
---|
[984a9ba] | 199 | if (!async_data_read_receive(&call, &size)) {
|
---|
| 200 | async_answer_0(&call, EREFUSED);
|
---|
| 201 | async_answer_0(icall, EREFUSED);
|
---|
[1626cd4] | 202 | return;
|
---|
| 203 | }
|
---|
| 204 |
|
---|
[fafb8e5] | 205 | sid = ipc_get_arg1(icall);
|
---|
[1626cd4] | 206 |
|
---|
| 207 | category_id_t *id_buf = (category_id_t *) malloc(size);
|
---|
| 208 | if (id_buf == NULL) {
|
---|
[984a9ba] | 209 | async_answer_0(&call, ENOMEM);
|
---|
| 210 | async_answer_0(icall, ENOMEM);
|
---|
[1626cd4] | 211 | return;
|
---|
| 212 | }
|
---|
| 213 |
|
---|
| 214 | rc = vbds_get_parts(sid, id_buf, size, &act_size);
|
---|
| 215 | if (rc != EOK) {
|
---|
[984a9ba] | 216 | async_answer_0(&call, rc);
|
---|
| 217 | async_answer_0(icall, rc);
|
---|
[1626cd4] | 218 | return;
|
---|
| 219 | }
|
---|
| 220 |
|
---|
[984a9ba] | 221 | errno_t retval = async_data_read_finalize(&call, id_buf, size);
|
---|
[1626cd4] | 222 | free(id_buf);
|
---|
| 223 |
|
---|
[984a9ba] | 224 | async_answer_1(icall, retval, act_size);
|
---|
[28ed0d95] | 225 | }
|
---|
| 226 |
|
---|
[984a9ba] | 227 | static void vbds_part_get_info_srv(ipc_call_t *icall)
|
---|
[28ed0d95] | 228 | {
|
---|
| 229 | vbds_part_id_t part;
|
---|
[6a0d4ce2] | 230 | vbd_part_info_t pinfo;
|
---|
[b7fd2a0] | 231 | errno_t rc;
|
---|
[22fb7ab] | 232 |
|
---|
[55f8c6e7] | 233 | log_msg(LOG_DEFAULT, LVL_DEBUG, "vbds_part_get_info_srv()");
|
---|
[22fb7ab] | 234 |
|
---|
[fafb8e5] | 235 | part = ipc_get_arg1(icall);
|
---|
[28ed0d95] | 236 | rc = vbds_part_get_info(part, &pinfo);
|
---|
[b7a4d06] | 237 | if (rc != EOK) {
|
---|
[984a9ba] | 238 | async_answer_0(icall, rc);
|
---|
[b7a4d06] | 239 | return;
|
---|
| 240 | }
|
---|
| 241 |
|
---|
[984a9ba] | 242 | ipc_call_t call;
|
---|
[b7a4d06] | 243 | size_t size;
|
---|
[984a9ba] | 244 | if (!async_data_read_receive(&call, &size)) {
|
---|
| 245 | async_answer_0(&call, EREFUSED);
|
---|
| 246 | async_answer_0(icall, EREFUSED);
|
---|
[b7a4d06] | 247 | return;
|
---|
| 248 | }
|
---|
| 249 |
|
---|
| 250 | if (size != sizeof(vbd_part_info_t)) {
|
---|
[984a9ba] | 251 | async_answer_0(&call, EINVAL);
|
---|
| 252 | async_answer_0(icall, EINVAL);
|
---|
[b7a4d06] | 253 | return;
|
---|
| 254 | }
|
---|
| 255 |
|
---|
[984a9ba] | 256 | rc = async_data_read_finalize(&call, &pinfo,
|
---|
[b7a4d06] | 257 | min(size, sizeof(pinfo)));
|
---|
| 258 | if (rc != EOK) {
|
---|
[984a9ba] | 259 | async_answer_0(&call, rc);
|
---|
| 260 | async_answer_0(icall, rc);
|
---|
[b7a4d06] | 261 | return;
|
---|
| 262 | }
|
---|
| 263 |
|
---|
[984a9ba] | 264 | async_answer_0(icall, EOK);
|
---|
[22fb7ab] | 265 | }
|
---|
| 266 |
|
---|
[984a9ba] | 267 | static void vbds_part_create_srv(ipc_call_t *icall)
|
---|
[22fb7ab] | 268 | {
|
---|
| 269 | service_id_t disk_sid;
|
---|
[6bc542b] | 270 | vbd_part_spec_t pspec;
|
---|
[28ed0d95] | 271 | vbds_part_id_t part;
|
---|
[b7fd2a0] | 272 | errno_t rc;
|
---|
[22fb7ab] | 273 |
|
---|
[55f8c6e7] | 274 | log_msg(LOG_DEFAULT, LVL_DEBUG, "vbds_part_create_srv()");
|
---|
[22fb7ab] | 275 |
|
---|
[fafb8e5] | 276 | disk_sid = ipc_get_arg1(icall);
|
---|
[6bc542b] | 277 |
|
---|
[984a9ba] | 278 | ipc_call_t call;
|
---|
[6bc542b] | 279 | size_t size;
|
---|
[984a9ba] | 280 | if (!async_data_write_receive(&call, &size)) {
|
---|
| 281 | async_answer_0(&call, EREFUSED);
|
---|
| 282 | async_answer_0(icall, EREFUSED);
|
---|
[6bc542b] | 283 | return;
|
---|
| 284 | }
|
---|
| 285 |
|
---|
| 286 | if (size != sizeof(vbd_part_spec_t)) {
|
---|
[984a9ba] | 287 | async_answer_0(&call, EINVAL);
|
---|
| 288 | async_answer_0(icall, EINVAL);
|
---|
[6bc542b] | 289 | return;
|
---|
| 290 | }
|
---|
| 291 |
|
---|
[984a9ba] | 292 | rc = async_data_write_finalize(&call, &pspec, sizeof(vbd_part_spec_t));
|
---|
[6bc542b] | 293 | if (rc != EOK) {
|
---|
[984a9ba] | 294 | async_answer_0(&call, rc);
|
---|
| 295 | async_answer_0(icall, rc);
|
---|
[6bc542b] | 296 | return;
|
---|
| 297 | }
|
---|
| 298 |
|
---|
| 299 | rc = vbds_part_create(disk_sid, &pspec, &part);
|
---|
| 300 | if (rc != EOK) {
|
---|
[984a9ba] | 301 | async_answer_0(icall, rc);
|
---|
[6bc542b] | 302 | return;
|
---|
| 303 | }
|
---|
| 304 |
|
---|
[984a9ba] | 305 | async_answer_1(icall, rc, (sysarg_t)part);
|
---|
[22fb7ab] | 306 | }
|
---|
| 307 |
|
---|
[984a9ba] | 308 | static void vbds_part_delete_srv(ipc_call_t *icall)
|
---|
[22fb7ab] | 309 | {
|
---|
[28ed0d95] | 310 | vbds_part_id_t part;
|
---|
[b7fd2a0] | 311 | errno_t rc;
|
---|
[22fb7ab] | 312 |
|
---|
[55f8c6e7] | 313 | log_msg(LOG_DEFAULT, LVL_DEBUG, "vbds_part_delete_srv()");
|
---|
[22fb7ab] | 314 |
|
---|
[fafb8e5] | 315 | part = ipc_get_arg1(icall);
|
---|
[28ed0d95] | 316 | rc = vbds_part_delete(part);
|
---|
[984a9ba] | 317 | async_answer_0(icall, rc);
|
---|
[22fb7ab] | 318 | }
|
---|
[1356f85a] | 319 |
|
---|
[984a9ba] | 320 | static void vbds_suggest_ptype_srv(ipc_call_t *icall)
|
---|
[f57ccb5] | 321 | {
|
---|
| 322 | service_id_t disk_sid;
|
---|
| 323 | label_ptype_t ptype;
|
---|
| 324 | label_pcnt_t pcnt;
|
---|
[b7fd2a0] | 325 | errno_t rc;
|
---|
[f57ccb5] | 326 |
|
---|
[55f8c6e7] | 327 | log_msg(LOG_DEFAULT, LVL_DEBUG, "vbds_suggest_ptype_srv()");
|
---|
[f57ccb5] | 328 |
|
---|
[fafb8e5] | 329 | disk_sid = ipc_get_arg1(icall);
|
---|
| 330 | pcnt = ipc_get_arg2(icall);
|
---|
[f57ccb5] | 331 |
|
---|
| 332 | rc = vbds_suggest_ptype(disk_sid, pcnt, &ptype);
|
---|
| 333 | if (rc != EOK) {
|
---|
[984a9ba] | 334 | async_answer_0(icall, rc);
|
---|
[f57ccb5] | 335 | return;
|
---|
| 336 | }
|
---|
| 337 |
|
---|
[984a9ba] | 338 | ipc_call_t call;
|
---|
[f57ccb5] | 339 | size_t size;
|
---|
[984a9ba] | 340 | if (!async_data_read_receive(&call, &size)) {
|
---|
| 341 | async_answer_0(&call, EREFUSED);
|
---|
| 342 | async_answer_0(icall, EREFUSED);
|
---|
[f57ccb5] | 343 | return;
|
---|
| 344 | }
|
---|
| 345 |
|
---|
| 346 | if (size != sizeof(label_ptype_t)) {
|
---|
[984a9ba] | 347 | async_answer_0(&call, EINVAL);
|
---|
| 348 | async_answer_0(icall, EINVAL);
|
---|
[f57ccb5] | 349 | return;
|
---|
| 350 | }
|
---|
| 351 |
|
---|
[984a9ba] | 352 | rc = async_data_read_finalize(&call, &ptype, sizeof(label_ptype_t));
|
---|
[f57ccb5] | 353 | if (rc != EOK) {
|
---|
[984a9ba] | 354 | async_answer_0(&call, rc);
|
---|
| 355 | async_answer_0(icall, rc);
|
---|
[f57ccb5] | 356 | return;
|
---|
| 357 | }
|
---|
| 358 |
|
---|
[984a9ba] | 359 | async_answer_0(icall, EOK);
|
---|
[f57ccb5] | 360 | }
|
---|
| 361 |
|
---|
[984a9ba] | 362 | static void vbds_ctl_conn(ipc_call_t *icall, void *arg)
|
---|
[1356f85a] | 363 | {
|
---|
[55f8c6e7] | 364 | log_msg(LOG_DEFAULT, LVL_DEBUG, "vbds_client_conn()");
|
---|
[1356f85a] | 365 |
|
---|
| 366 | /* Accept the connection */
|
---|
[beb83c1] | 367 | async_accept_0(icall);
|
---|
[1356f85a] | 368 |
|
---|
| 369 | while (true) {
|
---|
| 370 | ipc_call_t call;
|
---|
[984a9ba] | 371 | async_get_call(&call);
|
---|
[fafb8e5] | 372 | sysarg_t method = ipc_get_imethod(&call);
|
---|
[1356f85a] | 373 |
|
---|
| 374 | if (!method) {
|
---|
| 375 | /* The other side has hung up */
|
---|
[984a9ba] | 376 | async_answer_0(&call, EOK);
|
---|
[1356f85a] | 377 | return;
|
---|
| 378 | }
|
---|
| 379 |
|
---|
| 380 | switch (method) {
|
---|
[372df8f] | 381 | case VBD_GET_DISKS:
|
---|
[984a9ba] | 382 | vbds_get_disks_srv(&call);
|
---|
[22fb7ab] | 383 | break;
|
---|
| 384 | case VBD_DISK_INFO:
|
---|
[984a9ba] | 385 | vbds_disk_info_srv(&call);
|
---|
[22fb7ab] | 386 | break;
|
---|
| 387 | case VBD_LABEL_CREATE:
|
---|
[984a9ba] | 388 | vbds_label_create_srv(&call);
|
---|
[22fb7ab] | 389 | break;
|
---|
| 390 | case VBD_LABEL_DELETE:
|
---|
[984a9ba] | 391 | vbds_label_delete_srv(&call);
|
---|
[28ed0d95] | 392 | break;
|
---|
| 393 | case VBD_LABEL_GET_PARTS:
|
---|
[984a9ba] | 394 | vbds_label_get_parts_srv(&call);
|
---|
[28ed0d95] | 395 | break;
|
---|
| 396 | case VBD_PART_GET_INFO:
|
---|
[984a9ba] | 397 | vbds_part_get_info_srv(&call);
|
---|
[28ed0d95] | 398 | break;
|
---|
| 399 | case VBD_PART_CREATE:
|
---|
[984a9ba] | 400 | vbds_part_create_srv(&call);
|
---|
[28ed0d95] | 401 | break;
|
---|
| 402 | case VBD_PART_DELETE:
|
---|
[984a9ba] | 403 | vbds_part_delete_srv(&call);
|
---|
[22fb7ab] | 404 | break;
|
---|
[f57ccb5] | 405 | case VBD_SUGGEST_PTYPE:
|
---|
[984a9ba] | 406 | vbds_suggest_ptype_srv(&call);
|
---|
[f57ccb5] | 407 | break;
|
---|
[1356f85a] | 408 | default:
|
---|
[984a9ba] | 409 | async_answer_0(&call, EINVAL);
|
---|
[1356f85a] | 410 | }
|
---|
| 411 | }
|
---|
| 412 | }
|
---|
| 413 |
|
---|
[984a9ba] | 414 | static void vbds_client_conn(ipc_call_t *icall, void *arg)
|
---|
[78d50bd] | 415 | {
|
---|
| 416 | service_id_t sid;
|
---|
| 417 |
|
---|
[55f8c6e7] | 418 | log_msg(LOG_DEFAULT, LVL_DEBUG, "vbds_client_conn()");
|
---|
[78d50bd] | 419 |
|
---|
[fafb8e5] | 420 | sid = (service_id_t) ipc_get_arg2(icall);
|
---|
[78d50bd] | 421 |
|
---|
| 422 | if (sid == ctl_sid)
|
---|
[984a9ba] | 423 | vbds_ctl_conn(icall, arg);
|
---|
[78d50bd] | 424 | else
|
---|
[984a9ba] | 425 | vbds_bd_conn(icall, arg);
|
---|
[78d50bd] | 426 | }
|
---|
| 427 |
|
---|
[1356f85a] | 428 | int main(int argc, char *argv[])
|
---|
| 429 | {
|
---|
[b7fd2a0] | 430 | errno_t rc;
|
---|
[1356f85a] | 431 |
|
---|
| 432 | printf("%s: Virtual Block Device service\n", NAME);
|
---|
| 433 |
|
---|
| 434 | if (log_init(NAME) != EOK) {
|
---|
| 435 | printf(NAME ": Failed to initialize logging.\n");
|
---|
| 436 | return 1;
|
---|
| 437 | }
|
---|
| 438 |
|
---|
[28ed0d95] | 439 | rc = vbds_init();
|
---|
[1356f85a] | 440 | if (rc != EOK)
|
---|
| 441 | return 1;
|
---|
| 442 |
|
---|
| 443 | printf(NAME ": Accepting connections.\n");
|
---|
| 444 | task_retval(0);
|
---|
| 445 | async_manager();
|
---|
| 446 |
|
---|
| 447 | return 0;
|
---|
| 448 | }
|
---|
| 449 |
|
---|
| 450 | /** @}
|
---|
| 451 | */
|
---|