Changeset 04e520e in mainline for uspace/app/init/init.c


Ignore:
Timestamp:
2024-07-24T10:33:58Z (6 months ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
master
Children:
3d2d455b, 53bff11, 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

File:
1 edited

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;
Note: See TracChangeset for help on using the changeset viewer.