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


Ignore:
Timestamp:
2024-10-13T08:23:40Z (2 months ago)
Author:
GitHub <noreply@…>
Children:
0472cf17
Parents:
2a0c827c (diff), b3b79981 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
git-author:
boba-buba <120932204+boba-buba@…> (2024-10-13 08:23:40)
git-committer:
GitHub <noreply@…> (2024-10-13 08:23:40)
Message:

Merge branch 'HelenOS:master' into topic/packet-capture

File:
1 edited

Legend:

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

    r2a0c827c rebb1489  
    11/*
    2  * Copyright (c) 2018 Jiri Svoboda
     2 * Copyright (c) 2024 Jiri Svoboda
    33 * All rights reserved.
    44 *
     
    4141#include <errno.h>
    4242#include <fdisk.h>
     43#include <futil.h>
    4344#include <loc.h>
    4445#include <stdio.h>
     
    4950#include <vol.h>
    5051
    51 #include "futil.h"
    5252#include "grub.h"
    5353#include "rdimg.h"
     
    6262 * in Grub notation).
    6363 */
    64 #define DEFAULT_DEV "devices/\\hw\\sys\\00:01.0\\ata-c1\\d0"
     64#define DEFAULT_DEV_0 "devices/\\hw\\sys\\00:01.1\\c0d0"
     65#define DEFAULT_DEV_1 "devices/\\hw\\sys\\00:01.0\\ata1\\c0d0"
    6566//#define DEFAULT_DEV "devices/\\hw\\pci0\\00:01.2\\uhci_rh\\usb01_a1\\mass-storage0\\l0"
    6667/** Volume label for the new file system */
     
    7980#define BOOT_BLOCK_IDX 0 /* MBR */
    8081
     82#define CFG_FILES_SRC "/cfg"
     83#define CFG_FILES_DEST MOUNT_POINT "/cfg"
     84
     85static const char *default_devs[] = {
     86        DEFAULT_DEV_0,
     87        DEFAULT_DEV_1,
     88        NULL
     89};
     90
    8191static const char *sys_dirs[] = {
    8292        "/cfg",
    83         "/data"
     93        "/data",
     94        NULL
    8495};
     96
     97/** Check the if the destination device exists.
     98 *
     99 * @param dev Disk device
     100 *
     101 * @return EOK on success or an error code
     102 */
     103static errno_t sysinst_check_dev(const char *dev)
     104{
     105        service_id_t sid;
     106        errno_t rc;
     107
     108        rc = loc_service_get_id(dev, &sid, 0);
     109        if (rc != EOK)
     110                return rc;
     111
     112        (void)sid;
     113        return EOK;
     114}
    85115
    86116/** Label the destination device.
     
    200230        path = NULL;
    201231
     232        /* Copy initial configuration files */
     233        rc = futil_rcopy_contents(CFG_FILES_SRC, CFG_FILES_DEST);
     234        if (rc != EOK)
     235                return rc;
     236
    202237        return EOK;
    203238error:
     
    244279        }
    245280
    246         rv = asprintf(&path, "%s%s", rdpath, "/cfg/volsrv.sif");
     281        rv = asprintf(&path, "%s%s", rdpath, "/cfg/initvol.sif");
    247282        if (rv < 0) {
    248283                rc = ENOMEM;
     
    271306                printf("Error creating system partition configuration.\n");
    272307                rc = EIO;
     308                goto error;
     309        }
     310
     311        rc = vol_volumes_sync(volumes);
     312        if (rc != EOK) {
     313                printf("Error saving volume confiuration.\n");
    273314                goto error;
    274315        }
     
    361402
    362403        printf("sysinst_copy_boot_blocks: block_init.\n");
    363         rc = block_init(sid, 512);
     404        rc = block_init(sid);
    364405        if (rc != EOK)
    365406                return rc;
     
    490531int main(int argc, char *argv[])
    491532{
    492         const char *dev = DEFAULT_DEV;
    493         return sysinst_install(dev);
     533        unsigned i;
     534        errno_t rc;
     535
     536        i = 0;
     537        while (default_devs[i] != NULL) {
     538                rc = sysinst_check_dev(default_devs[i]);
     539                if (rc == EOK)
     540                        break;
     541        }
     542
     543        if (default_devs[i] == NULL) {
     544                printf("Cannot determine installation device.\n");
     545                return 1;
     546        }
     547
     548        return sysinst_install(default_devs[i]);
    494549}
    495550
Note: See TracChangeset for help on using the changeset viewer.