Changeset 9f9d9067 in mainline for uspace/app/sysinst/sysinst.c


Ignore:
Timestamp:
2026-04-08T11:23:57Z (4 days ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
master
Children:
6d06bbc
Parents:
8bf4494
git-author:
Jiri Svoboda <jiri@…> (2026-04-08 18:23:43)
git-committer:
Jiri Svoboda <jiri@…> (2026-04-08 11:23:57)
Message:

Allow sysinst to upgrade an existing installation (WIP).

File:
1 edited

Legend:

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

    r8bf4494 r9f9d9067  
    7777/** Index of partition which we must install to (hardwired in load.cfg) */
    7878#define INST_PART_IDX 1
     79/* File system type cannot be changed without modifying core.img */
     80#define INST_FSTYPE fs_ext4
    7981/** Volume label for the new file system */
    8082#define INST_VOL_LABEL "HelenOS"
     
    432434}
    433435
     436/** Find existing OS partition.
     437 *
     438 * @param sysinst System installer
     439 * @param fdev Destination device
     440 * @param rpart Place to store pointer to partition
     441 *
     442 * @return EOK on success or an error code
     443 */
     444static errno_t sysinst_existing_os_part_find(sysinst_t *sysinst,
     445    fdisk_dev_t *fdev, fdisk_part_t **rpart)
     446{
     447        fdisk_part_t *part;
     448        fdisk_part_info_t pinfo;
     449        errno_t rc;
     450
     451        sysinst_debug(sysinst, "sysinst_existing_os_part_find(): walk partitions");
     452
     453        part = fdisk_part_first(fdev);
     454        while (part != NULL) {
     455                rc = fdisk_part_get_info(part, &pinfo);
     456                if (rc != EOK) {
     457                        sysinst_error(sysinst,
     458                            "Error getting partition information.");
     459                        goto error;
     460                }
     461
     462                if (pinfo.index == INST_PART_IDX && pinfo.pkind == lpk_primary)
     463                        break;
     464
     465                part = fdisk_part_next(part);
     466        }
     467
     468        /* Partition with index INST_PART_IDX not found? */
     469        if (part == NULL)
     470                return ENOENT;
     471
     472        /* Correct file system type? */
     473        if (pinfo.fstype != INST_FSTYPE) {
     474                /* Not a usable existing partition. */
     475                return ENOENT;
     476        }
     477
     478        sysinst_debug(sysinst, "sysinst_existing_os_part_find(): OK");
     479        sysinst->psvc_id = pinfo.svc_id;
     480        *rpart = part;
     481        return EOK;
     482error:
     483        return rc;
     484}
     485
    434486/** Create installation partition.
    435487 *
     
    459511        pspec.capacity = capa;
    460512        pspec.pkind = lpk_primary;
    461         pspec.fstype = fs_ext4; /* Cannot be changed without modifying core.img */
     513        pspec.fstype = INST_FSTYPE; /* Cannot be changed without modifying core.img */
    462514        pspec.mountp = MOUNT_POINT;
    463515        pspec.index = INST_PART_IDX; /* Cannot be changed without modifying core.img */
     
    494546        fdisk_t *fdisk = NULL;
    495547        fdisk_dev_t *fdev = NULL;
     548        fdisk_part_t *part;
    496549        fdisk_label_info_t linfo;
    497550        bool create_label = false;
     
    566619        sysinst_debug(sysinst, "sysinst_label_dev(): create partition");
    567620
    568         /* Create installation partition. */
    569         rc = sysinst_inst_part_create(sysinst, fdev);
    570         if (rc != EOK)
    571                 goto error;
     621        /* Existing OS partition? */
     622        rc = sysinst_existing_os_part_find(sysinst, fdev, &part);
     623        if (rc == EOK) {
     624                /* Set mount point for installation partition. */
     625                rc = fdisk_part_set_mountp(part, MOUNT_POINT);
     626                if (rc != EOK) {
     627                        sysinst_error(sysinst, "Cannot mount installation "
     628                            "partition.");
     629                        goto error;
     630                }
     631        } else {
     632                /* Create installation partition. */
     633                rc = sysinst_inst_part_create(sysinst, fdev);
     634                if (rc != EOK)
     635                        goto error;
     636        }
    572637
    573638        return EOK;
     
    627692
    628693                rc = vfs_link_path(path, KIND_DIRECTORY, NULL);
    629                 if (rc != EOK) {
     694                if (rc != EOK && rc != EEXIST) {
    630695                        sysinst_error(sysinst, "Error creating directory.");
    631696                        goto error;
Note: See TracChangeset for help on using the changeset viewer.