Changeset b7a4d06 in mainline
- Timestamp:
- 2015-07-18T12:55:12Z (10 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- c43db5f
- Parents:
- 70815a24
- Location:
- uspace
- Files:
-
- 19 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/fdisk/fdisk.c
r70815a24 rb7a4d06 51 51 /** Delete label */ 52 52 devac_delete_label, 53 /** Create partition */ 54 devac_create_part, 53 /** Create (primary) partition */ 54 devac_create_pri_part, 55 /** Create extended partition */ 56 devac_create_ext_part, 57 /** Create logical partition */ 58 devac_create_log_part, 55 59 /** Delete partition */ 56 60 devac_delete_part, … … 312 316 } 313 317 314 static int fdsk_create_part(fdisk_dev_t *dev )318 static int fdsk_create_part(fdisk_dev_t *dev, label_pkind_t pkind) 315 319 { 316 320 int rc; 317 321 fdisk_part_spec_t pspec; 318 322 fdisk_cap_t cap; 319 fdisk_fstype_t fstype ;323 fdisk_fstype_t fstype = fdfs_none; 320 324 tinput_t *tinput = NULL; 321 325 char *scap; … … 345 349 tinput = NULL; 346 350 347 rc = fdsk_select_fstype(&fstype); 348 if (rc != EOK) 349 goto error; 351 if (pkind != lpk_extended) { 352 rc = fdsk_select_fstype(&fstype); 353 if (rc != EOK) 354 goto error; 355 } 350 356 351 357 fdisk_pspec_init(&pspec); 352 358 pspec.capacity = cap; 359 pspec.pkind = pkind; 353 360 pspec.fstype = fstype; 354 361 … … 471 478 char *sfstype = NULL; 472 479 char *svcname = NULL; 480 char *spkind; 473 481 int rc; 474 482 int npart; … … 563 571 } 564 572 565 printf("Partition %d: %s, %s\n", npart, scap, sfstype); 573 printf("Partition %d: %s", npart, scap); 574 if ((linfo.flags & lf_ext_supp) != 0) { 575 rc = fdisk_pkind_format(pinfo.pkind, &spkind); 576 if (rc != EOK) { 577 printf("\nOut of memory.\n"); 578 goto error; 579 } 580 581 printf(", %s", spkind); 582 free(spkind); 583 } 584 585 if (pinfo.pkind != lpk_extended) 586 printf(", %s", sfstype); 587 printf("\n"); 588 566 589 free(scap); 567 590 scap = NULL; … … 580 603 581 604 if (linfo.dcnt == dc_label) { 582 rc = nchoice_add(choice, "Create partition", 583 (void *)devac_create_part); 584 if (rc != EOK) { 585 assert(rc == ENOMEM); 586 printf("Out of memory.\n"); 587 goto error; 605 if ((linfo.flags & lf_ext_supp) != 0) { 606 if ((linfo.flags & lf_can_create_pri) != 0) { 607 rc = nchoice_add(choice, "Create primary " 608 "partition", 609 (void *)devac_create_pri_part); 610 if (rc != EOK) { 611 assert(rc == ENOMEM); 612 printf("Out of memory.\n"); 613 goto error; 614 } 615 } 616 617 if ((linfo.flags & lf_can_create_ext) != 0) { 618 rc = nchoice_add(choice, "Create extended " 619 "partition", 620 (void *)devac_create_ext_part); 621 if (rc != EOK) { 622 assert(rc == ENOMEM); 623 printf("Out of memory.\n"); 624 goto error; 625 } 626 } 627 628 if ((linfo.flags & lf_can_create_log) != 0) { 629 rc = nchoice_add(choice, "Create logical " 630 "partition", 631 (void *)devac_create_log_part); 632 if (rc != EOK) { 633 assert(rc == ENOMEM); 634 printf("Out of memory.\n"); 635 goto error; 636 } 637 } 638 } else { /* (linfo.flags & lf_ext_supp) == 0 */ 639 if ((linfo.flags & lf_can_create_pri) != 0) { 640 rc = nchoice_add(choice, "Create partition", 641 (void *)devac_create_pri_part); 642 if (rc != EOK) { 643 assert(rc == ENOMEM); 644 printf("Out of memory.\n"); 645 goto error; 646 } 647 } 588 648 } 589 649 } … … 637 697 (void) fdsk_delete_label(dev); 638 698 break; 639 case devac_create_part: 640 (void) fdsk_create_part(dev); 699 case devac_create_pri_part: 700 (void) fdsk_create_part(dev, lpk_primary); 701 break; 702 case devac_create_ext_part: 703 (void) fdsk_create_part(dev, lpk_extended); 704 break; 705 case devac_create_log_part: 706 (void) fdsk_create_part(dev, lpk_logical); 641 707 break; 642 708 case devac_delete_part: -
uspace/lib/c/generic/vbd.c
r70815a24 rb7a4d06 264 264 { 265 265 async_exch_t *exch; 266 sysarg_t index; 267 sysarg_t b0_lo, b0_hi; 268 sysarg_t nb_lo, nb_hi; 269 int retval; 270 271 exch = async_exchange_begin(vbd->sess); 272 retval = async_req_1_5(exch, VBD_PART_GET_INFO, part, &index, 273 &b0_lo, &b0_hi, &nb_lo, &nb_hi); 274 async_exchange_end(exch); 275 276 if (retval != EOK) 277 return EIO; 278 279 pinfo->index = index; 280 pinfo->block0 = MERGE_LOUP32(b0_lo, b0_hi); 281 pinfo->nblocks = MERGE_LOUP32(nb_lo, nb_hi); 266 sysarg_t retval; 267 ipc_call_t answer; 268 269 exch = async_exchange_begin(vbd->sess); 270 aid_t req = async_send_1(exch, VBD_PART_GET_INFO, part, &answer); 271 int rc = async_data_read_start(exch, pinfo, sizeof(vbd_part_info_t)); 272 async_exchange_end(exch); 273 274 if (rc != EOK) { 275 async_forget(req); 276 return EIO; 277 } 278 279 async_wait_for(req, &retval); 280 if (retval != EOK) 281 return EIO; 282 282 283 return EOK; 283 284 } -
uspace/lib/c/generic/vol.c
r70815a24 rb7a4d06 192 192 { 193 193 async_exch_t *exch; 194 sysarg_t dcnt, ltype ;194 sysarg_t dcnt, ltype, flags; 195 195 int retval; 196 196 197 197 exch = async_exchange_begin(vol->sess); 198 retval = async_req_1_2(exch, VOL_DISK_INFO, sid, &dcnt, <ype); 198 retval = async_req_1_3(exch, VOL_DISK_INFO, sid, &dcnt, <ype, 199 &flags); 199 200 async_exchange_end(exch); 200 201 … … 204 205 vinfo->dcnt = (label_disk_cnt_t)dcnt; 205 206 vinfo->ltype = (label_type_t)ltype; 207 vinfo->flags = (label_flags_t)flags; 206 208 return EOK; 207 209 } -
uspace/lib/c/include/types/label.h
r70815a24 rb7a4d06 58 58 #define LT_LIMIT (lt_gpt + 1) 59 59 60 /** Partition kind */ 61 typedef enum { 62 /** Primary partition */ 63 lpk_primary, 64 /** Extended partition */ 65 lpk_extended, 66 /** Logical partition */ 67 lpk_logical 68 } label_pkind_t; 69 70 /** Label flags */ 71 typedef enum { 72 /** Label supports extended (and logical) partitions */ 73 lf_ext_supp = 0x1, 74 /** Currently it is possible to create a primary partition */ 75 lf_can_create_pri = 0x2, 76 /** Currently it is possible to create an extended partition */ 77 lf_can_create_ext = 0x4, 78 /** Currrently it is possible to create a logical partition */ 79 lf_can_create_log = 0x8 80 } label_flags_t; 60 81 61 82 #endif -
uspace/lib/c/include/vbd.h
r70815a24 rb7a4d06 51 51 /** Label type */ 52 52 label_type_t ltype; 53 /** Label flags */ 54 label_flags_t flags; 53 55 /** First block that can be allocated */ 54 56 aoff64_t ablock0; … … 67 69 /** Number of blocks */ 68 70 aoff64_t nblocks; 71 /** Partition kind */ 72 label_pkind_t pkind; 69 73 /** Partition type */ 70 74 uint64_t ptype; … … 75 79 /** Partition index */ 76 80 int index; 81 /** Partition kind */ 82 label_pkind_t pkind; 77 83 /** First block */ 78 84 aoff64_t block0; -
uspace/lib/c/include/vol.h
r70815a24 rb7a4d06 53 53 /** Label type, if disk contents is label */ 54 54 label_type_t ltype; 55 /** Label flags */ 56 label_flags_t flags; 55 57 } vol_disk_info_t; 56 58 -
uspace/lib/fdisk/include/fdisk.h
r70815a24 rb7a4d06 72 72 extern int fdisk_ltype_format(label_type_t, char **); 73 73 extern int fdisk_fstype_format(fdisk_fstype_t, char **); 74 extern int fdisk_pkind_format(label_pkind_t, char **); 74 75 75 76 #endif -
uspace/lib/fdisk/include/types/fdisk.h
r70815a24 rb7a4d06 119 119 /** Label type */ 120 120 label_type_t ltype; 121 /** Label flags */ 122 label_flags_t flags; 121 123 } fdisk_label_info_t; 122 124 … … 131 133 /** Capacity */ 132 134 fdisk_cap_t capacity; 135 /** Partition kind */ 136 label_pkind_t pkind; 133 137 /** File system type */ 134 138 fdisk_fstype_t fstype; … … 147 151 /** Desired capacity */ 148 152 fdisk_cap_t capacity; 153 /** Partition kind */ 154 label_pkind_t pkind; 149 155 /** File system type */ 150 156 fdisk_fstype_t fstype; … … 153 159 /** Partition info */ 154 160 typedef struct { 161 /** Capacity */ 155 162 fdisk_cap_t capacity; 163 /** Partition kind */ 164 label_pkind_t pkind; 156 165 /** File system type */ 157 166 fdisk_fstype_t fstype; -
uspace/lib/fdisk/src/fdisk.c
r70815a24 rb7a4d06 271 271 part->block0 = pinfo.block0; 272 272 part->nblocks = pinfo.nblocks; 273 part->pkind = pinfo.pkind; 273 274 274 275 /* Insert to list by block address */ … … 442 443 info->dcnt = vinfo.dcnt; 443 444 info->ltype = vinfo.ltype; 445 info->flags = vinfo.flags; 444 446 return EOK; 445 447 error: … … 497 499 info->capacity = part->capacity; 498 500 info->fstype = part->fstype; 501 info->pkind = part->pkind; 499 502 return EOK; 500 503 } … … 671 674 } 672 675 676 int fdisk_pkind_format(label_pkind_t pkind, char **rstr) 677 { 678 const char *spkind; 679 char *s; 680 681 spkind = NULL; 682 switch (pkind) { 683 case lpk_primary: 684 spkind = "Primary"; 685 break; 686 case lpk_extended: 687 spkind = "Extended"; 688 break; 689 case lpk_logical: 690 spkind = "Logical"; 691 break; 692 } 693 694 s = str_dup(spkind); 695 if (s == NULL) 696 return ENOMEM; 697 698 *rstr = s; 699 return EOK; 700 } 701 673 702 /** Get free partition index. */ 674 703 static int fdisk_part_get_free_idx(fdisk_dev_t *dev, int *rindex) … … 765 794 return EIO; 766 795 796 memset(vpspec, 0, sizeof(vbd_part_spec_t)); 767 797 vpspec->index = index; 768 798 vpspec->block0 = fblock0; 769 799 vpspec->nblocks = req_blocks; 770 vpspec->ptype = 42; 800 vpspec->pkind = pspec->pkind; 801 if (pspec->pkind != lpk_extended) 802 vpspec->ptype = 42; 803 771 804 return EOK; 772 805 } -
uspace/lib/label/include/types/liblabel.h
r70815a24 rb7a4d06 68 68 /** Label type */ 69 69 label_type_t ltype; 70 /** Label flags */ 71 label_flags_t flags; 70 72 /** First block that can be allocated */ 71 73 aoff64_t ablock0; … … 77 79 /** Partition index */ 78 80 int index; 81 /** Partition kind */ 82 label_pkind_t pkind; 79 83 /** Address of first block */ 80 84 aoff64_t block0; … … 88 92 struct label *label; 89 93 /** Link to label_t.parts */ 90 link_t llabel; 94 link_t lparts; 95 /** Link to label_t.pri_parts */ 96 link_t lpri; 97 /** Link to label_t.log_parts */ 98 link_t llog; 91 99 /** Index */ 92 100 int index; … … 109 117 /** Number of blocks */ 110 118 aoff64_t nblocks; 119 /** Partition kind */ 120 label_pkind_t pkind; 111 121 /** Partition type */ 112 122 uint64_t ptype; … … 135 145 /** Partitions */ 136 146 list_t parts; /* of label_part_t */ 147 /** Primary partitions */ 148 list_t pri_parts; /* of label_part_t */ 149 /** Logical partitions */ 150 list_t log_parts; /* of label_part_t */ 137 151 /** First block that can be allocated */ 138 152 aoff64_t ablock0; … … 141 155 /** Number of primary partition entries */ 142 156 int pri_entries; 157 /** Index of extended partition or -1 if there is none */ 158 int ext_part_idx; 143 159 /** Block size */ 144 160 size_t block_size; -
uspace/lib/label/src/gpt.c
r70815a24 rb7a4d06 150 150 151 151 list_initialize(&label->parts); 152 list_initialize(&label->pri_parts); 153 list_initialize(&label->log_parts); 152 154 153 155 for (j = 0; j < 2; j++) { … … 300 302 label->pri_entries = num_entries; 301 303 label->block_size = bsize; 304 label->ext_part_idx = -1; 302 305 303 306 label->lt.gpt.hdr_ba[0] = gpt_hdr_ba; … … 436 439 437 440 list_initialize(&label->parts); 441 list_initialize(&label->pri_parts); 442 list_initialize(&label->log_parts); 438 443 439 444 label->ops = &gpt_label_ops; … … 444 449 label->pri_entries = num_entries; 445 450 label->block_size = bsize; 451 label->ext_part_idx = -1; 446 452 447 453 label->lt.gpt.hdr_ba[0] = hdr_ba[0]; … … 468 474 part = gpt_part_first(label); 469 475 while (part != NULL) { 470 list_remove(&part->llabel); 476 list_remove(&part->lparts); 477 list_remove(&part->lpri); 471 478 free(part); 472 479 part = gpt_part_first(label); … … 532 539 } 533 540 541 static bool gpt_can_create_pri(label_t *label) 542 { 543 return list_count(&label->parts) < (size_t)label->pri_entries; 544 } 545 534 546 static int gpt_get_info(label_t *label, label_info_t *linfo) 535 547 { … … 537 549 linfo->dcnt = dc_label; 538 550 linfo->ltype = lt_gpt; 551 linfo->flags = 0; 552 if (gpt_can_create_pri(label)) 553 linfo->flags = linfo->flags | lf_can_create_pri; 539 554 linfo->ablock0 = label->ablock0; 540 555 linfo->anblocks = label->anblocks; … … 550 565 return NULL; 551 566 552 return list_get_instance(link, label_part_t, l label);567 return list_get_instance(link, label_part_t, lparts); 553 568 } 554 569 … … 557 572 link_t *link; 558 573 559 link = list_next(&part->l label, &part->label->parts);574 link = list_next(&part->lparts, &part->label->parts); 560 575 if (link == NULL) 561 576 return NULL; 562 577 563 return list_get_instance(link, label_part_t, l label);578 return list_get_instance(link, label_part_t, lparts); 564 579 } 565 580 … … 567 582 { 568 583 pinfo->index = part->index; 584 pinfo->pkind = lpk_primary; 569 585 pinfo->block0 = part->block0; 570 586 pinfo->nblocks = part->nblocks; … … 587 603 588 604 if (pspec->index < 1 || pspec->index > label->pri_entries) { 605 rc = EINVAL; 606 goto error; 607 } 608 609 /* GPT only has primary partitions */ 610 if (pspec->pkind != lpk_primary) { 589 611 rc = EINVAL; 590 612 goto error; … … 614 636 } 615 637 616 list_append(&part->llabel, &label->parts); 638 list_append(&part->lparts, &label->parts); 639 list_append(&part->lpri, &label->pri_parts); 617 640 618 641 *rpart = part; … … 636 659 return EIO; 637 660 638 list_remove(&part->llabel); 661 list_remove(&part->lparts); 662 list_remove(&part->lpri); 639 663 free(part); 640 664 return EOK; … … 694 718 695 719 part->label = label; 696 list_append(&part->llabel, &label->parts); 720 list_append(&part->lparts, &label->parts); 721 list_append(&part->lpri, &label->pri_parts); 697 722 return EOK; 698 723 } -
uspace/lib/label/src/mbr.c
r70815a24 rb7a4d06 122 122 123 123 list_initialize(&label->parts); 124 list_initialize(&label->pri_parts); 125 list_initialize(&label->log_parts); 124 126 125 127 /* Verify boot record signature */ … … 130 132 } 131 133 134 label->ext_part_idx = -1; 132 135 for (entry = 0; entry < mbr_nprimary; entry++) { 133 136 eptr = &mbr->pte[entry]; … … 187 190 188 191 list_initialize(&label->parts); 192 list_initialize(&label->pri_parts); 193 list_initialize(&label->log_parts); 189 194 190 195 mbr->media_id = 0; … … 210 215 label->anblocks = nblocks - mbr_ablock0; 211 216 label->pri_entries = mbr_nprimary; 217 label->ext_part_idx = -1; 212 218 213 219 *rlabel = label; … … 225 231 part = mbr_part_first(label); 226 232 while (part != NULL) { 227 list_remove(&part->llabel); 233 list_remove(&part->lparts); 234 if (link_used(&part->lpri)) 235 list_remove(&part->lpri); 236 if (link_used(&part->llog)) 237 list_remove(&part->llog); 228 238 free(part); 229 239 … … 273 283 linfo->dcnt = dc_label; 274 284 linfo->ltype = lt_mbr; 285 286 /* We support extended partitions */ 287 linfo->flags = lf_ext_supp; 288 289 /** Can create primary if there is a free slot */ 290 if (list_count(&label->pri_parts) < mbr_nprimary) 291 linfo->flags |= lf_can_create_pri; 292 /* Can create extended if there is a free slot and no extended */ 293 if ((linfo->flags & lf_can_create_pri) != 0 && label->ext_part_idx < 0) 294 linfo->flags |= lf_can_create_ext; 295 /* Can create logical if there is an extended partition */ 296 if (label->ext_part_idx >= 0) 297 linfo->flags |= lf_can_create_log; 298 275 299 linfo->ablock0 = label->ablock0; 276 300 linfo->anblocks = label->anblocks; 301 277 302 return EOK; 278 303 } … … 286 311 return NULL; 287 312 288 return list_get_instance(link, label_part_t, l label);313 return list_get_instance(link, label_part_t, lparts); 289 314 } 290 315 … … 293 318 link_t *link; 294 319 295 link = list_next(&part->l label, &part->label->parts);320 link = list_next(&part->lparts, &part->label->parts); 296 321 if (link == NULL) 297 322 return NULL; 298 323 299 return list_get_instance(link, label_part_t, llabel); 300 } 301 324 return list_get_instance(link, label_part_t, lparts); 325 } 326 327 #include <io/log.h> 302 328 static void mbr_part_get_info(label_part_t *part, label_part_info_t *pinfo) 303 329 { … … 305 331 pinfo->block0 = part->block0; 306 332 pinfo->nblocks = part->nblocks; 333 334 log_msg(LOG_DEFAULT, LVL_NOTE, "mbr_part_get_info: index=%d ptype=%d", 335 (int)part->index, (int)part->ptype); 336 if (link_used(&part->llog)) 337 pinfo->pkind = lpk_logical; 338 else if (part->ptype == mbr_pt_extended) 339 pinfo->pkind = lpk_extended; 340 else 341 pinfo->pkind = lpk_primary; 307 342 } 308 343 … … 318 353 return ENOMEM; 319 354 320 /* XXX Verify index, block0, nblocks */321 322 if (pspec->index < 1 || pspec->index > label->pri_entries) {323 rc = EINVAL;324 goto error;325 }326 355 327 356 /* XXX Check if index is used */ … … 331 360 part->block0 = pspec->block0; 332 361 part->nblocks = pspec->nblocks; 333 part->ptype = pspec->ptype; 334 335 rc = mbr_part_to_pte(part, &pte); 336 if (rc != EOK) { 337 rc = EINVAL; 338 goto error; 339 } 340 341 rc = mbr_pte_update(label, &pte, pspec->index - 1); 342 if (rc != EOK) { 343 rc = EIO; 344 goto error; 345 } 346 347 list_append(&part->llabel, &label->parts); 362 363 switch (pspec->pkind) { 364 case lpk_primary: 365 part->ptype = pspec->ptype; 366 break; 367 case lpk_extended: 368 part->ptype = mbr_pt_extended; 369 if (pspec->ptype != 0) { 370 rc = EINVAL; 371 goto error; 372 } 373 if (label->ext_part_idx >= 0) { 374 rc = EEXISTS; 375 goto error; 376 } 377 break; 378 case lpk_logical: 379 part->ptype = pspec->ptype; 380 if (pspec->index != 0) { 381 rc = EINVAL; 382 goto error; 383 } 384 break; 385 } 386 387 if (pspec->pkind != lpk_logical) { 388 /* Primary or extended partition */ 389 /* XXX Verify index, block0, nblocks */ 390 391 if (pspec->index < 1 || pspec->index > label->pri_entries) { 392 rc = EINVAL; 393 goto error; 394 } 395 396 rc = mbr_part_to_pte(part, &pte); 397 if (rc != EOK) { 398 rc = EINVAL; 399 goto error; 400 } 401 402 rc = mbr_pte_update(label, &pte, pspec->index - 1); 403 if (rc != EOK) { 404 rc = EIO; 405 goto error; 406 } 407 408 list_append(&part->lparts, &label->parts); 409 list_append(&part->lpri, &label->pri_parts); 410 411 if (pspec->pkind == lpk_extended) 412 label->ext_part_idx = pspec->index - 1; 413 } else { 414 /* Logical partition */ 415 rc = ENOTSUP; 416 goto error; 417 } 348 418 349 419 *rpart = part; … … 367 437 return EIO; 368 438 369 list_remove(&part->llabel); 439 /* If it was the extended partition, clear ext. part. index */ 440 if (part->index - 1 == part->label->ext_part_idx) 441 part->label->ext_part_idx = -1; 442 443 list_remove(&part->lparts); 444 if (link_used(&part->lpri)) 445 list_remove(&part->lpri); 446 if (link_used(&part->llog)) 447 list_remove(&part->llog); 370 448 free(part); 371 449 return EOK; … … 386 464 return EINVAL; 387 465 466 log_msg(LOG_DEFAULT, LVL_NOTE, "mbr_part_to_pte: a0=%" PRIu64 467 " len=%" PRIu64 " ptype=%d", part->block0, part->nblocks, 468 (int)part->ptype); 388 469 memset(pte, 0, sizeof(mbr_pte_t)); 389 470 pte->ptype = part->ptype; … … 403 484 404 485 /* See UEFI specification 2.0 section 5.2.1 Legacy Master Boot Record */ 405 if (pte->ptype == mbr_pt_unused || pte->ptype == mbr_pt_extended || 406 nblocks == 0) 486 if (pte->ptype == mbr_pt_unused || nblocks == 0) 407 487 return EOK; 408 488 … … 411 491 return ENOMEM; 412 492 493 part->ptype = pte->ptype; 413 494 part->index = index; 414 495 part->block0 = block0; … … 422 503 423 504 part->label = label; 424 list_append(&part->llabel, &label->parts); 505 list_append(&part->lparts, &label->parts); 506 list_append(&part->lpri, &label->pri_parts); 507 508 if (pte->ptype == mbr_pt_extended) 509 label->ext_part_idx = index - 1; 425 510 return EOK; 426 511 } -
uspace/srv/bd/vbd/disk.c
r70815a24 rb7a4d06 125 125 disk->svc_name, lpart); 126 126 127 label_part_get_info(lpart, &lpinfo); 128 127 129 part = calloc(1, sizeof(vbds_part_t)); 128 130 if (part == NULL) { … … 148 150 149 151 free(name); 150 label_part_get_info(lpart, &lpinfo);151 152 152 153 part->lpart = lpart; … … 302 303 } 303 304 304 int vbds_disk_info(service_id_t sid, vbd s_disk_info_t *info)305 int vbds_disk_info(service_id_t sid, vbd_disk_info_t *info) 305 306 { 306 307 vbds_disk_t *disk; … … 317 318 318 319 info->ltype = linfo.ltype; 320 info->flags = linfo.flags; 319 321 info->ablock0 = linfo.ablock0; 320 322 info->anblocks = linfo.anblocks; … … 467 469 468 470 pinfo->index = lpinfo.index; 471 pinfo->pkind = lpinfo.pkind; 469 472 pinfo->block0 = lpinfo.block0; 470 473 pinfo->nblocks = lpinfo.nblocks; … … 492 495 lpspec.block0 = pspec->block0; 493 496 lpspec.nblocks = pspec->nblocks; 497 lpspec.pkind = pspec->pkind; 494 498 lpspec.ptype = pspec->ptype; 495 499 -
uspace/srv/bd/vbd/disk.h
r70815a24 rb7a4d06 45 45 extern int vbds_disk_add(service_id_t); 46 46 extern int vbds_disk_remove(service_id_t); 47 extern int vbds_disk_info(service_id_t, vbd s_disk_info_t *);47 extern int vbds_disk_info(service_id_t, vbd_disk_info_t *); 48 48 extern int vbds_get_parts(service_id_t, service_id_t *, size_t, size_t *); 49 49 extern int vbds_label_create(service_id_t, label_type_t); -
uspace/srv/bd/vbd/types/vbd.h
r70815a24 rb7a4d06 47 47 typedef sysarg_t vbds_part_id_t; 48 48 49 /** Disk info */50 typedef struct {51 /** Label type */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;59 } vbds_disk_info_t;60 61 49 /** Partition */ 62 50 typedef struct { -
uspace/srv/bd/vbd/vbd.c
r70815a24 rb7a4d06 107 107 { 108 108 service_id_t disk_sid; 109 vbd s_disk_info_t dinfo;109 vbd_disk_info_t dinfo; 110 110 int rc; 111 111 … … 127 127 } 128 128 129 if (size != sizeof(vbd s_disk_info_t)) {129 if (size != sizeof(vbd_disk_info_t)) { 130 130 async_answer_0(callid, EINVAL); 131 131 async_answer_0(iid, EINVAL); … … 219 219 part = IPC_GET_ARG1(*icall); 220 220 rc = vbds_part_get_info(part, &pinfo); 221 async_answer_5(iid, (sysarg_t)rc, pinfo.index, 222 LOWER32(pinfo.block0), UPPER32(pinfo.block0), 223 LOWER32(pinfo.nblocks), UPPER32(pinfo.nblocks)); 221 if (rc != EOK) { 222 async_answer_0(iid, rc); 223 return; 224 } 225 226 ipc_callid_t callid; 227 size_t size; 228 if (!async_data_read_receive(&callid, &size)) { 229 async_answer_0(callid, EREFUSED); 230 async_answer_0(iid, EREFUSED); 231 return; 232 } 233 234 if (size != sizeof(vbd_part_info_t)) { 235 async_answer_0(callid, EINVAL); 236 async_answer_0(iid, EINVAL); 237 return; 238 } 239 240 rc = async_data_read_finalize(callid, &pinfo, 241 min(size, sizeof(pinfo))); 242 if (rc != EOK) { 243 async_answer_0(callid, rc); 244 async_answer_0(iid, rc); 245 return; 246 } 247 248 async_answer_0(iid, EOK); 224 249 } 225 250 -
uspace/srv/volsrv/disk.c
r70815a24 rb7a4d06 271 271 } 272 272 273 int vol_disk_empty (vol_disk_t *disk)273 int vol_disk_empty_disk(vol_disk_t *disk) 274 274 { 275 275 int rc; … … 286 286 } 287 287 288 int vol_disk_get_info(vol_disk_t *disk, vol_disk_info_t *dinfo) 289 { 290 vbd_disk_info_t vdinfo; 291 int rc; 292 293 dinfo->dcnt = disk->dcnt; 294 295 if (disk->dcnt == dc_label) { 296 rc = vbd_disk_info(vbd, disk->svc_id, &vdinfo); 297 if (rc != EOK) 298 return rc; 299 300 dinfo->ltype = vdinfo.ltype; 301 dinfo->flags = vdinfo.flags; 302 } 303 304 return EOK; 305 } 306 288 307 289 308 /** @} -
uspace/srv/volsrv/disk.h
r70815a24 rb7a4d06 39 39 40 40 #include <sys/types.h> 41 #include <vol.h> 41 42 #include "types/disk.h" 42 43 … … 46 47 extern int vol_disk_find_by_id(service_id_t, vol_disk_t **); 47 48 extern int vol_disk_label_create(vol_disk_t *, label_type_t); 48 extern int vol_disk_empty(vol_disk_t *); 49 extern int vol_disk_empty_disk(vol_disk_t *); 50 extern int vol_disk_get_info(vol_disk_t *, vol_disk_info_t *); 49 51 50 52 #endif -
uspace/srv/volsrv/volsrv.c
r70815a24 rb7a4d06 43 43 #include <stdlib.h> 44 44 #include <task.h> 45 #include <vol.h> 45 46 46 47 #include "disk.h" … … 118 119 service_id_t sid; 119 120 vol_disk_t *disk; 121 vol_disk_info_t dinfo; 120 122 int rc; 121 123 … … 127 129 } 128 130 129 async_answer_2(iid, rc, disk->dcnt, disk->ltype); 131 rc = vol_disk_get_info(disk, &dinfo); 132 if (rc != EOK) { 133 async_answer_0(iid, EIO); 134 return; 135 } 136 137 async_answer_3(iid, rc, dinfo.dcnt, dinfo.ltype, dinfo.flags); 130 138 } 131 139 … … 169 177 } 170 178 171 rc = vol_disk_empty (disk);179 rc = vol_disk_empty_disk(disk); 172 180 if (rc != EOK) { 173 181 async_answer_0(iid, EIO);
Note:
See TracChangeset
for help on using the changeset viewer.