William Roberts | c950a35 | 2016-03-04 18:12:29 -0800 | [diff] [blame] | 1 | _____ _____ _____ _____ __ __ _____ |
| 2 | / _ \/ __\/ _ \| _ \/ \/ \/ __\ |
| 3 | | _ <| __|| _ || | || \/ || __| |
| 4 | \__|\_/\_____/\__|__/|_____/\__ \__/\_____/ |
| 5 | |
| 6 | |
| 7 | Generating the android_filesystem_config.h |
| 8 | |
| 9 | To generate the android_filesystem_config.h file, one can choose from |
| 10 | one of two methods. The first method, is to declare |
| 11 | TARGET_ANDROID_FILESYSTEM_CONFIG_H in the device BoardConfig.mk file. This |
| 12 | variable can only have one item in it, and it is used directly as the |
| 13 | android_filesystem_config.h header when building |
| 14 | fs_config_generate_$(TARGET_DEVICE) which is used to generate fs_config_files |
| 15 | and fs_config_dirs target executable. |
| 16 | |
| 17 | The limitation with this, is that it can only be set once, thus if the device |
| 18 | has a make hierarchy, then each device needs its own file, and cannot share |
| 19 | from a common source or that common source needs to include everything from |
| 20 | both devices. |
| 21 | |
| 22 | The other way is to set TARGET_FS_CONFIG_GEN, which can be a list of |
| 23 | intermediate fs configuration files. It is a build error on any one |
| 24 | these 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 | |
| 29 | The parsing of the config file follows the Python ConfigParser specification, |
| 30 | with the sections and fields as defined below. There are two types of sections, |
| 31 | both sections require all options to be specified. The first section type is |
| 32 | the "caps" section. |
| 33 | |
| 34 | The "caps" section follows the following syntax: |
| 35 | |
| 36 | [path] |
| 37 | mode: Octal file mode |
| 38 | user: AID_<user> |
| 39 | group: AID_<group> |
| 40 | caps: cap* |
| 41 | |
| 42 | Where: |
| 43 | |
| 44 | [path] |
| 45 | The filesystem path to configure. A path ending in / is considered a dir, |
| 46 | else its a file. |
| 47 | |
| 48 | mode: |
| 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 | |
| 52 | user: |
| 53 | The exact, C define for a valid AID. Note custom AIDs can be defined in the |
| 54 | AID section documented below. |
| 55 | |
| 56 | group: |
| 57 | The exact, C define for a valid AID. Note custom AIDs can be defined in the |
| 58 | AID section documented below. |
| 59 | |
| 60 | caps: |
| 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 Roberts | db616f0 | 2016-04-09 10:24:25 -0700 | [diff] [blame^] | 70 | It is an error to specify multiple sections with the same [path] in different |
| 71 | files. Note that the same file may contain sections that override the previous |
| 72 | section in Python versions <= 3.2. In Python 3.2 it's set to strict mode. |
William Roberts | c950a35 | 2016-03-04 18:12:29 -0800 | [diff] [blame] | 73 | |
| 74 | |
| 75 | The next section type is the "AID" section, for specifying OEM specific AIDS. |
| 76 | |
| 77 | The AID section follows the following syntax: |
| 78 | |
| 79 | [AID_<name>] |
| 80 | value: <number> |
| 81 | |
| 82 | Where: |
| 83 | |
| 84 | [AID_<name>] |
| 85 | The <name> can be any valid character for a #define identifier in C. |
| 86 | |
| 87 | value: |
William Roberts | db616f0 | 2016-04-09 10:24:25 -0700 | [diff] [blame^] | 88 | A valid C style number string. Hex, octal, binary and decimal are supported. |
| 89 | See "caps" above for more details on number formatting. |
William Roberts | c950a35 | 2016-03-04 18:12:29 -0800 | [diff] [blame] | 90 | |
William Roberts | db616f0 | 2016-04-09 10:24:25 -0700 | [diff] [blame^] | 91 | It is an error to specify multiple sections with the same [AID_<name>]. With |
| 92 | the same constraints as [path] described above. It is also an error to specify |
| 93 | multiple sections with the same value option. It is also an error to specify a |
| 94 | value that is outside of the inclusive OEM ranges: |
William Roberts | 580f2c4 | 2016-04-08 22:03:42 -0700 | [diff] [blame] | 95 | * AID_OEM_RESERVED_START(2900) - AID_OEM_RESERVED_END(2999) |
| 96 | * AID_OEM_RESERVED_2_START(5000) - AID_OEM_RESERVED_2_END(5999) |
| 97 | |
William Roberts | c950a35 | 2016-03-04 18:12:29 -0800 | [diff] [blame] | 98 | as defined by system/core/include/private/android_filesystem_config.h. |
| 99 | |
| 100 | Ordering within the TARGET_FS_CONFIG_GEN files is not relevant. The paths for files are sorted |
| 101 | like so within their respective array definition: |
| 102 | * specified path before prefix match |
| 103 | ** ie foo before f* |
| 104 | * lexicographical less than before other |
| 105 | ** ie boo before foo |
| 106 | |
| 107 | Given these paths: |
| 108 | |
| 109 | paths=['ac', 'a', 'acd', 'an', 'a*', 'aa', 'ac*'] |
| 110 | |
| 111 | The sort order would be: |
| 112 | paths=['a', 'aa', 'ac', 'acd', 'an', 'ac*', 'a*'] |
| 113 | |
| 114 | Thus the fs_config tools will match on specified paths before attempting prefix, and match on the |
| 115 | longest matching prefix. |
| 116 | |
| 117 | The declared AIDS are sorted in ascending numerical order based on the option "value". The string |
| 118 | representation of value is preserved. Both choices were made for maximum readability of the generated |
| 119 | file and to line up files. Sync lines are placed with the source file as comments in the generated |
| 120 | header file. |