blob: d884e3276a289836a25f1b20dc4ad0c8095f2836 [file] [log] [blame]
William Robertsc950a352016-03-04 18:12:29 -08001 _____ _____ _____ _____ __ __ _____
2/ _ \/ __\/ _ \| _ \/ \/ \/ __\
3| _ <| __|| _ || | || \/ || __|
4\__|\_/\_____/\__|__/|_____/\__ \__/\_____/
5
6
7Generating the android_filesystem_config.h
8
9To generate the android_filesystem_config.h file, one can choose from
10one of two methods. The first method, is to declare
11TARGET_ANDROID_FILESYSTEM_CONFIG_H in the device BoardConfig.mk file. This
12variable can only have one item in it, and it is used directly as the
13android_filesystem_config.h header when building
14fs_config_generate_$(TARGET_DEVICE) which is used to generate fs_config_files
15and fs_config_dirs target executable.
16
17The limitation with this, is that it can only be set once, thus if the device
18has a make hierarchy, then each device needs its own file, and cannot share
19from a common source or that common source needs to include everything from
20both devices.
21
22The other way is to set TARGET_FS_CONFIG_GEN, which can be a list of
23intermediate fs configuration files. It is a build error on any one
24these conditions:
25 * Specify TARGET_FS_CONFIG_GEN and TARGET_ANDROID_FILESYSTEM_CONFIG_H
26 * Specify TARGET_FS_CONFIG_GEN and provide
27 $(TARGET_DEVICE_DIR)/android_filesystem_config.h
28
29The parsing of the config file follows the Python ConfigParser specification,
30with the sections and fields as defined below. There are two types of sections,
31both sections require all options to be specified. The first section type is
32the "caps" section.
33
34The "caps" section follows the following syntax:
35
36[path]
37mode: Octal file mode
38user: AID_<user>
39group: AID_<group>
40caps: cap*
41
42Where:
43
44[path]
45 The filesystem path to configure. A path ending in / is considered a dir,
46 else its a file.
47
48mode:
49 A valid octal file mode of at least 3 digits. If 3 is specified, it is
50 prefixed with a 0, else mode is used as is.
51
52user:
Elliott Hughes2d7c86d2016-12-13 23:37:07 +000053 Either the C define for a valid AID or the friendly name. For instance both
54 AID_RADIO and radio are acceptable. Note custom AIDs can be defined in the
William Robertsc950a352016-03-04 18:12:29 -080055 AID section documented below.
56
57group:
Elliott Hughes2d7c86d2016-12-13 23:37:07 +000058 Same as user.
William Robertsc950a352016-03-04 18:12:29 -080059
60caps:
61 The name as declared in
62 system/core/include/private/android_filesystem_capability.h without the
63 leading CAP_. Mixed case is allowed. Caps can also be the raw:
64 * binary (0b0101)
65 * octal (0455)
66 * int (42)
67 * hex (0xFF)
68 For multiple caps, just separate by whitespace.
69
William Robertsdb616f02016-04-09 10:24:25 -070070It is an error to specify multiple sections with the same [path] in different
71files. Note that the same file may contain sections that override the previous
72section in Python versions <= 3.2. In Python 3.2 it's set to strict mode.
William Robertsc950a352016-03-04 18:12:29 -080073
74
75The next section type is the "AID" section, for specifying OEM specific AIDS.
76
77The AID section follows the following syntax:
78
79[AID_<name>]
80value: <number>
81
82Where:
83
84[AID_<name>]
Elliott Hughes2d7c86d2016-12-13 23:37:07 +000085 The <name> can contain characters in the set uppercase, numbers
86 and underscores.
William Robertsc950a352016-03-04 18:12:29 -080087
88value:
William Robertsdb616f02016-04-09 10:24:25 -070089 A valid C style number string. Hex, octal, binary and decimal are supported.
90 See "caps" above for more details on number formatting.
William Robertsc950a352016-03-04 18:12:29 -080091
William Robertsdb616f02016-04-09 10:24:25 -070092It is an error to specify multiple sections with the same [AID_<name>]. With
93the same constraints as [path] described above. It is also an error to specify
94multiple sections with the same value option. It is also an error to specify a
95value that is outside of the inclusive OEM ranges:
William Roberts580f2c42016-04-08 22:03:42 -070096 * AID_OEM_RESERVED_START(2900) - AID_OEM_RESERVED_END(2999)
97 * AID_OEM_RESERVED_2_START(5000) - AID_OEM_RESERVED_2_END(5999)
98
William Robertsc950a352016-03-04 18:12:29 -080099as defined by system/core/include/private/android_filesystem_config.h.
100
101Ordering within the TARGET_FS_CONFIG_GEN files is not relevant. The paths for files are sorted
102like so within their respective array definition:
103 * specified path before prefix match
104 ** ie foo before f*
105 * lexicographical less than before other
106 ** ie boo before foo
107
108Given these paths:
109
110paths=['ac', 'a', 'acd', 'an', 'a*', 'aa', 'ac*']
111
112The sort order would be:
113paths=['a', 'aa', 'ac', 'acd', 'an', 'ac*', 'a*']
114
115Thus the fs_config tools will match on specified paths before attempting prefix, and match on the
116longest matching prefix.
117
118The declared AIDS are sorted in ascending numerical order based on the option "value". The string
119representation of value is preserved. Both choices were made for maximum readability of the generated
120file and to line up files. Sync lines are placed with the source file as comments in the generated
121header file.
Elliott Hughes2d7c86d2016-12-13 23:37:07 +0000122
123For OEMs wishing to use the define AIDs in their native code, one can access the generated header
124file like so:
125 1. In your C code just #include "generated_oem_aid.h" and start using the declared identifiers.
126 2. In your Makefile add this static library like so: LOCAL_STATIC_LIBRARIES := liboemaids
127
128Unit Tests:
129
130From within the fs_config directory, unit tests can be executed like so:
131$ python -m unittest test_fs_config_generator.Tests
132.............
133----------------------------------------------------------------------
134Ran 13 tests in 0.004s
135
136OK
137
138One could also use nose if they would like:
139$ nose2
140
141To add new tests, simply add a test_<xxx> method to the test class. It will automatically
142get picked up and added to the test suite.