Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 25b15be9 authored by Brian Swetland's avatar Brian Swetland
Browse files

init: use tmpfs/ftruncate for properties backing store instead of ashmem



This removes the need for ashmem for early bringup and avoids an issue
with permissions enforcement.

Change-Id: I405b080660934d73048c79d614b6b2ebc43ab182
Signed-off-by: default avatarBrian Swetland <swetland@google.com>
parent 63e5205c
Loading
Loading
Loading
Loading
+15 −6
Original line number Original line Diff line number Diff line
@@ -27,7 +27,6 @@


#include <cutils/misc.h>
#include <cutils/misc.h>
#include <cutils/sockets.h>
#include <cutils/sockets.h>
#include <cutils/ashmem.h>


#define _REALLY_INCLUDE_SYS__SYSTEM_PROPERTIES_H_
#define _REALLY_INCLUDE_SYS__SYSTEM_PROPERTIES_H_
#include <sys/_system_properties.h>
#include <sys/_system_properties.h>
@@ -110,21 +109,31 @@ static int init_workspace(workspace *w, size_t size)
    void *data;
    void *data;
    int fd;
    int fd;


    fd = ashmem_create_region("system_properties", size);
        /* dev is a tmpfs that we can use to carve a shared workspace
         * out of, so let's do that...
         */
    fd = open("/dev/__properties__", O_RDWR | O_CREAT, 0600);
    if (fd < 0)
    if (fd < 0)
        return -1;
        return -1;


    if (ftruncate(fd, size) < 0)
        goto out;

    data = mmap(NULL, size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
    data = mmap(NULL, size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
    if(data == MAP_FAILED)
    if(data == MAP_FAILED)
        goto out;
        goto out;


    /* allow the wolves we share with to do nothing but read */
    close(fd);
    ashmem_set_prot_region(fd, PROT_READ);

    fd = open("/dev/__properties__", O_RDONLY);
    if (fd < 0)
        return -1;

    unlink("/dev/__properties__");


    w->data = data;
    w->data = data;
    w->size = size;
    w->size = size;
    w->fd = fd;
    w->fd = fd;

    return 0;
    return 0;


out:
out: