Changeset 75701004 in mainline


Ignore:
Timestamp:
2018-06-07T16:07:26Z (7 years ago)
Author:
Martin Decky <martin@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
931afbc
Parents:
18ad56a8
Message:

use a TAR as the archive format for populating TMPFS root file system

Also remove the logic of populating a TMPFS file system from the TMPFS
file system driver. A more elegant separation of concerns is to populate
the file system from the client. This is now done by the init task (if
required) and should work universally for any file system.

Files:
2 added
2 deleted
8 edited

Legend:

Unmodified
Added
Removed
  • boot/Makefile.common

    r18ad56a8 r75701004  
    5252
    5353MKARRAY = $(TOOLS_PATH)/mkarray.py
    54 MKTMPFS = $(TOOLS_PATH)/mktmpfs.py
    5554MKFAT = $(TOOLS_PATH)/mkfat.py
    5655MKEXT4 = $(TOOLS_PATH)/mkext4.py
  • boot/Makefile.initrd

    r18ad56a8 r75701004  
    2929$(INITRD).img:
    3030ifeq ($(RDFMT),tmpfs)
    31         $(MKTMPFS) $(DIST_PATH) $@
     31        tar -c -f $@ -C $(DIST_PATH) .
    3232endif
    3333ifeq ($(RDFMT),fat)
  • tools/autotool.py

    r18ad56a8 r75701004  
    579579                check_app(["make", "--version"], "Make utility", "preferably GNU Make")
    580580                check_app(["unzip"], "unzip utility", "usually part of zip/unzip utilities")
     581                check_app(["tar", "--version"], "tar utility", "usually part of tar")
    581582
    582583                platform, cc_args, target = get_target(config)
  • uspace/app/init/Makefile

    r18ad56a8 r75701004  
    3232STATIC_NEEDED = y
    3333
     34LIBS = untar block
     35
    3436SOURCES = \
    35         init.c
     37        init.c \
     38        untar.c
    3639
    3740include $(USPACE_PREFIX)/Makefile.common
  • uspace/app/init/init.c

    r18ad56a8 r75701004  
    4848#include <config.h>
    4949#include <io/logctl.h>
     50#include "untar.h"
    5051#include "init.h"
    5152
     
    8384        switch (rc) {
    8485        case EOK:
    85                 if (dev != NULL)
     86                if ((dev != NULL) && (str_cmp(dev, "") != 0))
    8687                        printf("%s: %s mounted on %s (%s at %s)\n", NAME, desc, mntpt,
    8788                            fstype, dev);
     
    107108}
    108109
    109 /** Mount root filesystem
    110  *
    111  * The operation blocks until the root filesystem
     110/** Mount root file system
     111 *
     112 * The operation blocks until the root file system
    112113 * server is ready for mounting.
    113114 *
    114  * @param[in] fstype Root filesystem type.
     115 * @param[in] fstype Root file system type.
    115116 *
    116117 * @return True on success.
     
    120121static bool mount_root(const char *fstype)
    121122{
    122         const char *opts = "";
    123 
    124         if (str_cmp(fstype, "tmpfs") == 0)
    125                 opts = "restore";
    126 
    127         errno_t rc = vfs_mount_path(ROOT_MOUNT_POINT, fstype, ROOT_DEVICE, opts,
     123        const char *root_device = "";
     124
     125        if (str_cmp(fstype, "tmpfs") != 0)
     126                root_device = ROOT_DEVICE;
     127
     128        errno_t rc = vfs_mount_path(ROOT_MOUNT_POINT, fstype, root_device, "",
    128129            IPC_FLAG_BLOCKING, 0);
    129130        if (rc == EOK)
    130131                logctl_set_root();
    131         return mount_report("Root filesystem", ROOT_MOUNT_POINT, fstype,
    132             ROOT_DEVICE, rc);
    133 }
    134 
    135 /** Mount locfs filesystem
    136  *
    137  * The operation blocks until the locfs filesystem
     132
     133        bool ret = mount_report("Root file system", ROOT_MOUNT_POINT, fstype,
     134            root_device, rc);
     135
     136        rc = vfs_cwd_set(ROOT_MOUNT_POINT);
     137        if (rc != EOK) {
     138                printf("%s: Unable to set current directory to %s (%s)\n",
     139                    NAME, ROOT_MOUNT_POINT, str_error(ret));
     140                return false;
     141        }
     142
     143        if ((ret) && (str_cmp(fstype, "tmpfs") == 0)) {
     144                printf("%s: Extracting root file system archive\n", NAME);
     145                ret = bd_untar(ROOT_DEVICE);
     146        }
     147
     148        return ret;
     149}
     150
     151/** Mount locfs file system
     152 *
     153 * The operation blocks until the locfs file system
    138154 * server is ready for mounting.
    139155 *
     
    146162        errno_t rc = vfs_mount_path(LOCFS_MOUNT_POINT, LOCFS_FS_TYPE, "", "",
    147163            IPC_FLAG_BLOCKING, 0);
    148         return mount_report("Location service filesystem", LOCFS_MOUNT_POINT,
     164        return mount_report("Location service file system", LOCFS_MOUNT_POINT,
    149165            LOCFS_FS_TYPE, NULL, rc);
    150166}
     
    301317{
    302318        errno_t rc = vfs_mount_path(TMPFS_MOUNT_POINT, TMPFS_FS_TYPE, "", "", 0, 0);
    303         return mount_report("Temporary filesystem", TMPFS_MOUNT_POINT,
     319        return mount_report("Temporary file system", TMPFS_MOUNT_POINT,
    304320            TMPFS_FS_TYPE, NULL, rc);
    305321}
  • uspace/srv/fs/tmpfs/Makefile

    r18ad56a8 r75701004  
    3535SOURCES = \
    3636        tmpfs.c \
    37         tmpfs_ops.c \
    38         tmpfs_dump.c
     37        tmpfs_ops.c
    3938
    4039include $(USPACE_PREFIX)/Makefile.common
  • uspace/srv/fs/tmpfs/tmpfs.h

    r18ad56a8 r75701004  
    7474
    7575extern bool tmpfs_init(void);
    76 extern bool tmpfs_restore(service_id_t);
    7776
    7877#endif
  • uspace/srv/fs/tmpfs/tmpfs_ops.c

    r18ad56a8 r75701004  
    447447        assert(rc == EOK);
    448448        tmpfs_node_t *rootp = TMPFS_NODE(rootfn);
    449         if (str_cmp(opts, "restore") == 0) {
    450                 if (!tmpfs_restore(service_id))
    451                         return ELIMIT;
    452         }
    453449
    454450        *index = rootp->index;
Note: See TracChangeset for help on using the changeset viewer.