fs_config: android_id header generator
Implement an android_id generator that takes the data acquired from parsing private/android_filesystem_config.h and generates the android_id friendly name to uid mapping for consumption in Bionic. Test: That ls, ps, mkdir, chown, chgrp and services for built in names work. Change-Id: I1e55a401be0fca0ad162f8dc1e072e6afde7b927 Signed-off-by: William Roberts <william.c.roberts@intel.com>
This commit is contained in:
parent
64edf5bb97
commit
d7104bca65
|
@ -16,6 +16,9 @@ import re
|
|||
import sys
|
||||
import textwrap
|
||||
|
||||
# Keep the tool in one file to make it easy to run.
|
||||
# pylint: disable=too-many-lines
|
||||
|
||||
|
||||
# Lowercase generator used to be inline with @staticmethod.
|
||||
class generator(object): # pylint: disable=invalid-name
|
||||
|
@ -360,7 +363,7 @@ class AIDHeaderParser(object):
|
|||
Returns:
|
||||
A list of AID() objects.
|
||||
"""
|
||||
return self._aid_name_to_value.values()
|
||||
return self._aid_name_to_value
|
||||
|
||||
@staticmethod
|
||||
def _convert_lst_to_tup(name, lst):
|
||||
|
@ -942,6 +945,58 @@ class FSConfigGen(BaseGenerator):
|
|||
print FSConfigGen._CLOSE_FILE_STRUCT
|
||||
|
||||
|
||||
@generator('aidarray')
|
||||
class AIDArrayGen(BaseGenerator):
|
||||
"""Generates the android_id static array."""
|
||||
|
||||
_GENERATED = ('/*\n'
|
||||
' * THIS IS AN AUTOGENERATED FILE! DO NOT MODIFY!\n'
|
||||
' */')
|
||||
|
||||
_INCLUDE = '#include <private/android_filesystem_config.h>'
|
||||
|
||||
_STRUCT_FS_CONFIG = textwrap.dedent("""
|
||||
struct android_id_info {
|
||||
const char *name;
|
||||
unsigned aid;
|
||||
};""")
|
||||
|
||||
_OPEN_ID_ARRAY = 'static const struct android_id_info android_ids[] = {'
|
||||
|
||||
_ID_ENTRY = ' { "%s", %s },'
|
||||
|
||||
_CLOSE_FILE_STRUCT = '};'
|
||||
|
||||
_COUNT = ('#define android_id_count \\\n'
|
||||
' (sizeof(android_ids) / sizeof(android_ids[0]))')
|
||||
|
||||
def add_opts(self, opt_group):
|
||||
|
||||
opt_group.add_argument(
|
||||
'hdrfile', help='The android_filesystem_config.h'
|
||||
'file to parse')
|
||||
|
||||
def __call__(self, args):
|
||||
|
||||
hdr = AIDHeaderParser(args['hdrfile'])
|
||||
|
||||
print AIDArrayGen._GENERATED
|
||||
print
|
||||
print AIDArrayGen._INCLUDE
|
||||
print
|
||||
print AIDArrayGen._STRUCT_FS_CONFIG
|
||||
print
|
||||
print AIDArrayGen._OPEN_ID_ARRAY
|
||||
|
||||
for name, aid in hdr.aids.iteritems():
|
||||
print AIDArrayGen._ID_ENTRY % (name, aid.identifier)
|
||||
|
||||
print AIDArrayGen._CLOSE_FILE_STRUCT
|
||||
print
|
||||
print AIDArrayGen._COUNT
|
||||
print
|
||||
|
||||
|
||||
def main():
|
||||
"""Main entry point for execution."""
|
||||
|
||||
|
|
Loading…
Reference in New Issue