bionic: make property area expandable

The property area is initially one 4K region, automatically expanding as
needed up to 64 regions.

To avoid duplicating code, __system_property_area_init() now allocates
and initializes the first region (previously it was allocated in init's
init_property_area() and initialized in bionic).  For testing purposes,
__system_property_set_filename() may be used to override the file used
to map in regions.

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

(cherry picked from commit d32969701b)

Change-Id: I038d451fe8849b0c4863663eec6f57f6521bf4a7
This commit is contained in:
Greg Hackmann
2013-02-13 14:41:48 -08:00
committed by Colin Cross
parent 0ea1d5c0ae
commit cb215a7e9e
4 changed files with 264 additions and 74 deletions

View File

@@ -42,12 +42,13 @@ typedef struct prop_msg prop_msg;
#define PROP_SERVICE_NAME "property_service"
#define PROP_FILENAME "/dev/__properties__"
/* (8 header words + 247 toc words) = 1020 bytes */
/* 1024 bytes header and toc + 247 prop_infos @ 128 bytes = 32640 bytes */
/* (4 header words + 28 toc words) = 128 bytes */
/* 128 bytes header and toc + 28 prop_infos @ 128 bytes = 3712 bytes */
#define PA_COUNT_MAX 247
#define PA_INFO_START 1024
#define PA_SIZE 32768
#define PA_COUNT_MAX 28
#define PA_REGION_COUNT 128
#define PA_INFO_START 128
#define PA_SIZE 4096
#define TOC_NAME_LEN(toc) ((toc) >> 24)
#define TOC_TO_INFO(area, toc) ((prop_info*) (((char*) area) + ((toc) & 0xFFFFFF)))
@@ -96,12 +97,18 @@ struct prop_msg
#define PROP_PATH_LOCAL_OVERRIDE "/data/local.prop"
#define PROP_PATH_FACTORY "/factory/factory.prop"
/*
** Map the property area from the specified filename. This
** method is for testing only.
*/
int __system_property_set_filename(const char *filename);
/*
** Initialize the area to be used to store properties. Can
** only be done by a single process that has write access to
** the property area.
*/
void __system_property_area_init(void *data);
int __system_property_area_init();
/* Add a new system property. Can only be done by a single
** process that has write access to the property area, and