Changeset 1626cd4 in mainline
- Timestamp:
- 2015-07-02T19:01:37Z (9 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 6a0d4ce2
- Parents:
- 3faa03d
- Location:
- uspace
- Files:
-
- 14 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/c/generic/vbd.c
r3faa03d r1626cd4 37 37 #include <ipc/vbd.h> 38 38 #include <loc.h> 39 #include <macros.h> 39 40 #include <mem.h> 40 41 #include <stdlib.h> … … 106 107 } 107 108 109 #include <io/log.h> 108 110 /** Get disk information. */ 109 111 int vbd_disk_info(vbd_t *vbd, service_id_t sid, vbd_disk_info_t *vinfo) 110 112 { 111 113 async_exch_t *exch; 112 sysarg_t ltype; 113 int retval; 114 115 exch = async_exchange_begin(vbd->sess); 116 retval = async_req_1_1(exch, VBD_DISK_INFO, sid, <ype); 117 async_exchange_end(exch); 118 119 if (retval != EOK) 120 return EIO; 121 122 vinfo->ltype = (label_type_t)ltype; 114 sysarg_t retval; 115 ipc_call_t answer; 116 117 log_msg(LOG_DEFAULT, LVL_DEBUG, "vbd_disk_info() begin exchange"); 118 exch = async_exchange_begin(vbd->sess); 119 aid_t req = async_send_1(exch, VBD_DISK_INFO, sid, &answer); 120 log_msg(LOG_DEFAULT, LVL_DEBUG, "vbd_disk_info() read start"); 121 int rc = async_data_read_start(exch, vinfo, sizeof(vbd_disk_info_t)); 122 log_msg(LOG_DEFAULT, LVL_DEBUG, "vbd_disk_info() end exch"); 123 async_exchange_end(exch); 124 125 if (rc != EOK) { 126 async_forget(req); 127 return EIO; 128 } 129 130 log_msg(LOG_DEFAULT, LVL_DEBUG, "vbd_disk_info() wait fore req reply"); 131 async_wait_for(req, &retval); 132 if (retval != EOK) 133 return EIO; 134 135 log_msg(LOG_DEFAULT, LVL_DEBUG, "vbd_disk_info() done"); 123 136 return EOK; 124 137 } … … 257 270 { 258 271 async_exch_t *exch; 259 int retval; 260 261 exch = async_exchange_begin(vbd->sess); 262 retval = async_req_1_0(exch, VBD_PART_GET_INFO, part); 263 async_exchange_end(exch); 264 265 if (retval != EOK) 266 return EIO; 267 272 sysarg_t index; 273 sysarg_t b0_lo, b0_hi; 274 sysarg_t nb_lo, nb_hi; 275 int retval; 276 277 exch = async_exchange_begin(vbd->sess); 278 retval = async_req_1_5(exch, VBD_PART_GET_INFO, part, &index, 279 &b0_lo, &b0_hi, &nb_lo, &nb_hi); 280 async_exchange_end(exch); 281 282 if (retval != EOK) 283 return EIO; 284 285 pinfo->index = index; 286 pinfo->block0 = MERGE_LOUP32(b0_lo, b0_hi); 287 pinfo->nblocks = MERGE_LOUP32(nb_lo, nb_hi); 268 288 return EOK; 269 289 } -
uspace/lib/c/include/vbd.h
r3faa03d r1626cd4 39 39 #include <loc.h> 40 40 #include <types/label.h> 41 #include <sys/types.h> 41 42 42 43 /** VBD service */ … … 50 51 /** Label type */ 51 52 label_type_t ltype; 53 /** First block that can be allocated */ 54 aoff64_t ablock0; 55 /** Number of blocks that can be allocated */ 56 aoff64_t anblocks; 57 /** Block size */ 58 size_t block_size; 52 59 } vbd_disk_info_t; 53 60 … … 56 63 57 64 typedef struct { 65 /** Partition index */ 66 int index; 67 /** First block */ 68 aoff64_t block0; 69 /** Number of blocks */ 70 aoff64_t nblocks; 58 71 } vbd_part_info_t; 59 72 -
uspace/lib/fdisk/include/types/fdisk.h
r3faa03d r1626cd4 106 106 /** Service ID */ 107 107 service_id_t sid; 108 /** Partitions */ 109 list_t parts; /* of fdisk_part_t */ 108 /** Partitions sorted by index */ 109 list_t parts_idx; /* of fdisk_part_t */ 110 /** Partitions sorted by block address */ 111 list_t parts_ba; 112 /** Disk info */ 113 vbd_disk_info_t dinfo; 110 114 } fdisk_dev_t; 111 115 … … 121 125 /** Containing device */ 122 126 fdisk_dev_t *dev; 123 /** Link to fdisk_dev_t.parts */ 124 link_t ldev; 127 /** Link to fdisk_dev_t.parts_idx */ 128 link_t ldev_idx; 129 /** Link to fdisk_dev_t.parts_ba */ 130 link_t ldev_ba; 125 131 /** Capacity */ 126 132 fdisk_cap_t capacity; … … 129 135 /** Partition ID */ 130 136 vbd_part_id_t part_id; 137 /** Partition index */ 138 int index; 139 /** First block */ 140 aoff64_t block0; 141 /** Number of blocks */ 142 aoff64_t nblocks; 131 143 } fdisk_part_t; 132 144 -
uspace/lib/fdisk/src/fdisk.c
r3faa03d r1626cd4 246 246 } 247 247 248 static int fdisk_part_add(fdisk_dev_t *dev, vbd_part_id_t partid, 249 fdisk_part_t **rpart) 250 { 251 fdisk_part_t *part, *p; 252 vbd_part_info_t pinfo; 253 link_t *link; 254 int rc; 255 256 part = calloc(1, sizeof(fdisk_part_t)); 257 if (part == NULL) 258 return ENOMEM; 259 260 rc = vbd_part_get_info(dev->fdisk->vbd, partid, &pinfo); 261 if (rc != EOK) { 262 rc = EIO; 263 goto error; 264 } 265 266 part->dev = dev; 267 part->index = pinfo.index; 268 part->block0 = pinfo.block0; 269 part->nblocks = pinfo.nblocks; 270 271 /* Insert to list by block address */ 272 link = list_first(&dev->parts_ba); 273 while (link != NULL) { 274 p = list_get_instance(link, fdisk_part_t, ldev_ba); 275 if (p->block0 > part->block0) { 276 list_insert_before(&part->ldev_ba, &p->ldev_ba); 277 break; 278 } 279 280 link = list_next(link, &dev->parts_ba); 281 } 282 283 if (link == NULL) 284 list_append(&part->ldev_ba, &dev->parts_ba); 285 286 /* Insert to list by index */ 287 link = list_first(&dev->parts_idx); 288 while (link != NULL) { 289 p = list_get_instance(link, fdisk_part_t, ldev_idx); 290 if (p->index > part->index) { 291 list_insert_before(&part->ldev_idx, &p->ldev_idx); 292 break; 293 } 294 295 link = list_next(link, &dev->parts_idx); 296 } 297 298 if (link == NULL) 299 list_append(&part->ldev_idx, &dev->parts_idx); 300 301 part->capacity.cunit = cu_byte; 302 part->capacity.value = part->nblocks * dev->dinfo.block_size; 303 part->part_id = partid; 304 305 if (rpart != NULL) 306 *rpart = part; 307 return EOK; 308 error: 309 free(part); 310 return rc; 311 } 312 313 248 314 int fdisk_dev_open(fdisk_t *fdisk, service_id_t sid, fdisk_dev_t **rdev) 249 315 { 250 fdisk_dev_t *dev; 316 fdisk_dev_t *dev = NULL; 317 service_id_t *psids = NULL; 318 size_t nparts, i; 319 int rc; 251 320 252 321 dev = calloc(1, sizeof(fdisk_dev_t)); … … 256 325 dev->fdisk = fdisk; 257 326 dev->sid = sid; 258 list_initialize(&dev->parts); 327 list_initialize(&dev->parts_idx); 328 list_initialize(&dev->parts_ba); 329 330 printf("get info\n"); 331 rc = vbd_disk_info(fdisk->vbd, sid, &dev->dinfo); 332 if (rc != EOK) { 333 printf("failed\n"); 334 rc = EIO; 335 goto error; 336 } 337 338 printf("block size: %zu\n", dev->dinfo.block_size); 339 printf("get partitions\n"); 340 rc = vbd_label_get_parts(fdisk->vbd, sid, &psids, &nparts); 341 if (rc != EOK) { 342 printf("failed\n"); 343 rc = EIO; 344 goto error; 345 } 346 printf("OK\n"); 347 348 printf("found %zu partitions.\n", nparts); 349 for (i = 0; i < nparts; i++) { 350 printf("add partition sid=%zu\n", psids[i]); 351 rc = fdisk_part_add(dev, psids[i], NULL); 352 if (rc != EOK) { 353 printf("failed\n"); 354 goto error; 355 } 356 printf("OK\n"); 357 } 358 359 free(psids); 259 360 *rdev = dev; 260 361 return EOK; 362 error: 363 fdisk_dev_close(dev); 364 return rc; 261 365 } 262 366 263 367 void fdisk_dev_close(fdisk_dev_t *dev) 264 368 { 369 if (dev == NULL) 370 return; 371 372 /* XXX Clean up partitions */ 265 373 free(dev); 266 374 } … … 351 459 link_t *link; 352 460 353 link = list_first(&dev->parts );461 link = list_first(&dev->parts_ba); 354 462 if (link == NULL) 355 463 return NULL; 356 464 357 return list_get_instance(link, fdisk_part_t, ldev );465 return list_get_instance(link, fdisk_part_t, ldev_ba); 358 466 } 359 467 … … 362 470 link_t *link; 363 471 364 link = list_next(&part->ldev , &part->dev->parts);472 link = list_next(&part->ldev_ba, &part->dev->parts_ba); 365 473 if (link == NULL) 366 474 return NULL; 367 475 368 return list_get_instance(link, fdisk_part_t, ldev );476 return list_get_instance(link, fdisk_part_t, ldev_ba); 369 477 } 370 478 … … 399 507 } 400 508 401 part->dev = dev; 402 list_append(&part->ldev, &dev->parts); 403 part->capacity = pspec->capacity; 404 part->fstype = pspec->fstype; 405 part->part_id = partid; 406 407 if (rpart != NULL) 408 *rpart = part; 509 rc = fdisk_part_add(dev, partid, rpart); 510 if (rc != EOK) { 511 /* Try rolling back */ 512 (void) vbd_part_delete(dev->fdisk->vbd, partid); 513 return EIO; 514 } 515 516 (*rpart)->fstype = pspec->fstype; 517 (*rpart)->capacity = pspec->capacity; 518 409 519 return EOK; 410 520 } … … 418 528 return EIO; 419 529 420 list_remove(&part->ldev); 530 list_remove(&part->ldev_ba); 531 list_remove(&part->ldev_idx); 421 532 free(part); 422 533 return EOK; -
uspace/lib/label/include/std/mbr.h
r3faa03d r1626cd4 38 38 #include <stdint.h> 39 39 40 /** Block address of Master Boot Record. */ 41 #define MBR_BA 0 40 enum { 41 /** Block address of Master Boot Record. */ 42 mbr_ba = 0, 42 43 43 enum { 44 /** First block allowed for allocation */ 45 mbr_ablock0 = 18, 46 44 47 /** Number of primary partition records */ 45 48 mbr_nprimary = 4, -
uspace/lib/label/include/types/liblabel.h
r3faa03d r1626cd4 43 43 44 44 typedef struct label label_t; 45 typedef struct label_info label_info_t; 45 46 typedef struct label_part label_part_t; 46 47 typedef struct label_part_info label_part_info_t; … … 53 54 void (*close)(label_t *); 54 55 int (*destroy)(label_t *); 56 int (*get_info)(label_t *, label_info_t *); 55 57 label_part_t *(*part_first)(label_t *); 56 58 label_part_t *(*part_next)(label_part_t *); … … 60 62 } label_ops_t; 61 63 62 typedef struct{64 struct label_info { 63 65 /** Disk contents */ 64 66 label_disk_cnt_t dcnt; 65 67 /** Label type */ 66 68 label_type_t ltype; 67 } label_info_t; 69 /** First block that can be allocated */ 70 aoff64_t ablock0; 71 /** Number of blocks that can be allocated */ 72 aoff64_t anblocks; 73 }; 68 74 69 75 struct label_part_info { 76 /** Partition index */ 77 int index; 70 78 /** Address of first block */ 71 79 aoff64_t block0; … … 80 88 /** Link to label_t.parts */ 81 89 link_t llabel; 90 /** Index */ 91 int index; 92 /** First block */ 82 93 aoff64_t block0; 94 /** Number of blocks */ 83 95 aoff64_t nblocks; 84 96 }; … … 96 108 /** Partitions */ 97 109 list_t parts; /* of label_part_t */ 110 /** First block that can be allocated */ 111 aoff64_t ablock0; 112 /** Number of blocks that can be allocated */ 113 aoff64_t anblocks; 98 114 }; 99 115 -
uspace/lib/label/src/gpt.c
r3faa03d r1626cd4 37 37 #include <byteorder.h> 38 38 #include <errno.h> 39 #include <mem.h> 39 40 #include <stdlib.h> 40 41 … … 46 47 static void gpt_close(label_t *); 47 48 static int gpt_destroy(label_t *); 49 static int gpt_get_info(label_t *, label_info_t *); 48 50 static label_part_t *gpt_part_first(label_t *); 49 51 static label_part_t *gpt_part_next(label_part_t *); … … 52 54 static int gpt_part_destroy(label_part_t *); 53 55 54 static int gpt_pte_to_part(label_t *, gpt_entry_t * );56 static int gpt_pte_to_part(label_t *, gpt_entry_t *, int); 55 57 56 58 const uint8_t efi_signature[8] = { … … 64 66 .close = gpt_close, 65 67 .destroy = gpt_destroy, 68 .get_info = gpt_get_info, 66 69 .part_first = gpt_part_first, 67 70 .part_next = gpt_part_next, … … 83 86 uint64_t ba; 84 87 uint32_t entry; 88 uint64_t ba_min, ba_max; 85 89 int i; 86 90 int rc; … … 126 130 bcnt = (num_entries + esize - 1) / esize; 127 131 ba = uint64_t_le2host(gpt_hdr->entry_lba); 132 ba_min = uint64_t_le2host(gpt_hdr->first_usable_lba); 133 ba_max = uint64_t_le2host(gpt_hdr->last_usable_lba); 128 134 129 135 if (num_entries < 1) { … … 133 139 134 140 if (esize < sizeof(gpt_entry_t)) { 141 rc = EINVAL; 142 goto error; 143 } 144 145 if (ba_max < ba_min) { 135 146 rc = EINVAL; 136 147 goto error; … … 151 162 for (entry = 0; entry < num_entries; entry++) { 152 163 eptr = (gpt_entry_t *)(etable + entry * esize); 153 rc = gpt_pte_to_part(label, eptr );164 rc = gpt_pte_to_part(label, eptr, entry + 1); 154 165 if (rc != EOK) 155 166 goto error; … … 163 174 label->ops = &gpt_label_ops; 164 175 label->ltype = lt_gpt; 176 label->ablock0 = ba_min; 177 label->anblocks = ba_max - ba_min + 1; 165 178 *rlabel = label; 166 179 return EOK; … … 187 200 } 188 201 202 static int gpt_get_info(label_t *label, label_info_t *linfo) 203 { 204 memset(linfo, 0, sizeof(label_info_t)); 205 linfo->dcnt = dc_label; 206 linfo->ltype = lt_gpt; 207 linfo->ablock0 = label->ablock0; 208 linfo->anblocks = label->anblocks; 209 return EOK; 210 } 211 189 212 static label_part_t *gpt_part_first(label_t *label) 190 213 { … … 211 234 static void gpt_part_get_info(label_part_t *part, label_part_info_t *pinfo) 212 235 { 236 pinfo->index = part->index; 213 237 pinfo->block0 = part->block0; 214 238 pinfo->nblocks = part->nblocks; … … 218 242 label_part_t **rpart) 219 243 { 220 return E OK;244 return ENOTSUP; 221 245 } 222 246 223 247 static int gpt_part_destroy(label_part_t *part) 224 248 { 225 return E OK;226 } 227 228 static int gpt_pte_to_part(label_t *label, gpt_entry_t *pte )249 return ENOTSUP; 250 } 251 252 static int gpt_pte_to_part(label_t *label, gpt_entry_t *pte, int index) 229 253 { 230 254 label_part_t *part; … … 250 274 return EINVAL; 251 275 276 part->index = index; 252 277 part->block0 = b0; 253 278 part->nblocks = b1 - b0 + 1; -
uspace/lib/label/src/label.c
r3faa03d r1626cd4 97 97 int label_get_info(label_t *label, label_info_t *linfo) 98 98 { 99 memset(linfo, 0, sizeof(label_info_t)); 100 linfo->dcnt = dc_label; 101 linfo->ltype = label->ltype; 102 return EOK; 99 return label->ops->get_info(label, linfo); 103 100 } 104 101 -
uspace/lib/label/src/mbr.c
r3faa03d r1626cd4 37 37 #include <byteorder.h> 38 38 #include <errno.h> 39 #include <mem.h> 39 40 #include <stdlib.h> 40 41 … … 46 47 static void mbr_close(label_t *); 47 48 static int mbr_destroy(label_t *); 49 static int mbr_get_info(label_t *, label_info_t *); 48 50 static label_part_t *mbr_part_first(label_t *); 49 51 static label_part_t *mbr_part_next(label_part_t *); … … 52 54 static int mbr_part_destroy(label_part_t *); 53 55 54 static int mbr_pte_to_part(label_t *, mbr_pte_t * );56 static int mbr_pte_to_part(label_t *, mbr_pte_t *, int); 55 57 56 58 label_ops_t mbr_label_ops = { … … 59 61 .close = mbr_close, 60 62 .destroy = mbr_destroy, 63 .get_info = mbr_get_info, 61 64 .part_first = mbr_part_first, 62 65 .part_next = mbr_part_next, … … 73 76 uint16_t sgn; 74 77 size_t bsize; 78 aoff64_t nblocks; 75 79 uint32_t entry; 76 80 int rc; … … 82 86 } 83 87 88 rc = block_get_nblocks(sid, &nblocks); 89 if (rc != EOK) { 90 rc = EIO; 91 goto error; 92 } 93 84 94 if (bsize < 512 || (bsize % 512) != 0) { 95 rc = EINVAL; 96 goto error; 97 } 98 99 if (nblocks < mbr_ablock0) { 85 100 rc = EINVAL; 86 101 goto error; … … 93 108 } 94 109 95 rc = block_read_direct(sid, MBR_BA, 1, mbr);110 rc = block_read_direct(sid, mbr_ba, 1, mbr); 96 111 if (rc != EOK) { 97 112 rc = EIO; … … 114 129 for (entry = 0; entry < mbr_nprimary; entry++) { 115 130 eptr = &mbr->pte[entry]; 116 rc = mbr_pte_to_part(label, eptr );131 rc = mbr_pte_to_part(label, eptr, entry + 1); 117 132 if (rc != EOK) 118 133 goto error; … … 124 139 label->ops = &mbr_label_ops; 125 140 label->ltype = lt_mbr; 141 label->ablock0 = mbr_ablock0; 142 label->anblocks = nblocks - mbr_ablock0; 126 143 *rlabel = label; 127 144 return EOK; … … 147 164 } 148 165 166 static int mbr_get_info(label_t *label, label_info_t *linfo) 167 { 168 memset(linfo, 0, sizeof(label_info_t)); 169 linfo->dcnt = dc_label; 170 linfo->ltype = lt_mbr; 171 linfo->ablock0 = label->ablock0; 172 linfo->anblocks = label->anblocks; 173 return EOK; 174 } 175 149 176 static label_part_t *mbr_part_first(label_t *label) 150 177 { … … 171 198 static void mbr_part_get_info(label_part_t *part, label_part_info_t *pinfo) 172 199 { 200 pinfo->index = part->index; 173 201 pinfo->block0 = part->block0; 174 202 pinfo->nblocks = part->nblocks; … … 178 206 label_part_t **rpart) 179 207 { 180 return E OK;208 return ENOTSUP; 181 209 } 182 210 183 211 static int mbr_part_destroy(label_part_t *part) 184 212 { 185 return E OK;186 } 187 188 static int mbr_pte_to_part(label_t *label, mbr_pte_t *pte )213 return ENOTSUP; 214 } 215 216 static int mbr_pte_to_part(label_t *label, mbr_pte_t *pte, int index) 189 217 { 190 218 label_part_t *part; … … 204 232 return ENOMEM; 205 233 234 part->index = index; 206 235 part->block0 = block0; 207 236 part->nblocks = nblocks; -
uspace/srv/bd/vbd/disk.c
r3faa03d r1626cd4 268 268 int vbds_disk_info(service_id_t sid, vbds_disk_info_t *info) 269 269 { 270 vbds_disk_t *disk; 271 label_info_t linfo; 272 int rc; 273 270 274 log_msg(LOG_DEFAULT, LVL_NOTE, "vbds_disk_info(%zu)", sid); 271 info->ltype = lt_mbr; 272 return EOK; 273 } 275 276 rc = vbds_disk_by_svcid(sid, &disk); 277 if (rc != EOK) 278 return rc; 279 280 rc = label_get_info(disk->label, &linfo); 281 282 info->ltype = linfo.ltype; 283 info->ablock0 = linfo.ablock0; 284 info->anblocks = linfo.anblocks; 285 info->block_size = disk->block_size; 286 return EOK; 287 } 288 289 int vbds_get_parts(service_id_t sid, service_id_t *id_buf, size_t buf_size, 290 size_t *act_size) 291 { 292 vbds_disk_t *disk; 293 size_t act_cnt; 294 size_t buf_cnt; 295 int rc; 296 297 rc = vbds_disk_by_svcid(sid, &disk); 298 if (rc != EOK) 299 return rc; 300 301 buf_cnt = buf_size / sizeof(service_id_t); 302 303 act_cnt = list_count(&disk->parts); 304 *act_size = act_cnt * sizeof(service_id_t); 305 306 if (buf_size % sizeof(service_id_t) != 0) 307 return EINVAL; 308 309 size_t pos = 0; 310 list_foreach(disk->parts, ldisk, vbds_part_t, part) { 311 if (pos < buf_cnt) 312 id_buf[pos] = part->id; 313 pos++; 314 } 315 316 return EOK; 317 } 318 274 319 275 320 int vbds_label_create(service_id_t sid, label_type_t ltype) … … 328 373 { 329 374 vbds_part_t *part; 375 label_part_info_t lpinfo; 330 376 int rc; 331 377 … … 334 380 return rc; 335 381 382 label_part_get_info(part->lpart, &lpinfo); 383 384 pinfo->index = lpinfo.index; 385 pinfo->block0 = lpinfo.block0; 386 pinfo->nblocks = lpinfo.nblocks; 336 387 return EOK; 337 388 } -
uspace/srv/bd/vbd/disk.h
r3faa03d r1626cd4 45 45 extern int vbds_disk_remove(service_id_t); 46 46 extern int vbds_disk_info(service_id_t, vbds_disk_info_t *); 47 extern int vbds_get_parts(service_id_t, service_id_t *, size_t, size_t *); 47 48 extern int vbds_label_create(service_id_t, label_type_t); 48 49 extern int vbds_label_delete(service_id_t); -
uspace/srv/bd/vbd/types/vbd.h
r3faa03d r1626cd4 42 42 #include <label.h> 43 43 #include <loc.h> 44 #include <sys/types.h> 44 45 #include <types/label.h> 45 46 … … 48 49 /** Disk info */ 49 50 typedef struct { 50 /** Label */51 label_t *label;52 51 /** Label type */ 53 52 label_type_t ltype; 53 /** First block that can be allocated */ 54 aoff64_t ablock0; 55 /** Number of blocks that can be allocated */ 56 aoff64_t anblocks; 57 /** Block size */ 58 size_t block_size; 54 59 } vbds_disk_info_t; 55 60 … … 92 97 } vbds_disk_t; 93 98 99 /** Partition info */ 94 100 typedef struct { 101 /** Partition index */ 102 int index; 103 /** First block */ 104 aoff64_t block0; 105 /** Number of blocks */ 106 aoff64_t nblocks; 95 107 } vbds_part_info_t; 96 108 -
uspace/srv/bd/vbd/vbd.c
r3faa03d r1626cd4 40 40 #include <ipc/vbd.h> 41 41 #include <loc.h> 42 #include <macros.h> 42 43 #include <stdio.h> 43 44 #include <stdlib.h> … … 112 113 disk_sid = IPC_GET_ARG1(*icall); 113 114 rc = vbds_disk_info(disk_sid, &dinfo); 114 async_answer_1(iid, (sysarg_t)rc, (sysarg_t)dinfo.ltype); 115 if (rc != EOK) { 116 log_msg(LOG_DEFAULT, LVL_NOTE, "vbd_disk_info() call failed"); 117 async_answer_0(iid, rc); 118 return; 119 } 120 121 log_msg(LOG_DEFAULT, LVL_NOTE, "vbd_disk_info() data_read_receive"); 122 ipc_callid_t callid; 123 size_t size; 124 if (!async_data_read_receive(&callid, &size)) { 125 log_msg(LOG_DEFAULT, LVL_NOTE, "vbd_disk_info() failed"); 126 async_answer_0(callid, EREFUSED); 127 async_answer_0(iid, EREFUSED); 128 return; 129 } 130 131 log_msg(LOG_DEFAULT, LVL_NOTE, "vbd_disk_info() check size"); 132 if (size != sizeof(vbds_disk_info_t)) { 133 log_msg(LOG_DEFAULT, LVL_NOTE, "vbd_disk_info() wrong size"); 134 async_answer_0(callid, EINVAL); 135 async_answer_0(iid, EINVAL); 136 return; 137 } 138 139 log_msg(LOG_DEFAULT, LVL_NOTE, "vbd_disk_info() data_read_finalize"); 140 rc = async_data_read_finalize(callid, &dinfo, 141 min(size, sizeof(dinfo))); 142 if (rc != EOK) { 143 async_answer_0(callid, rc); 144 async_answer_0(iid, rc); 145 return; 146 } 147 148 log_msg(LOG_DEFAULT, LVL_NOTE, "vbd_disk_info() reply EOK"); 149 async_answer_0(iid, EOK); 115 150 } 116 151 … … 143 178 static void vbds_label_get_parts_srv(ipc_callid_t iid, ipc_call_t *icall) 144 179 { 145 // service_id_t disk_sid; 146 // int rc; 180 ipc_callid_t callid; 181 size_t size; 182 size_t act_size; 183 service_id_t sid; 184 int rc; 147 185 148 186 log_msg(LOG_DEFAULT, LVL_NOTE, "vbds_label_get_parts_srv()"); 149 187 150 // disk_sid = IPC_GET_ARG1(*icall); 151 // rc = vbds_label_delete(disk_sid); 152 // async_answer_0(iid, (sysarg_t) rc); 153 async_answer_0(iid, ENOTSUP); 154 } 188 if (!async_data_read_receive(&callid, &size)) { 189 async_answer_0(callid, EREFUSED); 190 async_answer_0(iid, EREFUSED); 191 return; 192 } 193 194 sid = IPC_GET_ARG1(*icall); 195 196 category_id_t *id_buf = (category_id_t *) malloc(size); 197 if (id_buf == NULL) { 198 async_answer_0(callid, ENOMEM); 199 async_answer_0(iid, ENOMEM); 200 return; 201 } 202 203 rc = vbds_get_parts(sid, id_buf, size, &act_size); 204 if (rc != EOK) { 205 async_answer_0(callid, rc); 206 async_answer_0(iid, rc); 207 return; 208 } 209 210 sysarg_t retval = async_data_read_finalize(callid, id_buf, size); 211 free(id_buf); 212 213 async_answer_1(iid, retval, act_size); 214 } 215 155 216 156 217 static void vbds_part_get_info_srv(ipc_callid_t iid, ipc_call_t *icall) … … 164 225 part = IPC_GET_ARG1(*icall); 165 226 rc = vbds_part_get_info(part, &pinfo); 166 async_answer_0(iid, (sysarg_t)rc); 227 async_answer_5(iid, (sysarg_t)rc, pinfo.index, 228 LOWER32(pinfo.block0), UPPER32(pinfo.block0), 229 LOWER32(pinfo.nblocks), UPPER32(pinfo.nblocks)); 167 230 } 168 231 -
uspace/srv/volsrv/disk.c
r3faa03d r1626cd4 137 137 assert(fibril_mutex_is_locked(&vol_disks_lock)); 138 138 139 log_msg(LOG_DEFAULT, LVL_ DEBUG, "vol_disk_add()");139 log_msg(LOG_DEFAULT, LVL_NOTE, "vol_disk_add()"); 140 140 disk = vol_disk_new(); 141 141 if (disk == NULL) … … 158 158 159 159 rc = vbd_disk_info(vbd, sid, &dinfo); 160 log_msg(LOG_DEFAULT, LVL_NOTE, "Got disk info."); 160 161 if (rc != EOK) { 161 162 log_msg(LOG_DEFAULT, LVL_NOTE, "Cannot get disk label "
Note:
See TracChangeset
for help on using the changeset viewer.