[1356f85a] | 1 | /*
|
---|
| 2 | * Copyright (c) 2015 Jiri Svoboda
|
---|
| 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 |
|
---|
| 29 | /** @addtogroup volsrv
|
---|
| 30 | * @{
|
---|
| 31 | */
|
---|
| 32 | /**
|
---|
| 33 | * @file Volume service
|
---|
| 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/vol.h>
|
---|
[1356f85a] | 42 | #include <loc.h>
|
---|
[0ecfc62] | 43 | #include <macros.h>
|
---|
[1356f85a] | 44 | #include <stdio.h>
|
---|
| 45 | #include <stdlib.h>
|
---|
| 46 | #include <task.h>
|
---|
[edebb4a1] | 47 | #include <types/vol.h>
|
---|
[1356f85a] | 48 |
|
---|
[9c2c7d2] | 49 | #include "mkfs.h"
|
---|
[372df8f] | 50 | #include "part.h"
|
---|
[64ffd83] | 51 | #include "volume.h"
|
---|
[1356f85a] | 52 |
|
---|
| 53 | #define NAME "volsrv"
|
---|
| 54 |
|
---|
[984a9ba] | 55 | static void vol_client_conn(ipc_call_t *, void *);
|
---|
[1356f85a] | 56 |
|
---|
[b7fd2a0] | 57 | static errno_t vol_init(void)
|
---|
[1356f85a] | 58 | {
|
---|
[b7fd2a0] | 59 | errno_t rc;
|
---|
[64ffd83] | 60 | vol_volumes_t *volumes = NULL;
|
---|
[e89a06a] | 61 | vol_parts_t *parts = NULL;
|
---|
| 62 |
|
---|
[1356f85a] | 63 | log_msg(LOG_DEFAULT, LVL_DEBUG, "vol_init()");
|
---|
| 64 |
|
---|
[64ffd83] | 65 | rc = vol_volumes_create(&volumes);
|
---|
| 66 | if (rc != EOK)
|
---|
| 67 | goto error;
|
---|
| 68 |
|
---|
| 69 | rc = vol_parts_create(volumes, &parts);
|
---|
[22fb7ab] | 70 | if (rc != EOK)
|
---|
[e89a06a] | 71 | goto error;
|
---|
[22fb7ab] | 72 |
|
---|
[e89a06a] | 73 | rc = vol_part_discovery_start(parts);
|
---|
[1356f85a] | 74 | if (rc != EOK)
|
---|
[e89a06a] | 75 | goto error;
|
---|
[1356f85a] | 76 |
|
---|
[e89a06a] | 77 | async_set_fallback_port_handler(vol_client_conn, parts);
|
---|
[1356f85a] | 78 |
|
---|
| 79 | rc = loc_server_register(NAME);
|
---|
| 80 | if (rc != EOK) {
|
---|
[c1694b6b] | 81 | log_msg(LOG_DEFAULT, LVL_ERROR, "Failed registering server: %s.", str_error(rc));
|
---|
[e89a06a] | 82 | rc = EEXIST;
|
---|
[1356f85a] | 83 | }
|
---|
| 84 |
|
---|
| 85 | service_id_t sid;
|
---|
| 86 | rc = loc_service_register(SERVICE_NAME_VOLSRV, &sid);
|
---|
| 87 | if (rc != EOK) {
|
---|
[c1694b6b] | 88 | log_msg(LOG_DEFAULT, LVL_ERROR, "Failed registering service: %s.", str_error(rc));
|
---|
[e89a06a] | 89 | rc = EEXIST;
|
---|
| 90 | goto error;
|
---|
[1356f85a] | 91 | }
|
---|
| 92 |
|
---|
| 93 | return EOK;
|
---|
[e89a06a] | 94 | error:
|
---|
[64ffd83] | 95 | vol_volumes_destroy(volumes);
|
---|
[e89a06a] | 96 | vol_parts_destroy(parts);
|
---|
| 97 | return rc;
|
---|
[1356f85a] | 98 | }
|
---|
| 99 |
|
---|
[e89a06a] | 100 | static void vol_get_parts_srv(vol_parts_t *parts, ipc_call_t *icall)
|
---|
[22fb7ab] | 101 | {
|
---|
[984a9ba] | 102 | ipc_call_t call;
|
---|
[22fb7ab] | 103 | size_t size;
|
---|
| 104 | size_t act_size;
|
---|
[b7fd2a0] | 105 | errno_t rc;
|
---|
[22fb7ab] | 106 |
|
---|
[984a9ba] | 107 | if (!async_data_read_receive(&call, &size)) {
|
---|
| 108 | async_answer_0(&call, EREFUSED);
|
---|
| 109 | async_answer_0(icall, EREFUSED);
|
---|
[22fb7ab] | 110 | return;
|
---|
| 111 | }
|
---|
| 112 |
|
---|
| 113 | service_id_t *id_buf = (service_id_t *) malloc(size);
|
---|
| 114 | if (id_buf == NULL) {
|
---|
[984a9ba] | 115 | async_answer_0(&call, ENOMEM);
|
---|
| 116 | async_answer_0(icall, ENOMEM);
|
---|
[22fb7ab] | 117 | return;
|
---|
| 118 | }
|
---|
| 119 |
|
---|
[e89a06a] | 120 | rc = vol_part_get_ids(parts, id_buf, size, &act_size);
|
---|
[22fb7ab] | 121 | if (rc != EOK) {
|
---|
[984a9ba] | 122 | async_answer_0(&call, rc);
|
---|
| 123 | async_answer_0(icall, rc);
|
---|
[22fb7ab] | 124 | return;
|
---|
| 125 | }
|
---|
| 126 |
|
---|
[984a9ba] | 127 | errno_t retval = async_data_read_finalize(&call, id_buf, size);
|
---|
[22fb7ab] | 128 | free(id_buf);
|
---|
| 129 |
|
---|
[984a9ba] | 130 | async_answer_1(icall, retval, act_size);
|
---|
[22fb7ab] | 131 | }
|
---|
| 132 |
|
---|
[e89a06a] | 133 | static void vol_part_add_srv(vol_parts_t *parts, ipc_call_t *icall)
|
---|
[edebb4a1] | 134 | {
|
---|
| 135 | service_id_t sid;
|
---|
[b7fd2a0] | 136 | errno_t rc;
|
---|
[edebb4a1] | 137 |
|
---|
| 138 | sid = IPC_GET_ARG1(*icall);
|
---|
| 139 |
|
---|
[64ffd83] | 140 | rc = vol_part_add_part(parts, sid);
|
---|
[edebb4a1] | 141 | if (rc != EOK) {
|
---|
[984a9ba] | 142 | async_answer_0(icall, rc);
|
---|
[edebb4a1] | 143 | return;
|
---|
| 144 | }
|
---|
| 145 |
|
---|
[984a9ba] | 146 | async_answer_0(icall, EOK);
|
---|
[edebb4a1] | 147 | }
|
---|
| 148 |
|
---|
[e89a06a] | 149 | static void vol_part_info_srv(vol_parts_t *parts, ipc_call_t *icall)
|
---|
[22fb7ab] | 150 | {
|
---|
| 151 | service_id_t sid;
|
---|
[372df8f] | 152 | vol_part_t *part;
|
---|
| 153 | vol_part_info_t pinfo;
|
---|
[b7fd2a0] | 154 | errno_t rc;
|
---|
[22fb7ab] | 155 |
|
---|
| 156 | sid = IPC_GET_ARG1(*icall);
|
---|
[55f8c6e7] | 157 | log_msg(LOG_DEFAULT, LVL_DEBUG, "vol_part_info_srv(%zu)",
|
---|
[edebb4a1] | 158 | sid);
|
---|
[e89a06a] | 159 | rc = vol_part_find_by_id_ref(parts, sid, &part);
|
---|
[22fb7ab] | 160 | if (rc != EOK) {
|
---|
[984a9ba] | 161 | async_answer_0(icall, ENOENT);
|
---|
[22fb7ab] | 162 | return;
|
---|
| 163 | }
|
---|
| 164 |
|
---|
[372df8f] | 165 | rc = vol_part_get_info(part, &pinfo);
|
---|
[b7a4d06] | 166 | if (rc != EOK) {
|
---|
[984a9ba] | 167 | async_answer_0(icall, EIO);
|
---|
[1a9174e] | 168 | goto error;
|
---|
[b7a4d06] | 169 | }
|
---|
| 170 |
|
---|
[984a9ba] | 171 | ipc_call_t call;
|
---|
[0ecfc62] | 172 | size_t size;
|
---|
[984a9ba] | 173 | if (!async_data_read_receive(&call, &size)) {
|
---|
| 174 | async_answer_0(&call, EREFUSED);
|
---|
| 175 | async_answer_0(icall, EREFUSED);
|
---|
[1a9174e] | 176 | goto error;
|
---|
[0ecfc62] | 177 | }
|
---|
| 178 |
|
---|
| 179 | if (size != sizeof(vol_part_info_t)) {
|
---|
[984a9ba] | 180 | async_answer_0(&call, EINVAL);
|
---|
| 181 | async_answer_0(icall, EINVAL);
|
---|
[1a9174e] | 182 | goto error;
|
---|
[0ecfc62] | 183 | }
|
---|
| 184 |
|
---|
[984a9ba] | 185 | rc = async_data_read_finalize(&call, &pinfo,
|
---|
[0ecfc62] | 186 | min(size, sizeof(pinfo)));
|
---|
| 187 | if (rc != EOK) {
|
---|
[984a9ba] | 188 | async_answer_0(&call, rc);
|
---|
| 189 | async_answer_0(icall, rc);
|
---|
[1a9174e] | 190 | goto error;
|
---|
[0ecfc62] | 191 | }
|
---|
| 192 |
|
---|
[984a9ba] | 193 | async_answer_0(icall, EOK);
|
---|
[1a9174e] | 194 | error:
|
---|
| 195 | vol_part_del_ref(part);
|
---|
[22fb7ab] | 196 | }
|
---|
| 197 |
|
---|
[e89a06a] | 198 | static void vol_part_eject_srv(vol_parts_t *parts, ipc_call_t *icall)
|
---|
[72c72d4] | 199 | {
|
---|
| 200 | service_id_t sid;
|
---|
| 201 | vol_part_t *part;
|
---|
| 202 | errno_t rc;
|
---|
| 203 |
|
---|
| 204 | sid = IPC_GET_ARG1(*icall);
|
---|
| 205 | log_msg(LOG_DEFAULT, LVL_DEBUG, "vol_part_eject_srv(%zu)", sid);
|
---|
| 206 |
|
---|
[e89a06a] | 207 | rc = vol_part_find_by_id_ref(parts, sid, &part);
|
---|
[72c72d4] | 208 | if (rc != EOK) {
|
---|
[984a9ba] | 209 | async_answer_0(icall, ENOENT);
|
---|
[1a9174e] | 210 | goto error;
|
---|
[72c72d4] | 211 | }
|
---|
| 212 |
|
---|
| 213 | rc = vol_part_eject_part(part);
|
---|
| 214 | if (rc != EOK) {
|
---|
[984a9ba] | 215 | async_answer_0(icall, EIO);
|
---|
[1a9174e] | 216 | goto error;
|
---|
[72c72d4] | 217 | }
|
---|
| 218 |
|
---|
[984a9ba] | 219 | async_answer_0(icall, EOK);
|
---|
[1a9174e] | 220 | error:
|
---|
| 221 | vol_part_del_ref(part);
|
---|
[72c72d4] | 222 | }
|
---|
| 223 |
|
---|
[e89a06a] | 224 | static void vol_part_empty_srv(vol_parts_t *parts, ipc_call_t *icall)
|
---|
[22fb7ab] | 225 | {
|
---|
| 226 | service_id_t sid;
|
---|
[372df8f] | 227 | vol_part_t *part;
|
---|
[b7fd2a0] | 228 | errno_t rc;
|
---|
[22fb7ab] | 229 |
|
---|
| 230 | sid = IPC_GET_ARG1(*icall);
|
---|
[55f8c6e7] | 231 | log_msg(LOG_DEFAULT, LVL_DEBUG, "vol_part_empty_srv(%zu)", sid);
|
---|
[22fb7ab] | 232 |
|
---|
[e89a06a] | 233 | rc = vol_part_find_by_id_ref(parts, sid, &part);
|
---|
[22fb7ab] | 234 | if (rc != EOK) {
|
---|
[984a9ba] | 235 | async_answer_0(icall, ENOENT);
|
---|
[22fb7ab] | 236 | return;
|
---|
| 237 | }
|
---|
| 238 |
|
---|
[372df8f] | 239 | rc = vol_part_empty_part(part);
|
---|
[603c1d1f] | 240 | if (rc != EOK) {
|
---|
[984a9ba] | 241 | async_answer_0(icall, EIO);
|
---|
[1a9174e] | 242 | goto error;
|
---|
[603c1d1f] | 243 | }
|
---|
[22fb7ab] | 244 |
|
---|
[984a9ba] | 245 | async_answer_0(icall, EOK);
|
---|
[1a9174e] | 246 | error:
|
---|
| 247 | vol_part_del_ref(part);
|
---|
[22fb7ab] | 248 | }
|
---|
[1356f85a] | 249 |
|
---|
[e89a06a] | 250 | static void vol_part_get_lsupp_srv(vol_parts_t *parts, ipc_call_t *icall)
|
---|
[9c2c7d2] | 251 | {
|
---|
| 252 | vol_fstype_t fstype;
|
---|
| 253 | vol_label_supp_t vlsupp;
|
---|
[b7fd2a0] | 254 | errno_t rc;
|
---|
[9c2c7d2] | 255 |
|
---|
| 256 | fstype = IPC_GET_ARG1(*icall);
|
---|
| 257 | log_msg(LOG_DEFAULT, LVL_DEBUG, "vol_part_get_lsupp_srv(%u)",
|
---|
| 258 | fstype);
|
---|
| 259 |
|
---|
| 260 | volsrv_part_get_lsupp(fstype, &vlsupp);
|
---|
| 261 |
|
---|
[984a9ba] | 262 | ipc_call_t call;
|
---|
[9c2c7d2] | 263 | size_t size;
|
---|
[984a9ba] | 264 | if (!async_data_read_receive(&call, &size)) {
|
---|
| 265 | async_answer_0(&call, EREFUSED);
|
---|
| 266 | async_answer_0(icall, EREFUSED);
|
---|
[9c2c7d2] | 267 | return;
|
---|
| 268 | }
|
---|
| 269 |
|
---|
| 270 | if (size != sizeof(vol_label_supp_t)) {
|
---|
[984a9ba] | 271 | async_answer_0(&call, EINVAL);
|
---|
| 272 | async_answer_0(icall, EINVAL);
|
---|
[9c2c7d2] | 273 | return;
|
---|
| 274 | }
|
---|
| 275 |
|
---|
[984a9ba] | 276 | rc = async_data_read_finalize(&call, &vlsupp,
|
---|
[9c2c7d2] | 277 | min(size, sizeof(vlsupp)));
|
---|
| 278 | if (rc != EOK) {
|
---|
[984a9ba] | 279 | async_answer_0(&call, rc);
|
---|
| 280 | async_answer_0(icall, rc);
|
---|
[9c2c7d2] | 281 | return;
|
---|
| 282 | }
|
---|
| 283 |
|
---|
[984a9ba] | 284 | async_answer_0(icall, EOK);
|
---|
[9c2c7d2] | 285 | }
|
---|
| 286 |
|
---|
[e89a06a] | 287 | static void vol_part_mkfs_srv(vol_parts_t *parts, ipc_call_t *icall)
|
---|
[44fe800] | 288 | {
|
---|
| 289 | service_id_t sid;
|
---|
| 290 | vol_part_t *part;
|
---|
| 291 | vol_fstype_t fstype;
|
---|
[2d78d88] | 292 | char *label = NULL;
|
---|
| 293 | char *mountp = NULL;
|
---|
[b7fd2a0] | 294 | errno_t rc;
|
---|
[44fe800] | 295 |
|
---|
[5f36841] | 296 | log_msg(LOG_DEFAULT, LVL_NOTE, "vol_part_mkfs_srv()");
|
---|
| 297 |
|
---|
[44fe800] | 298 | sid = IPC_GET_ARG1(*icall);
|
---|
| 299 | fstype = IPC_GET_ARG2(*icall);
|
---|
| 300 |
|
---|
[9c2c7d2] | 301 | rc = async_data_write_accept((void **)&label, true, 0, VOL_LABEL_MAXLEN,
|
---|
| 302 | 0, NULL);
|
---|
| 303 | if (rc != EOK) {
|
---|
[984a9ba] | 304 | async_answer_0(icall, rc);
|
---|
[2d78d88] | 305 | goto error;
|
---|
[9c2c7d2] | 306 | }
|
---|
| 307 |
|
---|
[5f36841] | 308 | if (label != NULL) {
|
---|
| 309 | log_msg(LOG_DEFAULT, LVL_NOTE, "vol_part_mkfs_srv: label='%s'",
|
---|
| 310 | label);
|
---|
| 311 | }
|
---|
[9c2c7d2] | 312 |
|
---|
[64ffd83] | 313 | rc = async_data_write_accept((void **)&mountp, true, 0, VOL_MOUNTP_MAXLEN,
|
---|
| 314 | 0, NULL);
|
---|
| 315 | if (rc != EOK) {
|
---|
| 316 | async_answer_0(icall, rc);
|
---|
[2d78d88] | 317 | goto error;
|
---|
[64ffd83] | 318 | }
|
---|
| 319 |
|
---|
| 320 | if (mountp != NULL) {
|
---|
| 321 | log_msg(LOG_DEFAULT, LVL_NOTE, "vol_part_mkfs_srv: mountp='%s'",
|
---|
| 322 | mountp);
|
---|
| 323 | }
|
---|
| 324 |
|
---|
[e89a06a] | 325 | rc = vol_part_find_by_id_ref(parts, sid, &part);
|
---|
[44fe800] | 326 | if (rc != EOK) {
|
---|
[984a9ba] | 327 | async_answer_0(icall, ENOENT);
|
---|
[2d78d88] | 328 | goto error;
|
---|
[44fe800] | 329 | }
|
---|
| 330 |
|
---|
[64ffd83] | 331 | rc = vol_part_mkfs_part(part, fstype, label, mountp);
|
---|
[44fe800] | 332 | if (rc != EOK) {
|
---|
[2d78d88] | 333 | async_answer_0(icall, rc);
|
---|
| 334 | vol_part_del_ref(part);
|
---|
| 335 | goto error;
|
---|
| 336 | }
|
---|
| 337 |
|
---|
| 338 | free(label);
|
---|
| 339 | free(mountp);
|
---|
| 340 | async_answer_0(icall, EOK);
|
---|
| 341 |
|
---|
| 342 | return;
|
---|
| 343 | error:
|
---|
| 344 | if (label != NULL)
|
---|
[9c2c7d2] | 345 | free(label);
|
---|
[2d78d88] | 346 | if (mountp != NULL)
|
---|
| 347 | free(mountp);
|
---|
| 348 | }
|
---|
| 349 |
|
---|
| 350 | static void vol_part_set_mountp_srv(vol_parts_t *parts,
|
---|
| 351 | ipc_call_t *icall)
|
---|
| 352 | {
|
---|
| 353 | service_id_t sid;
|
---|
| 354 | vol_part_t *part;
|
---|
| 355 | char *mountp;
|
---|
| 356 | errno_t rc;
|
---|
| 357 |
|
---|
| 358 | log_msg(LOG_DEFAULT, LVL_NOTE, "vol_part_set_mountp_srv()");
|
---|
| 359 |
|
---|
| 360 | sid = IPC_GET_ARG1(*icall);
|
---|
| 361 |
|
---|
| 362 | rc = async_data_write_accept((void **)&mountp, true, 0,
|
---|
| 363 | VOL_MOUNTP_MAXLEN, 0, NULL);
|
---|
| 364 | if (rc != EOK) {
|
---|
| 365 | async_answer_0(icall, rc);
|
---|
| 366 | return;
|
---|
| 367 | }
|
---|
| 368 |
|
---|
| 369 | if (mountp != NULL) {
|
---|
| 370 | log_msg(LOG_DEFAULT, LVL_NOTE,
|
---|
| 371 | "vol_part_set_mountp_srv: mountp='%s'", mountp);
|
---|
| 372 | }
|
---|
| 373 |
|
---|
| 374 | rc = vol_part_find_by_id_ref(parts, sid, &part);
|
---|
| 375 | if (rc != EOK) {
|
---|
| 376 | free(mountp);
|
---|
| 377 | async_answer_0(icall, ENOENT);
|
---|
| 378 | return;
|
---|
| 379 | }
|
---|
| 380 |
|
---|
| 381 | rc = vol_part_set_mountp_part(part, mountp);
|
---|
| 382 | if (rc != EOK) {
|
---|
| 383 | free(mountp);
|
---|
[984a9ba] | 384 | async_answer_0(icall, rc);
|
---|
[1a9174e] | 385 | vol_part_del_ref(part);
|
---|
[44fe800] | 386 | return;
|
---|
| 387 | }
|
---|
| 388 |
|
---|
[2d78d88] | 389 | free(mountp);
|
---|
[984a9ba] | 390 | async_answer_0(icall, EOK);
|
---|
[44fe800] | 391 | }
|
---|
| 392 |
|
---|
[984a9ba] | 393 | static void vol_client_conn(ipc_call_t *icall, void *arg)
|
---|
[1356f85a] | 394 | {
|
---|
[e89a06a] | 395 | vol_parts_t *parts = (vol_parts_t *) arg;
|
---|
| 396 |
|
---|
[1356f85a] | 397 | log_msg(LOG_DEFAULT, LVL_DEBUG, "vol_client_conn()");
|
---|
| 398 |
|
---|
| 399 | /* Accept the connection */
|
---|
[984a9ba] | 400 | async_answer_0(icall, EOK);
|
---|
[1356f85a] | 401 |
|
---|
| 402 | while (true) {
|
---|
| 403 | ipc_call_t call;
|
---|
[984a9ba] | 404 | async_get_call(&call);
|
---|
[1356f85a] | 405 | sysarg_t method = IPC_GET_IMETHOD(call);
|
---|
| 406 |
|
---|
| 407 | if (!method) {
|
---|
| 408 | /* The other side has hung up */
|
---|
[984a9ba] | 409 | async_answer_0(&call, EOK);
|
---|
[1356f85a] | 410 | return;
|
---|
| 411 | }
|
---|
| 412 |
|
---|
| 413 | switch (method) {
|
---|
[372df8f] | 414 | case VOL_GET_PARTS:
|
---|
[e89a06a] | 415 | vol_get_parts_srv(parts, &call);
|
---|
[22fb7ab] | 416 | break;
|
---|
[edebb4a1] | 417 | case VOL_PART_ADD:
|
---|
[e89a06a] | 418 | vol_part_add_srv(parts, &call);
|
---|
[edebb4a1] | 419 | break;
|
---|
[372df8f] | 420 | case VOL_PART_INFO:
|
---|
[e89a06a] | 421 | vol_part_info_srv(parts, &call);
|
---|
[22fb7ab] | 422 | break;
|
---|
[72c72d4] | 423 | case VOL_PART_EJECT:
|
---|
[e89a06a] | 424 | vol_part_eject_srv(parts, &call);
|
---|
[72c72d4] | 425 | break;
|
---|
[372df8f] | 426 | case VOL_PART_EMPTY:
|
---|
[e89a06a] | 427 | vol_part_empty_srv(parts, &call);
|
---|
[22fb7ab] | 428 | break;
|
---|
[9c2c7d2] | 429 | case VOL_PART_LSUPP:
|
---|
[e89a06a] | 430 | vol_part_get_lsupp_srv(parts, &call);
|
---|
[9c2c7d2] | 431 | break;
|
---|
[44fe800] | 432 | case VOL_PART_MKFS:
|
---|
[e89a06a] | 433 | vol_part_mkfs_srv(parts, &call);
|
---|
[44fe800] | 434 | break;
|
---|
[2d78d88] | 435 | case VOL_PART_SET_MOUNTP:
|
---|
| 436 | vol_part_set_mountp_srv(parts, &call);
|
---|
| 437 | break;
|
---|
[1356f85a] | 438 | default:
|
---|
[984a9ba] | 439 | async_answer_0(&call, EINVAL);
|
---|
[1356f85a] | 440 | }
|
---|
| 441 | }
|
---|
| 442 | }
|
---|
| 443 |
|
---|
| 444 | int main(int argc, char *argv[])
|
---|
| 445 | {
|
---|
[b7fd2a0] | 446 | errno_t rc;
|
---|
[1356f85a] | 447 |
|
---|
| 448 | printf("%s: Volume service\n", NAME);
|
---|
| 449 |
|
---|
| 450 | if (log_init(NAME) != EOK) {
|
---|
| 451 | printf(NAME ": Failed to initialize logging.\n");
|
---|
| 452 | return 1;
|
---|
| 453 | }
|
---|
| 454 |
|
---|
| 455 | rc = vol_init();
|
---|
| 456 | if (rc != EOK)
|
---|
| 457 | return 1;
|
---|
| 458 |
|
---|
| 459 | printf(NAME ": Accepting connections.\n");
|
---|
| 460 | task_retval(0);
|
---|
| 461 | async_manager();
|
---|
| 462 |
|
---|
| 463 | return 0;
|
---|
| 464 | }
|
---|
| 465 |
|
---|
| 466 | /** @}
|
---|
| 467 | */
|
---|