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

Commit 2baad525 authored by Greg Hackmann's avatar Greg Hackmann Committed by Colin Cross
Browse files

init: move initial property area allocation into bionic



bionic's __system_property_add() now expands the property area as needed
by mapping in more pages.  Rather than duplicate the mapping code, move
it inside bionic and have bionic's __system_property_area_init() set up
the first page.

Signed-off-by: default avatarGreg Hackmann <ghackmann@google.com>

(cherry picked from commit f14eef0c)

Change-Id: Ieb94caab1527c71f2155efe3795490b0ea215a29
parent 26f2d2f5
Loading
Loading
Loading
Loading
+5 −28
Original line number Diff line number Diff line
@@ -110,7 +110,6 @@ struct {
};

typedef struct {
    void *data;
    size_t size;
    int fd;
} workspace;
@@ -118,36 +117,13 @@ typedef struct {
static int init_workspace(workspace *w, size_t size)
{
    void *data;
    int fd;

        /* dev is a tmpfs that we can use to carve a shared workspace
         * out of, so let's do that...
         */
    fd = open(PROP_FILENAME, O_RDWR | O_CREAT | O_NOFOLLOW, 0644);
    int fd = open(PROP_FILENAME, O_RDONLY | O_NOFOLLOW);
    if (fd < 0)
        return -1;

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

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

    close(fd);

    fd = open(PROP_FILENAME, O_RDONLY | O_NOFOLLOW);
    if (fd < 0)
        return -1;

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

out:
    close(fd);
    return -1;
}

static workspace pa_workspace;
@@ -157,12 +133,13 @@ static int init_property_area(void)
    if (property_area_inited)
        return -1;

    if(init_workspace(&pa_workspace, PA_SIZE))
    if(__system_property_area_init())
        return -1;

    fcntl(pa_workspace.fd, F_SETFD, FD_CLOEXEC);
    if(init_workspace(&pa_workspace, 0))
        return -1;

    __system_property_area_init(pa_workspace.data);
    fcntl(pa_workspace.fd, F_SETFD, FD_CLOEXEC);

    property_area_inited = 1;
    return 0;