Changeset 04e520e in mainline


Ignore:
Timestamp:
2024-07-24T10:33:58Z (3 months ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
master
Children:
3d2d455b, 53bff11, a11679cf, ddfe233
Parents:
145d4e2e
git-author:
Jiri Svoboda <jiri@…> (2024-07-23 17:33:46)
git-committer:
Jiri Svoboda <jiri@…> (2024-07-24 10:33:58)
Message:

Config file persistence

Copy /cfg to /w/cfg when installing and when starting live image
Move futil to separate library
Wait for /w to be mounted while booting from disk
Change taskbar and taskbar-cfg to work with /w/cfg/taskbar.sif

Location:
uspace
Files:
2 added
7 edited
2 moved

Legend:

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

    r145d4e2e r04e520e  
    11/*
     2 * Copyright (c) 2024 Jiri Svoboda
    23 * Copyright (c) 2005 Martin Decky
    34 * All rights reserved.
     
    3536
    3637#include <fibril.h>
     38#include <futil.h>
    3739#include <stdio.h>
    3840#include <stdarg.h>
     
    351353        vol_info_t vinfo;
    352354        volume_id_t *volume_ids = NULL;
     355        service_id_t *part_ids = NULL;
     356        vol_part_info_t pinfo;
    353357        size_t nvols;
     358        size_t nparts;
     359        bool sv_mounted;
    354360        size_t i;
    355361        errno_t rc;
     
    385391        }
    386392
    387         vol_destroy(vol);
    388393        free(volume_ids);
     394        volume_ids = NULL;
    389395
    390396        if (!found_cfg) {
     
    397403                                printf("%s: Error creating directory '%s'.\n",
    398404                                    NAME, *cp);
    399                                 return rc;
     405                                goto error;
    400406                        }
    401407
    402408                        ++cp;
    403409                }
     410
     411                /* Copy initial configuration files */
     412                rc = futil_rcopy_contents("/cfg", "/w/cfg");
     413                if (rc != EOK)
     414                        goto error;
    404415        } else {
    405416                printf("%s: System volume is configured.\n", NAME);
    406         }
    407 
     417
     418                /* Wait until system volume is mounted */
     419                sv_mounted = false;
     420
     421                while (true) {
     422                        rc = vol_get_parts(vol, &part_ids, &nparts);
     423                        if (rc != EOK) {
     424                                printf("Error getting list of volumes.\n");
     425                                goto error;
     426                        }
     427
     428                        for (i = 0; i < nparts; i++) {
     429                                rc = vol_part_info(vol, part_ids[i], &pinfo);
     430                                if (rc != EOK) {
     431                                        printf("Error getting partition "
     432                                            "information.\n");
     433                                        rc = EIO;
     434                                        goto error;
     435                                }
     436
     437                                if (str_cmp(pinfo.cur_mp, "/w") == 0) {
     438                                        sv_mounted = true;
     439                                        break;
     440                                }
     441                        }
     442
     443                        if (sv_mounted)
     444                                break;
     445
     446                        free(part_ids);
     447                        part_ids = NULL;
     448
     449                        fibril_sleep(1);
     450                        printf("Sleeping(1) for system volume.\n");
     451                }
     452        }
     453
     454        vol_destroy(vol);
    408455        return EOK;
    409456error:
     
    411458        if (volume_ids != NULL)
    412459                free(volume_ids);
     460        if (part_ids != NULL)
     461                free(part_ids);
    413462
    414463        return rc;
  • uspace/app/init/meson.build

    r145d4e2e r04e520e  
    2828#
    2929
    30 deps = [ 'untar', 'block' ]
     30deps = [ 'block', 'futil', 'untar' ]
    3131link_args += '-static'
    3232src = files('init.c', 'untar.c')
  • uspace/app/sysinst/meson.build

    r145d4e2e r04e520e  
    2727#
    2828
    29 deps = [ 'block', 'fdisk', 'sif' ]
     29deps = [ 'block', 'fdisk', 'futil', 'sif' ]
    3030src = files(
    31         'futil.c',
    3231        'rdimg.c',
    3332        'sysinst.c',
  • uspace/app/sysinst/sysinst.c

    r145d4e2e r04e520e  
    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"
     
    8080#define BOOT_BLOCK_IDX 0 /* MBR */
    8181
     82#define CFG_FILES_SRC "/cfg"
     83#define CFG_FILES_DEST MOUNT_POINT "/cfg"
     84
    8285static const char *default_devs[] = {
    8386        DEFAULT_DEV_0,
     
    226229        free(path);
    227230        path = NULL;
     231
     232        /* Copy initial configuration files */
     233        rc = futil_rcopy_contents(CFG_FILES_SRC, CFG_FILES_DEST);
     234        if (rc != EOK)
     235                return rc;
    228236
    229237        return EOK;
  • uspace/app/taskbar-cfg/main.c

    r145d4e2e r04e520e  
    11/*
    2  * Copyright (c) 2023 Jiri Svoboda
     2 * Copyright (c) 2024 Jiri Svoboda
    33 * All rights reserved.
    44 *
     
    7777                return 1;
    7878
    79         rc = taskbar_cfg_open(tbcfg, "/cfg/taskbar.sif");
     79        rc = taskbar_cfg_open(tbcfg, "/w/cfg/taskbar.sif");
    8080        if (rc != EOK)
    8181                return 1;
  • uspace/app/taskbar/taskbar.c

    r145d4e2e r04e520e  
    4848#include "wndlist.h"
    4949
    50 #define TASKBAR_CONFIG_FILE "/cfg/taskbar.sif"
     50#define TASKBAR_CONFIG_FILE "/w/cfg/taskbar.sif"
    5151
    5252static void taskbar_wnd_close(ui_window_t *, void *);
  • uspace/lib/futil/include/futil.h

    r145d4e2e r04e520e  
    11/*
    2  * Copyright (c) 2014 Jiri Svoboda
     2 * Copyright (c) 2024 Jiri Svoboda
    33 * All rights reserved.
    44 *
     
    2727 */
    2828
    29 /** @addtogroup sysinst
     29/** @addtogroup futil
    3030 * @{
    3131 */
     
    3838#define FUTIL_H
    3939
    40 #include <ipc/loc.h>
    4140#include <stddef.h>
    4241
  • uspace/lib/futil/src/futil.c

    r145d4e2e r04e520e  
    11/*
    2  * Copyright (c) 2014 Jiri Svoboda
     2 * Copyright (c) 2024 Jiri Svoboda
    33 * All rights reserved.
    44 *
     
    2727 */
    2828
    29 /** @addtogroup sysinst
     29/** @addtogroup futil
    3030 * @{
    3131 */
    32 /** @file File manipulation utility functions for installer
     32/** @file File manipulation utility functions
    3333 */
    3434
  • uspace/lib/meson.build

    r145d4e2e r04e520e  
    7474        'fmtutil',
    7575        'fs',
     76        'futil',
    7677        'gfx',
    7778        'http',
Note: See TracChangeset for help on using the changeset viewer.