Changeset c43db5f in mainline for uspace/srv/bd/vbd/disk.c
- Timestamp:
- 2015-07-18T13:26:25Z (9 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- c02d098
- Parents:
- b7a4d06
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/bd/vbd/disk.c
rb7a4d06 rc43db5f 62 62 static int vbds_bsa_translate(vbds_part_t *, aoff64_t, size_t, aoff64_t *); 63 63 64 static vbd_part_id_t vbds_part_id = 1; 65 64 66 static bd_ops_t vbds_bd_ops = { 65 67 .open = vbds_bd_open, … … 95 97 } 96 98 97 static int vbds_part_by_ id(vbds_part_id_t partid, vbds_part_t **rpart)98 { 99 log_msg(LOG_DEFAULT, LVL_NOTE, "vbds_part_by_ id(%zu)", partid);99 static int vbds_part_by_pid(vbds_part_id_t partid, vbds_part_t **rpart) 100 { 101 log_msg(LOG_DEFAULT, LVL_NOTE, "vbds_part_by_pid(%zu)", partid); 100 102 101 103 list_foreach(vbds_parts, lparts, vbds_part_t, part) { 102 log_msg(LOG_DEFAULT, LVL_NOTE, "%zu == %zu ?", part-> id, partid);103 if (part-> id == partid) {104 log_msg(LOG_DEFAULT, LVL_NOTE, "%zu == %zu ?", part->pid, partid); 105 if (part->pid == partid) { 104 106 log_msg(LOG_DEFAULT, LVL_NOTE, "Found match."); 105 107 *rpart = part; … … 112 114 } 113 115 116 static int vbds_part_by_svcid(service_id_t svcid, vbds_part_t **rpart) 117 { 118 log_msg(LOG_DEFAULT, LVL_NOTE, "vbds_part_by_svcid(%zu)", svcid); 119 120 list_foreach(vbds_parts, lparts, vbds_part_t, part) { 121 log_msg(LOG_DEFAULT, LVL_NOTE, "%zu == %zu ?", part->svc_id, svcid); 122 if (part->svc_id == svcid) { 123 log_msg(LOG_DEFAULT, LVL_NOTE, "Found match."); 124 *rpart = part; 125 return EOK; 126 } 127 } 128 129 log_msg(LOG_DEFAULT, LVL_NOTE, "No match."); 130 return ENOENT; 131 } 132 114 133 /** Add partition to our inventory based on liblabel partition structure */ 115 134 static int vbds_part_add(vbds_disk_t *disk, label_part_t *lpart, … … 117 136 { 118 137 vbds_part_t *part; 119 service_id_t psid ;138 service_id_t psid = 0; 120 139 label_part_info_t lpinfo; 121 140 char *name; … … 133 152 } 134 153 135 /* XXX Proper service name */ 136 rc = asprintf(&name, "%sp%u", disk->svc_name, lpart->index); 137 if (rc < 0) { 138 log_msg(LOG_DEFAULT, LVL_ERROR, "Out of memory."); 139 return ENOMEM; 140 } 141 142 rc = loc_service_register(name, &psid); 143 if (rc != EOK) { 144 log_msg(LOG_DEFAULT, LVL_ERROR, "Failed registering " 145 "service %s.", name); 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 146 171 free(name); 147 free(part); 148 return EIO; 149 } 150 151 free(name); 172 } 152 173 153 174 part->lpart = lpart; 154 175 part->disk = disk; 155 part->id = (vbds_part_id_t)psid; 176 part->pid = ++vbds_part_id; 177 part->svc_id = psid; 156 178 part->block0 = lpinfo.block0; 157 179 part->nblocks = lpinfo.nblocks; … … 184 206 return EBUSY; 185 207 186 rc = loc_service_unregister((service_id_t)part->id); 187 if (rc != EOK) 188 return EIO; 208 if (part->svc_id != 0) { 209 rc = loc_service_unregister(part->svc_id); 210 if (rc != EOK) 211 return EIO; 212 } 189 213 190 214 list_remove(&part->ldisk); … … 348 372 list_foreach(disk->parts, ldisk, vbds_part_t, part) { 349 373 if (pos < buf_cnt) 350 id_buf[pos] = part-> id;374 id_buf[pos] = part->pid; 351 375 pos++; 352 376 } … … 462 486 int rc; 463 487 464 rc = vbds_part_by_ id(partid, &part);488 rc = vbds_part_by_pid(partid, &part); 465 489 if (rc != EOK) 466 490 return rc; … … 517 541 518 542 if (rpart != NULL) 519 *rpart = part-> id;543 *rpart = part->pid; 520 544 return EOK; 521 545 error: … … 530 554 int rc; 531 555 532 rc = vbds_part_by_ id(partid, &part);556 rc = vbds_part_by_pid(partid, &part); 533 557 if (rc != EOK) 534 558 return rc; … … 647 671 vbds_part_t *part; 648 672 int rc; 649 service_id_t partid;673 service_id_t svcid; 650 674 651 675 log_msg(LOG_DEFAULT, LVL_NOTE, "vbds_bd_conn()"); 652 676 653 partid = IPC_GET_ARG1(*icall);654 655 log_msg(LOG_DEFAULT, LVL_NOTE, "vbds_bd_conn() - partid=%zu", partid);656 657 rc = vbds_part_by_ id(partid, &part);677 svcid = IPC_GET_ARG1(*icall); 678 679 log_msg(LOG_DEFAULT, LVL_NOTE, "vbds_bd_conn() - svcid=%zu", svcid); 680 681 rc = vbds_part_by_svcid(svcid, &part); 658 682 if (rc != EOK) { 659 683 log_msg(LOG_DEFAULT, LVL_NOTE, "vbd_bd_conn() - partition "
Note:
See TracChangeset
for help on using the changeset viewer.