Changeset 6439741 in mainline for uspace/srv/bd/vbd/disk.c
- Timestamp:
- 2015-07-30T16:20:22Z (9 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 22747e8
- Parents:
- 100b1d1
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/bd/vbd/disk.c
r100b1d1 r6439741 62 62 static int vbds_bsa_translate(vbds_part_t *, aoff64_t, size_t, aoff64_t *); 63 63 64 static int vbds_part_svc_register(vbds_part_t *); 65 static int vbds_part_svc_unregister(vbds_part_t *); 66 static int vbds_part_indices_update(vbds_disk_t *); 67 64 68 static vbd_part_id_t vbds_part_id = 1; 65 69 … … 138 142 service_id_t psid = 0; 139 143 label_part_info_t lpinfo; 140 char *name;141 144 int rc; 142 145 … … 150 153 log_msg(LOG_DEFAULT, LVL_ERROR, "Out of memory."); 151 154 return ENOMEM; 152 }153 154 if (lpinfo.pkind != lpk_extended) {155 /* XXX Proper service name */156 rc = asprintf(&name, "%sp%u", disk->svc_name, lpart->index);157 if (rc < 0) {158 log_msg(LOG_DEFAULT, LVL_ERROR, "Out of memory.");159 return ENOMEM;160 }161 162 rc = loc_service_register(name, &psid);163 if (rc != EOK) {164 log_msg(LOG_DEFAULT, LVL_ERROR, "Failed registering "165 "service %s.", name);166 free(name);167 free(part);168 return EIO;169 }170 171 free(name);172 155 } 173 156 … … 183 166 part->bds.sarg = part; 184 167 168 if (lpinfo.pkind != lpk_extended) { 169 rc = vbds_part_svc_register(part); 170 if (rc != EOK) 171 return EIO; 172 } 173 185 174 list_append(&part->ldisk, &disk->parts); 186 175 list_append(&part->lparts, &vbds_parts); … … 207 196 208 197 if (part->svc_id != 0) { 209 rc = loc_service_unregister(part->svc_id);198 rc = vbds_part_svc_unregister(part); 210 199 if (rc != EOK) 211 200 return EIO; … … 533 522 } 534 523 524 rc = vbds_part_indices_update(disk); 525 if (rc != EOK) { 526 log_msg(LOG_DEFAULT, LVL_ERROR, "Error updating partition indices"); 527 goto error; 528 } 529 535 530 rc = vbds_part_add(disk, lpart, &part); 536 531 if (rc != EOK) { … … 581 576 } 582 577 578 rc = vbds_part_indices_update(disk); 579 if (rc != EOK) { 580 log_msg(LOG_DEFAULT, LVL_ERROR, "Error updating partition indices"); 581 return EIO; 582 } 583 583 584 return EOK; 584 585 } … … 707 708 } 708 709 710 /** Register service for partition */ 711 static int vbds_part_svc_register(vbds_part_t *part) 712 { 713 char *name; 714 service_id_t psid; 715 int idx; 716 int rc; 717 718 idx = part->lpart->index; 719 720 rc = asprintf(&name, "%sp%u", part->disk->svc_name, idx); 721 if (rc < 0) { 722 log_msg(LOG_DEFAULT, LVL_ERROR, "Out of memory."); 723 return ENOMEM; 724 } 725 726 rc = loc_service_register(name, &psid); 727 if (rc != EOK) { 728 log_msg(LOG_DEFAULT, LVL_ERROR, "Failed registering " 729 "service %s.", name); 730 free(name); 731 free(part); 732 return EIO; 733 } 734 735 free(name); 736 part->svc_id = psid; 737 part->reg_idx = idx; 738 return EOK; 739 } 740 741 /** Unregister service for partition */ 742 static int vbds_part_svc_unregister(vbds_part_t *part) 743 { 744 int rc; 745 746 rc = loc_service_unregister(part->svc_id); 747 if (rc != EOK) 748 return EIO; 749 750 part->svc_id = 0; 751 part->reg_idx = 0; 752 return EOK; 753 } 754 755 /** Update service names for any partition whose index has changed. */ 756 static int vbds_part_indices_update(vbds_disk_t *disk) 757 { 758 label_part_info_t lpinfo; 759 int rc; 760 761 log_msg(LOG_DEFAULT, LVL_NOTE, "vbds_part_indices_update()"); 762 763 /* First unregister services for partitions whose index has changed */ 764 list_foreach(disk->parts, ldisk, vbds_part_t, part) { 765 if (part->svc_id != 0 && part->lpart->index != part->reg_idx) { 766 rc = vbds_part_svc_unregister(part); 767 if (rc != EOK) { 768 log_msg(LOG_DEFAULT, LVL_NOTE, "Error " 769 "un-registering partition."); 770 return EIO; 771 } 772 } 773 } 774 775 /* Now re-register those services under the new indices */ 776 list_foreach(disk->parts, ldisk, vbds_part_t, part) { 777 label_part_get_info(part->lpart, &lpinfo); 778 if (part->svc_id == 0 && lpinfo.pkind != lpk_extended) { 779 rc = vbds_part_svc_register(part); 780 if (rc != EOK) { 781 log_msg(LOG_DEFAULT, LVL_NOTE, "Error " 782 "re-registering partition."); 783 return EIO; 784 } 785 } 786 } 787 788 return EOK; 789 } 790 709 791 /** @} 710 792 */
Note:
See TracChangeset
for help on using the changeset viewer.