Changeset 25444332 in mainline for uspace/app/sysinst/sysinst.c


Ignore:
Timestamp:
2026-04-06T14:26:00Z (23 hours ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
master
Children:
4116579, 8bf4494
Parents:
4f16db1
Message:

Sysinst should be able to install to an existing MBR label.

Provided that the first partition slot is empty and the largest
free block is large enough.

File:
1 edited

Legend:

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

    r4f16db1 r25444332  
    11/*
    2  * Copyright (c) 2025 Jiri Svoboda
     2 * Copyright (c) 2026 Jiri Svoboda
    33 * All rights reserved.
    44 *
     
    7575#define DEFAULT_DEV_2 "devices/\\hw\\sys\\00:01.0\\ide1\\c0d0"
    7676//#define DEFAULT_DEV "devices/\\hw\\pci0\\00:01.2\\uhci_rh\\usb01_a1\\mass-storage0\\l0"
     77/** Index of partition which we must install to (hardwired in load.cfg) */
     78#define INST_PART_IDX 1
    7779/** Volume label for the new file system */
    7880#define INST_VOL_LABEL "HelenOS"
     
    442444        fdisk_t *fdisk = NULL;
    443445        fdisk_dev_t *fdev = NULL;
     446        fdisk_label_info_t linfo;
    444447        fdisk_part_t *part;
    445448        fdisk_part_spec_t pspec;
    446449        fdisk_part_info_t pinfo;
     450        bool create_label = false;
    447451        bool dir_created = false;
    448452        bool label_created = false;
     
    483487        sysinst_debug(sysinst, "sysinst_label_dev(): create label");
    484488
    485         rc = fdisk_label_create(fdev, lt_mbr);
    486         if (rc != EOK) {
    487                 sysinst_error(sysinst, "Error creating label.");
    488                 goto error;
     489        rc = fdisk_label_get_info(fdev, &linfo);
     490        if (rc != EOK) {
     491                sysinst_error(sysinst, "Error analyzing device.");
     492                goto error;
     493        }
     494
     495        switch (linfo.ltype) {
     496        case lt_none:
     497                /* need to create label */
     498                create_label = true;
     499                break;
     500        case lt_mbr:
     501                /* MBR label already present */
     502                break;
     503        default:
     504                /* a different type of label already present */
     505                sysinst_error(sysinst, "Disk contains unusable label.");
     506                goto error;
     507        }
     508
     509        /* Need to create label? */
     510        if (create_label) {
     511                rc = fdisk_label_create(fdev, lt_mbr);
     512                if (rc != EOK) {
     513                        sysinst_error(sysinst, "Error creating label.");
     514                        goto error;
     515                }
    489516        }
    490517
     
    505532        pspec.fstype = fs_ext4; /* Cannot be changed without modifying core.img */
    506533        pspec.mountp = MOUNT_POINT;
     534        pspec.index = INST_PART_IDX; /* Cannot be changed without modifying core.img */
    507535        pspec.label = INST_VOL_LABEL;
    508536
Note: See TracChangeset for help on using the changeset viewer.