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 d32969701be070c0161c2643ee3c3df16066bbb8)
Change-Id: I038d451fe8849b0c4863663eec6f57f6521bf4a7
diff --git a/libc/include/sys/_system_properties.h b/libc/include/sys/_system_properties.h
index c5bc223..4971a4c 100644
--- a/libc/include/sys/_system_properties.h
+++ b/libc/include/sys/_system_properties.h
@@ -42,12 +42,13 @@
#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)))
@@ -97,11 +98,17 @@
#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