2 * Copyright (C) 2008 The Android Open Source Project
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in
12 * the documentation and/or other materials provided with the
15 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
16 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
17 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
18 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
19 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
20 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
21 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
22 * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
23 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
24 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
25 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 #ifndef _INCLUDE_SYS__SYSTEM_PROPERTIES_H
30 #define _INCLUDE_SYS__SYSTEM_PROPERTIES_H
32 #ifndef _REALLY_INCLUDE_SYS__SYSTEM_PROPERTIES_H_
33 #error you should #include <sys/system_properties.h> instead
35 #include <sys/system_properties.h>
37 typedef struct prop_area prop_area;
38 typedef struct prop_msg prop_msg;
40 #define PROP_AREA_MAGIC 0x504f5250
41 #define PROP_AREA_VERSION 0x45434f76
43 #define PROP_SERVICE_NAME "property_service"
45 /* #define PROP_MAX_ENTRIES 247 */
46 /* 247 -> 32620 bytes (<32768) */
48 #define TOC_NAME_LEN(toc) ((toc) >> 24)
49 #define TOC_TO_INFO(area, toc) ((prop_info*) (((char*) area) + ((toc) & 0xFFFFFF)))
52 unsigned volatile count;
53 unsigned volatile serial;
60 #define SERIAL_VALUE_LEN(serial) ((serial) >> 24)
61 #define SERIAL_DIRTY(serial) ((serial) & 1)
64 char name[PROP_NAME_MAX];
65 unsigned volatile serial;
66 char value[PROP_VALUE_MAX];
72 char name[PROP_NAME_MAX];
73 char value[PROP_VALUE_MAX];
76 #define PROP_MSG_SETPROP 1
81 ** - there is only one writer, but many readers
82 ** - prop_area.count will never decrease in value
83 ** - once allocated, a prop_info's name will not change
84 ** - once allocated, a prop_info's offset will not change
85 ** - reading a value requires the following steps
86 ** 1. serial = pi->serial
87 ** 2. if SERIAL_DIRTY(serial), wait*, then goto 1
88 ** 3. memcpy(local, pi->value, SERIAL_VALUE_LEN(serial) + 1)
89 ** 4. if pi->serial != serial, goto 2
91 ** - writing a value requires the following steps
92 ** 1. pi->serial = pi->serial | 1
93 ** 2. memcpy(pi->value, local_value, value_len)
94 ** 3. pi->serial = (value_len << 24) | ((pi->serial + 1) & 0xffffff)
97 ** - maintain the toc sorted by pi->name to allow lookup
102 #define PROP_PATH_RAMDISK_DEFAULT "/default.prop"
103 #define PROP_PATH_SYSTEM_BUILD "/system/build.prop"
104 #define PROP_PATH_SYSTEM_DEFAULT "/system/default.prop"
105 #define PROP_PATH_LOCAL_OVERRIDE "/data/local.prop"