summaryrefslogtreecommitdiffstats
path: root/roots.cpp (unfollow)
Commit message (Collapse)AuthorFilesLines
2017-10-02roots: Fix an issue with volume_for_path().Tao Bao1-1/+5
The earlier commit in 2dfc1a38982c4052bb32bc7fc06edeadf3908fb9 unintentionally changed the behavior. It gives a different result when looking up non-existent mount points (e.g. /cache on marlin). The logic behind volume_for_path("/xyz") is unclear: - It's fine to return non-null value if it's called by ensure_path_mounted() before accessing that file "/xyz". (Just based on the function name, we're not actually having this case.) - It should return nullptr if the caller is interested in the existence of that particular mount point "/xyz". This CL renames the function to volume_for_mount_point(), which does an exact match by querying the given mount point from libfs_mgr. The former volume_for_path() has been moved down to function scope for serving ensure_path_mounted() only. Test: Build and boot into recovery on bullhead and marlin respectively. 'View recovery logs'. Test: 'Mount /system' Test: 'Apply update from ADB' Change-Id: I1a16390f57540cae08a2b8f3d439d17886975217
2017-09-29roots: Remove #include "common.h".Tao Bao1-2/+2
And add the missing include of <string.h> (e.g. for strcmp(3)). Minor update to the arg of fs_mgr_get_entry_for_mount_point(), which now accepts std::string. Test: mmma bootable/recovery Change-Id: I9cb8c31fe71b5a053f4d84bf1aba00e96c02ed03
2017-09-27roots: volume_for_path() parses and tries prefixes.Tao Bao1-1/+20
Commit cc323958f99e40fea06c511656c69c0b2e2d47f7 in system/core has changed fs_mgr_get_entry_for_mount_point() to do an exact match only, which breaks the behavior in volume_for_path(). This CL changes the volume_for_path() implementation to parse and pass prefixes locally. For a given path like "/cache/recovery/last_log", it will in turn attempt the prefixes of "/cache/recovery/last_log", "/cache/recovery", "/cache", "/" and return the first hit. Bug: 63912287 Test: Build and boot into recovery image on bullhead. 'View recovery logs' works. Change-Id: Ic8635b0939649dd5cc9ca501ebc3a2d1fbf5849d
2017-09-12Integer overflow observed while formatting volumeAbhishek Arpure1-5/+12
While calculating volume size, get_block_device_size() returns u64 value but the returned value is assigned in ssize_t variable. This may cause integer overflow if the volume size is beyond ssize_t limit. Use int64_t instead of ssize_t in get_file_size() and explicitly check for overflow to fix the issue. Bug: 65001754 Test: mmma bootable/recovery Change-Id: I91eb30bff0bf7dcc48678efc2f414d2b79af6d0d
2017-07-26roots.cpp: Clean up format_volume().Tao Bao1-129/+121
Test: m -j bootable/recovery Test: Wipe data/cache in recovery Change-Id: I11a4bf34015e903992ae2fb100d0b59a9fb75e03
2017-07-25recovery: handle security footer before passing size to mke2fsJin Qian1-11/+28
mke2fs doesn't take negative size as reserved size. If footer is specified, compute fs size to be (max partition size - reserved footer size) / block_size Bug: 23686092 Bug: 63968011 Merged-In: Iac4e143bd26a70cfc81eb52a399d687e19b1049c Change-Id: Iac4e143bd26a70cfc81eb52a399d687e19b1049c (cherry picked from commit f3ccad58ddb256150858df55a5e6fe5a906c5754)
2017-07-25recovery: handle security footer before passing size to mke2fsJin Qian1-11/+28
mke2fs doesn't take negative size as reserved size. If footer is specified, compute fs size to be (max partition size - reserved footer size) / block_size Bug: 23686092 Bug: 63968011 Change-Id: Iac4e143bd26a70cfc81eb52a399d687e19b1049c
2017-07-25roots.cpp: Reformatting the file.Tao Bao1-101/+93
Mostly cosmetic changes. Removed the use of errno, and added constness to a few pointers. format_volume() and exec_cmd() will be cleaned up in a separate CL. Test: mmma -j bootable/recovery Change-Id: Ia12ce25a91c0bdd0e319f6da02ce1dc8377f265d
2017-07-23Remove the obsolete reference to /file_contexts.Tao Bao1-3/+1
This file no longer exists: - /file_contexts has been split into plat_file_contexts and nonplat_file_contexts since commit b236eb6ca204cefcb926e19bd5682f9dcad4021d (system/sepolicy). - It was named /file_contexts.bin prior to the split. '-S file_contexts' is also no longer required by e2fsdroid, since commit 2fff6fb036cbbb6dedd7da3d208b312a9038a5ce (external/e2fsprogs). It will load the file contexts via libselinux. Test: Trigger the path by performing a data wipe for converting to FBE. Change-Id: I179939da409e5c0415ae0ea0bf5ddb23f9e6331e (cherry picked from commit 7af933b6a6fd687bd17710ef6fda0ad5483e4d6d)
2017-07-20recovery: replace make_ext4 with e2fsprogsJin Qian1-6/+56
Execute mke2fs to create empty ext4 filesystem. Execute e2fsdroid to add files to filesystem. Test: enter recovery mode and wipe data Bug: 35219933 Change-Id: I10a9f4c1f4754ad864b2df45b1f879180ab33876 (cherry picked from commit ac31808cd37cfb98755e5821dbb2efb5fe5cb12a)
2017-06-27recovery: replace make_ext4 with e2fsprogsJin Qian1-6/+56
Execute mke2fs to create empty ext4 filesystem. Execute e2fsdroid to add files to filesystem. Test: enter recovery mode and wipe data Bug: 35219933 Change-Id: I10a9f4c1f4754ad864b2df45b1f879180ab33876 Merged-In: I10a9f4c1f4754ad864b2df45b1f879180ab33876
2017-05-10recovery: Skip "/" in setup_install_mounts().Tao Bao1-19/+22
We don't want to do anything for "/" when preparing for an install. Bug: 36686818 Test: adb sideload on angler/marlin respectively. Change-Id: Id854dd0a743a0e163a8f13baf2514105091ddc67
2017-05-05recovery: update mkfs.f2fs args to match f2fs-tools 1.8.0Jin Qian1-3/+3
mkfs.f2fs in 1.8.0 returns error if number of sectors is 0. Skip this argument to let mkfs detect device size. 0 sector is also not necessary for 1.4.1. Test: format userdata to f2fs and boot Bug: 37758867 Change-Id: If120988dfb678596c973d183572f870eb0b72a27
2017-03-31recovery: switch to fs_mgr_read_fstab_default()Bowgo Tsai1-2/+2
fs_mgr_read_fstab_default() is now aware of recovery mode so it's ok to switch to this new API. Bug: 35811655 Test: recovery boot sailfish Change-Id: I1025b606fd96e74a893ae99cefc1da01e4b27a23 (cherry picked from commit 84a06485a94f6d2bfe78dbe8b69c517e542a0ce9)
2017-03-29recovery: switch to fs_mgr_read_fstab_default()Bowgo Tsai1-2/+2
fs_mgr_read_fstab_default() is now aware of recovery mode so it's ok to switch to this new API. Bug: 35811655 Test: recovery boot sailfish Change-Id: I1025b606fd96e74a893ae99cefc1da01e4b27a23
2017-03-10recovery: replacing fs_mgr_read_fstab() with new fs_mgr APIsBowgo Tsai1-1/+1
The fstab settings of early-mounted partitions (e.g., /vendor) will be in kernel device tree. Switch to the new API to get the whole settings with those in device tree: fs_mgr_read_fstab_with_dt("/etc/recovery.fstab") The original default /fstab.{ro.hardware} might be moved to /vendor/etc/. or /odm/etc/. Use another new API to get the default fstab instead of using the hard-coded /fstab.{ro.hardware}. This API also includes the settings from device tree: fs_mgr_read_fstab_default() Bug: 35811655 Test: boot sailfish recovery Change-Id: Iaa56ac7f7b4c4dfc7180c65f03e9a37b94f1de09
2017-02-03Replace _exit(-1) with _exit(EXIT_FAILURE).Tao Bao1-1/+1
-1 is not a valid exit status. Also replace a few exit(1) with exit(EXIT_FAILURE). Test: mmma bootable/recovery Change-Id: I4596c8328b770bf95acccc06a4401bd5cabd4bfd
2017-01-25Use flash erase & logical block size for userdata wipeConnor O'Brien1-1/+6
If flash erase and logical block size are available, then pass them to libext4_utils when rebuilding userdata. Test: Factory reset marlin in recovery, confirmed params passed correctly Bug: 33243520 Change-Id: I6bed976a73e7a64a80eaac50f48fbacb6d812517 Signed-off-by: Connor O'Brien <connoro@google.com>
2016-10-09Update the header path for ext4_utils.Tao Bao1-3/+3
Test: `mmma bootable/recovery` Change-Id: I70ccddb3ddf46bb012fdc5f632afc46ebdd5473e
2016-10-07Update the header path for ext4_utils.Tao Bao1-3/+3
Test: `mmma bootable/recovery` Change-Id: I70ccddb3ddf46bb012fdc5f632afc46ebdd5473e (cherry picked from commit 3cbe1d20978dc488272e2b1ba10890a006fdfab9)
2016-09-01Switch recovery to libbase loggingTianjie Xu1-26/+31
Clean up the recovery image and switch to libbase logging. Bug: 28191554 Change-Id: Icd999c3cc832f0639f204b5c36cea8afe303ad35 (cherry picked from commit 747781433fb01f745529c7e9dd97c5599070ad0d)
2016-09-01Switch recovery to libbase loggingTianjie Xu1-26/+31
Clean up the recovery image and switch to libbase logging. Bug: 28191554 Change-Id: Icd999c3cc832f0639f204b5c36cea8afe303ad35 Merged-In: Icd999c3cc832f0639f204b5c36cea8afe303ad35
2016-09-01Switch recovery to libbase loggingTianjie Xu1-26/+31
Clean up the recovery image and switch to libbase logging. Bug: 28191554 Change-Id: Icd999c3cc832f0639f204b5c36cea8afe303ad35
2016-08-12Format formattable partitions if mount failsJohan Harvyl1-1/+14
If mount fails and the partition has the formattable flag set in fstab it is formatted and another attempt at the mount is made. Change-Id: I44edafac7d7ff663489072c66b7e210466316b14
2016-06-10Remove obsolete MTD support.Elliott Hughes1-54/+13
Bug: http://b/29250988 Change-Id: Ia97ba9082a165c37f74d6e1c3f71a367adc59945
2015-11-16recovery: Allow "Mount /system" for system_root_image.Tao Bao1-8/+18
When system images contain the root directory, there is no entry of "/system" in the fstab. Change it to look for "/" instead if ro.build.system_root_image is true. We actually mount the partition to /system_root instead, and create a symlink to /system_root/system for /system. This allows "adb shell" to work properly. Bug: 22855115 Change-Id: I91864444950dc3229fda3cc133ddbadeb8817fb8 (cherry picked from commit abb8f7785ee24eac42f6d28dbfef37872a06c7e9)
2015-11-16DO NOT MERGE recovery: Switch applypatch/ and updater/ to cpp.Tao Bao1-2/+0
Mostly trivial changes to make cpp compiler happy. Change-Id: I69bd1d96fcccf506007f6144faf37e11cfba1270 (cherry picked from commit ba9a42aa7e10686de186636fe9fecbf8c4cc7c19)
2015-11-13Create convert_fbe breadcrumb file to support conversion to FBEPaul Lawrence1-2/+6
Change-Id: I38b29e1e34ea793e4b87cd27a1d39fa905fddf7a
2015-07-31recovery: Allow "Mount /system" for system_root_image.Tao Bao1-8/+18
When system images contain the root directory, there is no entry of "/system" in the fstab. Change it to look for "/" instead if ro.build.system_root_image is true. We actually mount the partition to /system_root instead, and create a symlink to /system_root/system for /system. This allows "adb shell" to work properly. Bug: 22855115 Change-Id: Ibac493a5a9320c98ee3b60bd2cc635b925f5454a
2015-07-14recovery: Switch applypatch/ and updater/ to cpp.Tao Bao1-2/+0
Mostly trivial changes to make cpp compiler happy. Change-Id: I1b0481465c67c3bbca35a839d0764190d84ff34e (cherry picked from commit ba9a42aa7e10686de186636fe9fecbf8c4cc7c19)
2015-07-14recovery: Switch applypatch/ and updater/ to cpp.Tao Bao1-2/+0
Mostly trivial changes to make cpp compiler happy. Change-Id: I69bd1d96fcccf506007f6144faf37e11cfba1270
2015-07-07Allow mounting squashfs partitionsMohamad Ayyash1-0/+1
Change-Id: Ifb8f84063a406db7aad3f9ef12c349ea09a54e07 Signed-off-by: Mohamad Ayyash <mkayyash@google.com> (cherry picked from commit 0ddfa329acb1e6464fe5d66b58257013abf21116)
2015-07-01Allow mounting squashfs partitionsMohamad Ayyash1-0/+1
Change-Id: Ic023eb7d8a11e2a65172a23ff39fa902ef566183 Signed-off-by: Mohamad Ayyash <mkayyash@google.com>
2015-04-02DO NOT MERGE Revert "Erase PST partition if its marked to be erased."Andres Morales1-37/+0
This now gets done at the framework level. Doing it here breaks the signature on the partition. This reverts commit ee19387905650cab5da7dd97ada5502cd17ac93d. Bug: 19967123 Change-Id: I447b926b733ca145f11a916d9569ce39889db627
2015-03-31Revert "Erase PST partition if its marked to be erased."Andres Morales1-37/+0
This now gets done at the framework level. Doing it here breaks the signature on the partition. This reverts commit ee19387905650cab5da7dd97ada5502cd17ac93d. Bug: 19967123 Change-Id: I2a977cb0f0ba94defa1bf9091219398ddc1d3528 (cherry picked from commit 037444642bc32d8fed3bb996823b6a62faa57195)
2015-03-30Revert "Erase PST partition if its marked to be erased."Andres Morales1-37/+0
This now gets done at the framework level. Doing it here breaks the signature on the partition. This reverts commit ee19387905650cab5da7dd97ada5502cd17ac93d. Bug: 19967123 Change-Id: I447b926b733ca145f11a916d9569ce39889db627
2015-03-24always use volume mount option when mounting a partitionGaelle Nassiet1-1/+1
From ROS, if enable adb using the vol.up and vol.down buttons, the /system partition is mounted by the function ensure_path_mounted() but with hardcoded mount options. As a consequence, the blocks are modified and the reboot in MOS is blocked by the dm_verity feature that detects a corruption. This patch forces the function ensure_path_mounted() to use the mount options from the volume structure, that were previously read from the fstab. Change-Id: I748d32c14cb821f4aae5bcc430089dab45375515 Signed-off-by: Gaelle Nassiet <gaellex.nassiet@intel.com> Signed-off-by: Jeremy Compostella <jeremy.compostella@intel.com>
2014-08-06Erase PST partition if its marked to be erased.Andres Morales1-0/+37
We need to wipe the challenges on this partition if OEM unlock is enabled, as this is a signal that the user has opted out of factory reset protection. go/factory-reset Bug: 16633064 Change-Id: Icb8f1433bf99ca57813f5b72d5a3dd15fa94a263
2014-08-05Fix length printing + formatsJP Abgrall1-3/+3
Fix wrong argument order. Fix for 32 vs 64 bit. (reported by htc) Change-Id: Ie37a280bed2848199bcc075500e1326e371cd326
2014-06-17Support F2FS for the data partitionJP Abgrall1-13/+49
This adds F2FS support - for wiping a device - for the install "format" command. Note: crypto data in "footer" with a default/negative length is not supported, unlike with "ext4". Change-Id: I8d141a0d4d14df9fe84d3b131484e9696fcd8870 Signed-off-by: JP Abgrall <jpa@google.com>
2014-04-11Change filesystem add entry API call.Sasha Levitskiy1-1/+1
Needs fs_mgr matching change from: Icf23e659265d71d5226d527c2b40cfbc132320ee Change-Id: I9adb470b04e4301989d128c9c3097b21b4dea431 Signed-off-by: Sasha Levitskiy <sanek@google.com>
2014-01-16do verification and extraction on memory, not filesDoug Zongker1-2/+8
Changes minzip and recovery's file signature verification to work on memory regions, rather than files. For packages which are regular files, install.cpp now mmap()s them into memory and then passes the mapped memory to the verifier and to the minzip library. Support for files which are raw block maps (which will be used when we have packages written to encrypted data partitions) is present but largely untested so far. Bug: 12188746 Change-Id: I12cc3e809834745a489dd9d4ceb558cbccdc3f71
2013-12-13recovery: wipe encryption metadata along with data partitionDoug Zongker1-1/+26
This assumes that the metadata is correctly defined in fstab. Which apparently some devices don't do. Bug: 8766487 Bug: 12112624 Change-Id: I1b14b9d4c888e9348527984be3dce04bdd9f4de0
2013-08-21recovery: install packages in a known mount environmentDoug Zongker1-0/+19
When installing a package, we should have /tmp and /cache mounted and nothing else. Ensure this is true by explicitly mounting them and unmounting everything else as the first step of every install. Also fix an error in the progress bar that crops up when you do multiple package installs in one instance of recovery. Change-Id: I4837ed707cb419ddd3d9f6188b6355ba1bcfe2b2
2013-02-20Move to using the new unified fstab in recovery.Ken Sumrall1-110/+30
Instead of reading it's own fstab, have recovery invoke fs_mgr to read the unified fstab. Change-Id: I80c75d2c53b809ac60a4a69f0ef7ebfa707c39e9
2011-10-31turn recovery into a C++ binaryDoug Zongker1-3/+3
Change-Id: I423a23581048d451d53eef46e5f5eac485b77555
2011-10-28turn recovery into a C++ binaryDoug Zongker1-282/+0
Change-Id: I68a67a4c8edec9a74463b3d4766005ce27b51316
2011-04-12save a last_install file with the result of the last package install attemptDoug Zongker1-3/+2
When installing a package, create /cache/recovery/last_install, which contains the filename of the package and a 1 or 0 for success or failure. Also, don't mount ext4 and vfat filesystems as read-only (on devices where /cache is ext4, we need it to be read-write). Change-Id: I0cf2a1921bbd65e06343aa74e2006577fac77c2c
2011-03-12recovery: mount /sdcard read-onlyIliyan Malchev1-2/+3
Change-Id: Ieffafe00cf82620057cacd0629cb60b0e6aad817 Signed-off-by: Iliyan Malchev <malchev@google.com>
2011-02-25store partition length in recovery.fstabDoug Zongker1-9/+35
Don't hardcode magical partition behavior in roots.c. Change-Id: I587fc2c066575b51c11efd2e45a50f5b864df484
2011-02-25store partition length in recovery.fstabDoug Zongker1-9/+35
Don't hardcode magical partition behavior in roots.c. Change-Id: I587fc2c066575b51c11efd2e45a50f5b864df484
2011-02-18store partition length in recovery.fstabDoug Zongker1-9/+35
Don't hardcode magical partition behavior in roots.c. Change-Id: I587fc2c066575b51c11efd2e45a50f5b864df484
2011-01-20Reserve the last 16 Kbytes of /data for the crypto footer.Ken Sumrall1-2/+6
When formatting /data, if it's an ext4 filesystem, reserve the last 16 Kbytes for the crypto footer. Change-Id: I7b401d851ee87732e5da5860df0287a1c331c5b7
2011-01-06Update make_ext4fs arguments in roots.cColin Cross1-1/+1
Change-Id: I835e55fb80add6a74cd4d99f77b2528829d9a349
2010-09-22mount sdcard only on demand; fix sideload installsDoug Zongker1-0/+20
Bug: 3009493 Change-Id: I1a7f99fc41a6a7012742e82f8c06a0c75584890a
2010-09-21remove the notion of "root path"; support mixed flash typesDoug Zongker1-254/+137
Remove the wacky notion of "roots" and "root paths" (those things that look like "FOO:some/path" instead of just "/foo/some/path"). Let each device specify its own table of available partitions and how to mount them (needed for devices that use both MTD/yaffs2 and EMMC/ext4 partitions). (Cherrypicked from gingerbread w/slight edits.) Change-Id: I2479ce76b13e73f1d12035c89386c3a82b3edf51
2010-09-21remove the notion of "root path"; support mixed flash types (do not merge)Doug Zongker1-233/+146
Remove the wacky notion of "roots" and "root paths" (those things that look like "FOO:some/path" instead of just "/foo/some/path"). Let each device specify its own table of available partitions and how to mount them (needed for devices that use both MTD/yaffs2 and EMMC/ext4 partitions). Change-Id: I18b0a572a71c5e087e0b7ae11b1774388339bfd1
2010-09-17remove unneeded partition rootsDoug Zongker1-55/+0
Recovery itself no longer needs to access all these partitions; manipulation of them is done by the updater binary. This is a small first step towards removing roots entirely. Change-Id: I3fbcada32079a37db4cc097861dfa91e0a08da30
2010-08-14Changes to work with updated make_ext4fs tool that supports creating sparse images.Ken Sumrall1-1/+1
An extra parameter was added to the make_ext4fs() function, we these tools need to be updated to match. Change-Id: Id640a7f2b03153eb333b00337f0f991ff5332349
2010-08-13support using an EMMC misc partition to store recovery argumentsDoug Zongker1-1/+3
Change-Id: I9f912857cfc6afb8ba764f5541af7f01df029a77
2010-07-30generalize "install from sdcard" to "install from external storage"Doug Zongker1-3/+2
Allow sideloading of OTA packages from USB drives that appear as /dev/block/sda1. Change-Id: I1908576c24547cd0088475d8c8917699cd906868
2010-07-09make a copy of sideloaded packages in /tmp before verifyingDoug Zongker1-2/+5
Copy a sideloaded package into /tmp, then verify and install the copy, to prevent malicious users from overwriting the package between verification and install. Bug: 2826890 package can be replaced during verification Bug: 2058160 Recovery should copy sideloaded (sd card) update ... Change-Id: I3de148b0f1a671f1974782b6855527caeaefda23
2010-06-30support userdata and cache partitions using emmc/ext4 instead of mtd/yaffsDoug Zongker1-4/+32
Change-Id: I827af624c9ec7c64decb702de8c0310cf19b4141
2009-11-13eclair snapshotJean-Baptiste Queru1-0/+1
2009-06-19add function for device-specific wipe data featuresDoug Zongker1-0/+1
Some devices want to do special things when recovery wipes data (eg, wipe data in their baseband processor as well). Add a hook in the device-specific recovery library that gets called when data is wiped. Also add an amend root for the "mbm" partition.
2009-03-04auto import from //depot/cupcake/@135843The Android Open Source Project1-0/+370
2009-03-04auto import from //depot/cupcake/@135843The Android Open Source Project1-370/+0