summaryrefslogtreecommitdiff
path: root/init/builtins.cpp
AgeCommit message (Collapse)Author
2021-03-11Merge SP1A.210311.001Scott Lobdell
Change-Id: I01c4c598ed6764fc1936b2baaab660e585a3984c
2021-03-05Check if service is executed before APEX is readyKiyoung Kim
Any service which is executed when Runtime apex is mounted, but linkerconfig is not updated can fail to be executed due to missing information in ld.config.txt. This change updates init to have a status variable which contains if current mount namespace is default and APEX is not ready from ld.config.txt, and use bootstrap namespace if it is not ready. Bug: 181348374 Test: cuttlefish boot succeeded Change-Id: Ia574b1fad2110d4e68586680dacbe6137186546e
2021-02-19Introduce load_exports action.Artur Satayev
The action reads a file with individual `export` actions declared on each line, and calls `setenv` for each. See go/updatable-classpath for details on how this is going to be used. Bug: 180105615 Test: manual Change-Id: I5390e52cf8ffd9c3babf31ed854eeecc727351eb
2021-02-08Merge SP1A.210208.001Daniel Norman
Change-Id: I16e0e3c65461673b714dd66a389670445608d017
2021-01-20Set hashtree algorithm for verity partitionsTianjie
This is used in cts tests to verify that algorithms in blocklist aren't used to build the hashtree. The system properties are required to perform the check on unrooted devices. Bug: 175236047 Test: flash, getprop; atest CtsNativeVerifiedBootTestCases Change-Id: I2dcfdb06f85dbe92cde45e836dd68e7bd835020f
2020-12-07Merge SP1A.201207.001Daniel Norman
Change-Id: I7392e79bce6c4479997bc98770df1b2e850edcd7
2020-12-02Use bootstrap linkerconfig from early initKiyoung Kim
Linkerconfig will be moved into Runtime APEX, so /system/bin/linkerconfig would not be available before APEX is mounted. Use bootstrap linkerconfig instead during early init. Bug: 165769179 Test: Cuttlefish boot succeeded Change-Id: Iae41f325bbd5f5194aaf4613141860f913dfbff1
2020-11-30Merge SP1A.201130.001Daniel Norman
Change-Id: Ifcb754098c052feda32283cc056a9d760048832f
2020-11-20init: add a copy_per_line built-in commandWei Wang
There are sysfs nodes that don't take multiple inputs, adding a new copy_per_line built-in command to copy from source file to destination line by line. Bug: 171740453 Test: boot and check file and log Change-Id: I41b7a565829299d56b81d4509525dfa6a0a52444
2020-09-21Merge SP1A.200921.001Justin DeMartino
Change-Id: I90b97c4e9fb10b1f45e74def404823eed5b1aaa8
2020-09-08Only store result of mount_all that mounted userdataNikita Ioffe
During boot sequence there can be multiple calls to mount_all. For the userspace reboot to correctly remount userdata, we need to store the return code of the one that was responsible in mounting userdata. Test: adb root Test: adb shell setprop init.userspace_reboot.is_supported 1 Test: adb reboot userspace Test: checked dmsg Bug: 166353152 Change-Id: Id0ae15f3bcf65fa54e4e72b76f64716c053af7fb
2020-09-03Merge SP1A.200727.001Daniel Norman
Change-Id: I8f6750352c361cdc5b23825395234de12384ddd7
2020-08-26Merge "Store userspace reboot info in /metadata"Gavin Corkery
2020-08-21Store userspace reboot info in /metadataGavin Corkery
Store pertinent information about userspace reboot events in the case of failure. This information is any services which failed to stop cleanly, the output of the default fstab and /proc/mounts, and a list of mounts which failed to unmount. This information is only stored as necessary (i.e. mount information will not be stored if everything unmounted, even if some services failed to stop). Added new /metadata/userspacereboot directory to persist this information. Information older than 3 days will be deleted. Test: adb reboot userspace with sigterm/sigkill timeouts set to very low values Test: Manual test of storing all other information Bug: 151820675 Change-Id: I6cfbfae92a7fc6f6c984475cad2c50c559924866
2020-08-14Set ro.crypto.type even on failurePaul Crowley
Move responsibility for setting ro.crypto.type into fs_mgr_mount_all, so that even if setting up the filesystem fails, the type is set correctly and so errors are appropriately handled. Bug: 162289984 Test: simulate a failure and check that it's set. Change-Id: Ib061a454e7e21d7206c3c1fa8e88e16618099581
2020-06-11init: start ueventd in the default mount namespaceJooyung Han
Init starts ueventd in the default mount namespace to support loading firmware from APEXes. Bug: 155023652 Test: devices boots adb$ nsenter -t (pid of ueventd) -m ls /apex => shows all APEXes Change-Id: Ibb8b33a07eb014752275e3bca4541b8b694dc64b
2020-06-09Merge RP1A.200609.001Steven Laver
Change-Id: Iab3df682635e7c2b9a9bc94fed9a61a8842bcf3b
2020-06-08Respect ro.boot.fstab_suffix in swapon_allAlistair Delva
While mount_all and umount_all were updated to use ro.boot.fstab_suffix, I neglected to update swapon_all. Trivially copied from umount_all. Bug: 142424832 Change-Id: Icd706fe7a1fe16c687cd2811b0a3158d7d2e224e Merged-In: Icd706fe7a1fe16c687cd2811b0a3158d7d2e224e
2020-06-08Respect ro.boot.fstab_suffix in swapon_allAlistair Delva
While mount_all and umount_all were updated to use ro.boot.fstab_suffix, I neglected to update swapon_all. Trivially copied from umount_all. Bug: 142424832 Change-Id: Icd706fe7a1fe16c687cd2811b0a3158d7d2e224e
2020-06-02Merge RP1A.200601.001Steven Laver
Change-Id: I102331b5c7993a089d4350a75dab8788566d6e20
2020-05-29Merge RP1A.200526.001Scott Lobdell
Change-Id: Ic5248ed68b2edd7cada9fc67057fe8906af96040
2020-05-28Add ro.boot.fstab_suffix and modify mount_all to use itAlistair Delva
Currently the ReadDefaultFstab function, which calls GetFstabPath, makes some assumptions about what the fstab will be called and where it is located. This is being used by vold to set up userdata encryption and for gsid, and is even used in the default boot control HAL, so it has become quite baked. The original way for a board to specify things to mount was to use the "mount_all /path/to/fstab" command in init.rc. However, due to the above functionality, the path after mount_all is no longer very useful, as it cannot differ from the inferred path, or userdata encryption and other features will be broken. On Cuttlefish, we have an interest in being able to test alternative userdata configurations (ext4 vs f2fs, encryption on/off, etc.) and currently the only way to achieve this is to either a) modify the ro.hardware or ro.hardware.platform properties, which breaks a bunch of things like default HAL filenames, or regenerate our odm.img or vendor.img filesystems. We can't simply install another fstab and point to it with "mount_all". This change allows the fstab path to be omitted from "mount_all", and adds another property which overrides the existing checks for fstab.${ro.hardware} and fstab.${ro.hardware.platform}. Specifying ${ro.boot.fstab_suffix} will cause fstab.${ro.boot.fstab_suffix} to be checked first. Bug: 142424832 Test: booted cuttlefish with 'mount_all ${ro.hardware} --late' Test: booted cuttlefish with 'mount_all --late' Test: booted cuttlefish with 'mount_all --late' and fstab_suffix=f2fs Test: partially booted cuttlefish with 'mount_all ${ro.hardware}' Test: partially booted cuttlefish with 'mount_all' Change-Id: I3e10f66aecfcd48bdb9ebf1d304b7aae745cbd3c Merged-In: I3e10f66aecfcd48bdb9ebf1d304b7aae745cbd3c
2020-05-21Add ro.boot.fstab_suffix and modify mount_all to use itAlistair Delva
Currently the ReadDefaultFstab function, which calls GetFstabPath, makes some assumptions about what the fstab will be called and where it is located. This is being used by vold to set up userdata encryption and for gsid, and is even used in the default boot control HAL, so it has become quite baked. The original way for a board to specify things to mount was to use the "mount_all /path/to/fstab" command in init.rc. However, due to the above functionality, the path after mount_all is no longer very useful, as it cannot differ from the inferred path, or userdata encryption and other features will be broken. On Cuttlefish, we have an interest in being able to test alternative userdata configurations (ext4 vs f2fs, encryption on/off, etc.) and currently the only way to achieve this is to either a) modify the ro.hardware or ro.hardware.platform properties, which breaks a bunch of things like default HAL filenames, or regenerate our odm.img or vendor.img filesystems. We can't simply install another fstab and point to it with "mount_all". This change allows the fstab path to be omitted from "mount_all", and adds another property which overrides the existing checks for fstab.${ro.hardware} and fstab.${ro.hardware.platform}. Specifying ${ro.boot.fstab_suffix} will cause fstab.${ro.boot.fstab_suffix} to be checked first. Bug: 142424832 Test: booted cuttlefish with 'mount_all ${ro.hardware} --late' Test: booted cuttlefish with 'mount_all --late' Test: booted cuttlefish with 'mount_all --late' and fstab_suffix=f2fs Test: partially booted cuttlefish with 'mount_all ${ro.hardware}' Test: partially booted cuttlefish with 'mount_all' Change-Id: I3e10f66aecfcd48bdb9ebf1d304b7aae745cbd3c
2020-05-19init: support wait timeout with more precisionMark Salyzyn
A one second timeout is so coarse and can affect boot time when the possibility that the file does not exist. Switch to accepting a floating point number for seconds for the wait for file command. Signed-off-by: Mark Salyzyn <salyzyn@google.com> Bug: 151950334 Test: wait_for_file sleep 0.05 reports an appropriate delay Change-Id: I8d8ed386519ab54270b05ce91663d0add30f12e7
2020-05-15init: support wait timeout with more precisionMark Salyzyn
A one second timeout is so coarse and can affect boot time when the possibility that the file does not exist. Switch to accepting a floating point number for seconds for the wait for file command. Signed-off-by: Mark Salyzyn <salyzyn@google.com> Bug: 151950334 Test: wait_for_file sleep 0.05 reports an appropriate delay Change-Id: I8d8ed386519ab54270b05ce91663d0add30f12e7
2020-03-18Merge RP1A.200318.001Steven Laver
Change-Id: Id38ec56ae91da3eaea715332e5d3fac8d7ebbb32
2020-03-16Revert "init: handle property service callbacks asynchronously"Tom Cherry
This is apparently causing problems with reboot. This reverts commit d2dab830d3ec260ccd982d147d4eb0ef74071261. Bug: 150863651 Test: build Merged-In: Ib8a4835cdc8358a54c7acdebc5c95038963a0419 Change-Id: Ib8a4835cdc8358a54c7acdebc5c95038963a0419
2020-03-10Revert "init: handle property service callbacks asynchronously"Tom Cherry
This is apparently causing problems with reboot. This reverts commit 7205c6293341c82701e849fa29cfab66916d1052. Bug: 150863651 Test: build Change-Id: Ib8a4835cdc8358a54c7acdebc5c95038963a0419
2020-03-06Merge RP1A.200304.001Steven Laver
Change-Id: I2f68a4d411c470987a63e3fa4eaf51ad5ab8fb25
2020-03-02init: handle property service callbacks asynchronouslyTom Cherry
A previous change moved property_service into its own thread, since there was otherwise a deadlock whenever a process called by init would try to set a property. This new thread, however, would send a message via a blocking socket to init for each property that it received, since init may need to take action depending on which property it is. Unfortunately, this means that the deadlock is still possible, the only difference is the socket's buffer must be filled before init deadlocks. There are possible partial solutions here: the socket's buffer may be increased or property_service may only send messages for the properties that init will take action on, however all of these solutions still lead to eventual deadlock. The only complete solution is to handle these messages asynchronously. This change, therefore, adds the following: 1) A lock for instructing init to reboot 2) A lock for waiting on properties 3) A lock for queueing new properties 4) A lock for any actions with ServiceList or any Services, enforced through thread annotations, particularly since this code was not designed with the intention of being multi-threaded. Bug: 146877356 Bug: 148236233 Test: boot Test: kill hwservicemanager without deadlock Merged-In: I84108e54217866205a48c45e8b59355012c32ea8 Change-Id: I84108e54217866205a48c45e8b59355012c32ea8 (cherry picked from commit 7205c6293341c82701e849fa29cfab66916d1052)
2020-02-20init: handle property service callbacks asynchronouslyTom Cherry
A previous change moved property_service into its own thread, since there was otherwise a deadlock whenever a process called by init would try to set a property. This new thread, however, would send a message via a blocking socket to init for each property that it received, since init may need to take action depending on which property it is. Unfortunately, this means that the deadlock is still possible, the only difference is the socket's buffer must be filled before init deadlocks. There are possible partial solutions here: the socket's buffer may be increased or property_service may only send messages for the properties that init will take action on, however all of these solutions still lead to eventual deadlock. The only complete solution is to handle these messages asynchronously. This change, therefore, adds the following: 1) A lock for instructing init to reboot 2) A lock for waiting on properties 3) A lock for queueing new properties 4) A lock for any actions with ServiceList or any Services, enforced through thread annotations, particularly since this code was not designed with the intention of being multi-threaded. Bug: 146877356 Bug: 148236233 Test: boot Test: kill hwservicemanager without deadlock Change-Id: I84108e54217866205a48c45e8b59355012c32ea8
2020-02-14Merge RP1A.200214.001Steven Laver
Change-Id: I40351c1202f6bdca316a14937c6842f77f4c4b73
2020-02-10Merge "Don't log userspace_reboot.started/finished properties from init"Nikita Ioffe
2020-02-07Don't log userspace_reboot.started/finished properties from initNikita Ioffe
Instead they will be logged from system_server. This CL just prepares grounds for logging CL to land. Test: adb reboot userspace Bug: 148767783 Change-Id: Ie9482ef735344ecfb0de8a37785d314a3c0417ff
2020-02-06Convert system/core to Result::ok()Bernie Innocenti
No functionality changes, this is a mechanical cleanup. Test: m Test: cd system/core && atest Change-Id: Ifdaa3ce1947ed578f656d5a446978726eb416c36
2020-02-04Merge RP1A.200204.001Steven Laver
Change-Id: I6e7b77b53ef2e013a10f9dc68bc5fd2ebfeb2818
2020-01-23Merge RP1A.200123.001Steven Laver
Change-Id: I9a5261600a4bbae9e68b1e7ee554be2fd1c7525c
2020-01-23Whitelist reboot reasons related to userspace reboot failureNikita Ioffe
Test: system/core/bootstat/boot_reason_test.sh Bug: 135984674 Change-Id: I31422329f1109273909293a83913ae801eb1fe52
2020-01-17Give x permission on apex data directories.Oli Lan
This gives search (x) permission on the parent apex data directory /data/misc/apexdata so that directories below it may be opened. It also gives that permission on the apex data directories themselves. Bug: 147848983 Test: Build & flash, check perms are correct Change-Id: I27c4ea01602002c89d0771a144265e3879d9041a
2020-01-15Don't reboot into recovery during userspace rebootNikita Ioffe
In case one of the cryptfs calls to vdc fails, first try a normal reboot. Test: manual Bug: 135984674 Bug: 143970043 Change-Id: I5706d9cd6c3a08fa06329ffb7d141de632620e3d
2020-01-06Merge RP1A.200106.001Steven Laver
Change-Id: Iac92eee679219e76109967cf7d49914759313ccd
2020-01-03Change ownership of apex data directories to root.Oli Lan
The apex data directories must be accessed by apexd in order for it to perform snapshot and restore as part of the rollback process. As apexd runs as root, this CL changes the apex data directories under /data/misc to be owned by root. Bug: 141148175 Test: Build and flash; check permissions are set correctly. Change-Id: Ib534e705802c06900884a15f39fee257d4987f4c
2019-12-30Update linkerconfig to target out directoryKiyoung Kim
Current linkerconfig targets for specific output file. However, linkerconfig will generate more than 1 file based on APEX modules, so it should take argument for target directory rather than target file. This change updates linkerconfig's argument to point output directory. Bug: 146993126 Test: m -j passed & Cuttlefish succeeded to boot Change-Id: I3a720a047077688582436aabd307adafeafc5398
2019-12-20Generate linkerconfig per mount namespacesKiyoung Kim
There are two namespaces from init - bootstrap and default - and those will have different set of APEX modules. To support difference between two namespaces, linker config should be generated per namespace and each namespace should use its own linker configuration. As a first step of the work, this change will create different mount point for each namespace, and re-generate linker config after APEX mount from each namespaces. Bug: 144664390 Test: m -j passed & tested from cuttlefish Change-Id: Iac2e222376ec4b0ced6c29eed18b21d39ff0b1ba
2019-12-17Merge RP1A.191212.001Steven Laver
Change-Id: Ibadaa2dbfc58f0ec849233ba593dbb75dce237a9
2019-12-09Create DE_sys APEX data directories.Oli Lan
This creates the directory /data/misc/apexdata, at the same time as other directories under /data/misc. Then, when apexd has finished activating APEXes, a directory is created under /data/misc/apexdata for every APEX, with the same name as the APEX module name. See go/apex-data-directories. APEXes are discovered by scanning the /apex directory. It may be better to delegate this process to a library, but it is proposed to defer that change to a future CL. Bug: 141148175 Test: Built and flashed, checked directories were created. Change-Id: I639d6f490ae0b97f116ce38ff3ac348bd73aa20e
2019-12-06Merge RP1A.191203.001Steven Laver
Change-Id: Ie100c20a4e29ae7b582205b89b320ecac9a20fbf
2019-12-06Merge "Remove service defined in an APEX during userspace reboot"Nikita Ioffe
2019-12-05Remove service defined in an APEX during userspace rebootNikita Ioffe
Such services will be re-parsed and added back to the service list during post-fs-data stage. Test: adb reboot userspace Test: atest CtsInitTestCases Bug: 145669993 Bug: 135984674 Change-Id: Ibb393dfe0f101c4ebe37bc763733fd5d981d3691
2019-12-04init: Replace property_set() with android::base::SetProperty()Tom Cherry
Init is no longer a special case and talks to property service just like every other client, therefore move it away from property_set() and to android::base::SetProperty(). In doing so, this change moves the initial property set up from the kernel command line and property files directly into PropertyInit(). This makes the responsibilities between init and property services more clear. Test: boot, unit test cases Change-Id: I36b8c83e845d887f1b203355c2391ec123c3d05f