Changeset 8bf4494 in mainline for uspace/app/sysinst/sysinst.c


Ignore:
Timestamp:
2026-04-06T14:53:32Z (3 weeks ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
master, topic/fix-logger-deadlock
Children:
9f9d9067
Parents:
25444332
Message:

Create installation partition in a separate function.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/app/sysinst/sysinst.c

    r25444332 r8bf4494  
    432432}
    433433
     434/** Create installation partition.
     435 *
     436 * @param sysinst System installer
     437 * @param fdev Destination device
     438 *
     439 * @return EOK on success or an error code
     440 */
     441static errno_t sysinst_inst_part_create(sysinst_t *sysinst, fdisk_dev_t *fdev)
     442{
     443        fdisk_part_t *part;
     444        fdisk_part_spec_t pspec;
     445        fdisk_part_info_t pinfo;
     446        capa_spec_t capa;
     447        errno_t rc;
     448
     449        sysinst_debug(sysinst, "sysinst_inst_part_create(): get maximum available block");
     450
     451        rc = fdisk_part_get_max_avail(fdev, spc_pri, &capa);
     452        if (rc != EOK) {
     453                sysinst_error(sysinst,
     454                    "Error getting available capacity.");
     455                goto error;
     456        }
     457
     458        fdisk_pspec_init(&pspec);
     459        pspec.capacity = capa;
     460        pspec.pkind = lpk_primary;
     461        pspec.fstype = fs_ext4; /* Cannot be changed without modifying core.img */
     462        pspec.mountp = MOUNT_POINT;
     463        pspec.index = INST_PART_IDX; /* Cannot be changed without modifying core.img */
     464        pspec.label = INST_VOL_LABEL;
     465
     466        rc = fdisk_part_create(fdev, &pspec, &part);
     467        if (rc != EOK) {
     468                sysinst_error(sysinst, "Error creating partition.");
     469                goto error;
     470        }
     471
     472        rc = fdisk_part_get_info(part, &pinfo);
     473        if (rc != EOK) {
     474                sysinst_error(sysinst, "Error getting partition information.");
     475                goto error;
     476        }
     477
     478        sysinst_debug(sysinst, "sysinst_inst_part_create(): OK");
     479        sysinst->psvc_id = pinfo.svc_id;
     480        return EOK;
     481error:
     482        return rc;
     483}
     484
    434485/** Label and mount the destination device.
    435486 *
    436487 * @param sysinst System installer
    437488 * @param dev Disk device to label
    438  * @param psvc_id Place to store service ID of the created partition
    439489 *
    440490 * @return EOK on success or an error code
     
    445495        fdisk_dev_t *fdev = NULL;
    446496        fdisk_label_info_t linfo;
    447         fdisk_part_t *part;
    448         fdisk_part_spec_t pspec;
    449         fdisk_part_info_t pinfo;
    450497        bool create_label = false;
    451498        bool dir_created = false;
    452499        bool label_created = false;
    453         capa_spec_t capa;
    454500        service_id_t sid;
    455501        errno_t rc;
     
    520566        sysinst_debug(sysinst, "sysinst_label_dev(): create partition");
    521567
    522         rc = fdisk_part_get_max_avail(fdev, spc_pri, &capa);
    523         if (rc != EOK) {
    524                 sysinst_error(sysinst,
    525                     "Error getting available capacity.");
    526                 goto error;
    527         }
    528 
    529         fdisk_pspec_init(&pspec);
    530         pspec.capacity = capa;
    531         pspec.pkind = lpk_primary;
    532         pspec.fstype = fs_ext4; /* Cannot be changed without modifying core.img */
    533         pspec.mountp = MOUNT_POINT;
    534         pspec.index = INST_PART_IDX; /* Cannot be changed without modifying core.img */
    535         pspec.label = INST_VOL_LABEL;
    536 
    537         rc = fdisk_part_create(fdev, &pspec, &part);
    538         if (rc != EOK) {
    539                 sysinst_error(sysinst, "Error creating partition.");
    540                 goto error;
    541         }
    542 
    543         rc = fdisk_part_get_info(part, &pinfo);
    544         if (rc != EOK) {
    545                 sysinst_error(sysinst, "Error getting partition information.");
    546                 goto error;
    547         }
    548 
    549         sysinst_debug(sysinst, "sysinst_label_dev(): OK");
    550         fdisk_dev_close(fdev);
    551         fdisk_destroy(fdisk);
    552         sysinst->psvc_id = pinfo.svc_id;
     568        /* Create installation partition. */
     569        rc = sysinst_inst_part_create(sysinst, fdev);
     570        if (rc != EOK)
     571                goto error;
     572
    553573        return EOK;
    554574error:
Note: See TracChangeset for help on using the changeset viewer.