1 _____ _____ _____ _____ __ __ _____ 2/ _ \/ __\/ _ \| _ \/ \/ \/ __\ 3| _ <| __|| _ || | || \/ || __| 4\__|\_/\_____/\__|__/|_____/\__ \__/\_____/ 5 6Generating the android_filesystem_config.h: 7 8To generate the android_filesystem_config.h file, one can set 9TARGET_FS_CONFIG_GEN, which can be a list of intermediate fs configuration 10files. 11 12The parsing of the config file follows the Python ConfigParser specification, 13with the sections and fields as defined below. There are two types of sections, 14both sections require all options to be specified. The first section type is 15the "caps" section. 16 17The "caps" section follows the following syntax: 18 19[path] 20mode: Octal file mode 21user: AID_<user> 22group: AID_<group> 23caps: cap* 24 25Where: 26 27[path] 28 The filesystem path to configure. A path ending in / is considered a dir, 29 else its a file. 30 31mode: 32 A valid octal file mode of at least 3 digits. If 3 is specified, it is 33 prefixed with a 0, else mode is used as is. 34 35user: 36 Either the C define for a valid AID or the friendly name. For instance both 37 AID_RADIO and radio are acceptable. Note custom AIDs can be defined in the 38 AID section documented below. 39 40group: 41 Same as user. 42 43caps: 44 The name as declared in 45 system/core/include/private/android_filesystem_capability.h without the 46 leading CAP_. Mixed case is allowed. Caps can also be the raw: 47 * binary (0b0101) 48 * octal (0455) 49 * int (42) 50 * hex (0xFF) 51 For multiple caps, just separate by whitespace. 52 53It is an error to specify multiple sections with the same [path] in different 54files. Note that the same file may contain sections that override the previous 55section in Python versions <= 3.2. In Python 3.2 it's set to strict mode. 56 57 58The next section type is the "AID" section, for specifying OEM specific AIDS. 59 60The AID section follows the following syntax: 61 62[AID_<name>] 63value: <number> 64 65Where: 66 67[AID_<name>] 68 The <name> can contain characters in the set uppercase, numbers 69 and underscores. 70 71value: 72 A valid C style number string. Hex, octal, binary and decimal are supported. 73 See "caps" above for more details on number formatting. 74 75It is an error to specify multiple sections with the same [AID_<name>]. With 76the same constraints as [path] described above. It is also an error to specify 77multiple sections with the same value option. It is also an error to specify a 78value that is outside of the inclusive OEM ranges: 79 * AID_OEM_RESERVED_START(2900) - AID_OEM_RESERVED_END(2999) 80 * AID_OEM_RESERVED_2_START(5000) - AID_OEM_RESERVED_2_END(5999) 81 82as defined by system/core/include/private/android_filesystem_config.h. 83 84Ordering within the TARGET_FS_CONFIG_GEN files is not relevant. The paths for files are sorted 85like so within their respective array definition: 86 * specified path before prefix match 87 ** ie foo before f* 88 * lexicographical less than before other 89 ** ie boo before foo 90 91Given these paths: 92 93paths=['ac', 'a', 'acd', 'an', 'a*', 'aa', 'ac*'] 94 95The sort order would be: 96paths=['a', 'aa', 'ac', 'acd', 'an', 'ac*', 'a*'] 97 98Thus the fs_config tools will match on specified paths before attempting prefix, and match on the 99longest matching prefix. 100 101The declared AIDS are sorted in ascending numerical order based on the option "value". The string 102representation of value is preserved. Both choices were made for maximum readability of the generated 103file and to line up files. Sync lines are placed with the source file as comments in the generated 104header file. 105 106For OEMs wishing to use the define AIDs in their native code, one can access the generated header 107file like so: 108 1. In your C code just #include "generated_oem_aid.h" and start using the declared identifiers. 109 2. In your Makefile add this static library like so: LOCAL_HEADER_LIBRARIES := oemaids_headers 110 111Unit Tests: 112 113From within the fs_config directory, unit tests can be executed like so: 114$ python -m unittest test_fs_config_generator.Tests 115............. 116---------------------------------------------------------------------- 117Ran 13 tests in 0.004s 118 119OK 120 121One could also use nose if they would like: 122$ nose2 123 124To add new tests, simply add a test_<xxx> method to the test class. It will automatically 125get picked up and added to the test suite. 126 127Using the android_filesystem_config.h: 128 129The tool fs_config_generate is built as a dependency to fs_config_dirs and 130fs_config_files host targets, and #includes the above supplied or generated 131android_filesystem_config.h file, and can be instructed to generate the binary 132data that lands in the device target locations /system/etc/fs_config_dirs and 133/system/etc/fs_config_files and in the host's ${OUT} locations 134${OUT}/target/product/<device>/system/etc/fs_config_dirs and 135${OUT}/target/product/<device>/system/etc/fs_config_files. The binary files 136are interpreted by the libcutils fs_conf() function, along with the built-in 137defaults, to serve as overrides to complete the results. The Target files are 138used by filesystem and adb tools to ensure that the file and directory 139properties are preserved during runtime operations. The host files in the 140${OUT} directory are used in the final stages when building the filesystem 141images to set the file and directory properties. 142 143For systems with separate partition images, such as vendor or oem, 144fs_config_generate can be instructed to filter the specific file references 145to land in each partition's etc/fs_config_dirs or etc/fs_config_files 146locations. The filter can be instructed to blacklist a partition's data by 147providing the comma separated minus sign prefixed partition names. The filter 148can be instructed to whitelist partition data by providing the partition name. 149 150For example: 151- For system.img, but not vendor, oem or odm file references: 152 -P -vendor,-oem,-odm 153 This makes sure the results only contain content associated with the 154 system, and not vendor, oem or odm, blacklisting their content. 155- For vendor.img file references: -P vendor 156- For oem.img file references: -P oem 157- For odm.img file references: -P odm 158 159fs_config_generate --help reports: 160 161Generate binary content for fs_config_dirs (-D) and fs_config_files (-F) 162from device-specific android_filesystem_config.h override. Filter based 163on a comma separated partition list (-P) whitelist or prefixed by a 164minus blacklist. Partitions are identified as path references to 165<partition>/ or system/<partition> 166 167Usage: fs_config_generate -D|-F [-P list] [-o output-file] 168