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


Ignore:
Timestamp:
2018-10-06T21:14:14Z (6 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
0bd66f5
Parents:
e88eb48
Message:

Let installer amend RAM disk image with volume server configuration.

File:
1 edited

Legend:

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

    re88eb48 rdf8eaba  
    5151#include "futil.h"
    5252#include "grub.h"
     53#include "rdimg.h"
     54#include "volume.h"
    5355
    5456/** Device to install to
     
    6466/** Volume label for the new file system */
    6567#define INST_VOL_LABEL "HelenOS"
     68/** Mount point of system partition when running installed system */
     69#define INST_VOL_MP "/w"
    6670
    6771#define MOUNT_POINT "/inst"
     
    173177        printf("sysinst_copy_boot_files(): OK\n");
    174178        return EOK;
     179}
     180
     181/** Set up configuration in the initial RAM disk.
     182 *
     183 * @return EOK on success or an error code
     184 */
     185static errno_t sysinst_customize_initrd(void)
     186{
     187        errno_t rc;
     188        rd_img_t *rd = NULL;
     189        char *rdpath = NULL;
     190        char *path = NULL;
     191        vol_volumes_t *volumes = NULL;
     192        vol_volume_t *volume = NULL;
     193        int rv;
     194
     195        rc = rd_img_open(MOUNT_POINT "/boot/initrd.img", &rdpath, &rd);
     196        if (rc != EOK) {
     197                printf("Error opening initial RAM disk image.\n");
     198                goto error;
     199        }
     200
     201        rv = asprintf(&path, "%s%s", rdpath, "/cfg/volsrv.sif");
     202        if (rv < 0) {
     203                rc = ENOMEM;
     204                goto error;
     205        }
     206
     207        printf("Configuring volume server.\n");
     208        rc = vol_volumes_create(path, &volumes);
     209        if (rc != EOK) {
     210                printf("Error creating volume server configuration.\n");
     211                rc = EIO;
     212                goto error;
     213        }
     214
     215        printf("Configuring volume server: look up volume\n");
     216        rc = vol_volume_lookup_ref(volumes, INST_VOL_LABEL, &volume);
     217        if (rc != EOK) {
     218                printf("Error creating volume server configuration.\n");
     219                rc = EIO;
     220                goto error;
     221        }
     222
     223        printf("Configuring volume server: set mount point\n");
     224        rc = vol_volume_set_mountp(volume, INST_VOL_MP);
     225        if (rc != EOK) {
     226                printf("Error creating system partition configuration.\n");
     227                rc = EIO;
     228                goto error;
     229        }
     230
     231        printf("Configuring volume server: delete reference\n");
     232        vol_volume_del_ref(volume);
     233        volume = NULL;
     234        printf("Configuring volume server: destroy volumes object\n");
     235        vol_volumes_destroy(volumes);
     236        volumes = NULL;
     237
     238        rc = rd_img_close(rd);
     239        if (rc != EOK) {
     240                printf("Error closing initial RAM disk image.\n");
     241                rc = EIO;
     242                goto error;
     243        }
     244
     245        free(rdpath);
     246        rdpath = NULL;
     247        free(path);
     248        path = NULL;
     249
     250        return EOK;
     251error:
     252        if (volume != NULL)
     253                vol_volume_del_ref(volume);
     254        if (volumes != NULL)
     255                vol_volumes_destroy(volumes);
     256        if (rd != NULL)
     257                (void) rd_img_close(rd);
     258        if (path != NULL)
     259                free(path);
     260        if (rdpath != NULL)
     261                free(rdpath);
     262        return rc;
    175263}
    176264
     
    332420                return rc;
    333421
     422        printf("Boot files done. Configuring the system.\n");
     423        rc = sysinst_customize_initrd();
     424        if (rc != EOK)
     425                return rc;
     426
    334427        printf("Boot files done. Installing boot blocks.\n");
    335428        rc = sysinst_copy_boot_blocks(dev);
Note: See TracChangeset for help on using the changeset viewer.