Commit graph

33 commits

Author SHA1 Message Date
caozhiyuan
cb9450e113 Use f_bavail to calculate free space
Failures are seen on devices with
Linux 3.10. And they are mainly due to this change:
https://lwn.net/Articles/546473/
The blocks reserved in this change is not the same thing as what we
think are reserved for common usage of root user. And this part is
included in free blocks but not in available blocks.

Bug: 22118089
Change-Id: I81c9531703298019a4fc11839f28d2cc8b9df34e
(cherry picked from commit 3b4977638f)
2015-06-26 11:17:02 -07:00
Elliott Hughes
2f5feedf1d Check all lseek calls succeed.
Also add missing TEMP_FAILURE_RETRYs on read, write, and lseek.

Bug: http://b/20625546
Change-Id: I03b198e11c1921b35518ee2dd005a7cfcf4fd94b
(cherry picked from commit 7bad7c4646)
2015-04-29 21:14:56 -07:00
Michael Runge
be81e51c17 Use more aggressive sync writing to applypatch.
We have seen cases where the boot partition is patched, but upon
recovery the partition appears to be corrupted.  Open up all
patched files/partitions with O_SYNC, and do not ignore the
errors from fsync/close operations.

Bug: 18170529
Change-Id: I392ad0a321d937c4ad02eaeea9170be384a4744b
2014-10-29 13:00:21 -07:00
Doug Zongker
bc7ffeda98 installer for new block OTA system
(Cherry-pick back from master.)

Bug: 16984795
Change-Id: Ifa3d8345c5e2a0be86fb28faa080ca82592a96b4
2014-08-19 16:53:39 -07:00
Mark Salyzyn
679baa06b7 am 4b6de1ba: am 026ebe02: Merge "Recovery 64-bit compile issues"
* commit '4b6de1ba1ce0fff95c18a8abb7ba6e5762006d49':
  Recovery 64-bit compile issues
2014-03-14 21:35:41 +00:00
Mark Salyzyn
4b6de1ba1c am 026ebe02: Merge "Recovery 64-bit compile issues"
* commit '026ebe0214d6c1c9b3ddc22c35e9ac37e5f622bc':
  Recovery 64-bit compile issues
2014-03-14 20:59:56 +00:00
Mark Salyzyn
f3bb31c32f Recovery 64-bit compile issues
Change-Id: I92d5abd1a628feab3b0246924fab7f97ba3b9d34
2014-03-14 13:51:39 -07:00
Doug Zongker
a1bc148c7c remove 'retouch' ASLR support
Older versions of android supported an ASLR system where binaries were
randomly twiddled at OTA install time.  Remove support for this; we
now use the ASLR support in the linux kernel.

Change-Id: I8348eb0d6424692668dc1a00e2416fbef6c158a2
2014-02-13 15:18:19 -08:00
Doug Zongker
168724c31a fix unnecessarily slow writing of EMMC partitions
These were attempts to write partitions "conservatively" in hopes of
fixing the problems with writing the radio partition on Nexus 4.  They
didn't work (a kernel patch was needed), but got left in.  They make
writing of partitions unnecessarily slow (ie, we really shouldn't need
to sync() after every 4kb).  Roll back most of them, but leave the
verification read-back in.

Change-Id: I94badc0979e88816c5aa0485f6316c02be69173c
2013-12-19 15:16:57 -08:00
Doug Zongker
51c84694b0 am a69b50c5: am 901b898d: recovery: remove O_DIRECT, use O_SYNC only
* commit 'a69b50c567d46afad73c4d6ab9e57f078ee73327':
  recovery: remove O_DIRECT, use O_SYNC only
2013-07-11 14:23:44 -07:00
Doug Zongker
bce44d8b55 am 660637f3: am e8d953aa: recovery: more cargo-cult programming
* commit '660637f3fc6fe20e8b7f47b98152138c2c92b7ec':
  recovery: more cargo-cult programming
2013-07-11 14:23:36 -07:00
Doug Zongker
901b898d5e recovery: remove O_DIRECT, use O_SYNC only
O_DIRECT writes fail with EINVAL due to alignment issues.

Change-Id: If8cf38a636313e4f4b4e61e66287dc903c473e5b
2013-07-11 12:31:25 -07:00
Doug Zongker
e8d953aa7e recovery: more cargo-cult programming
Add O_DIRECT|O_SYNC when opening partitions for write.

Change-Id: I9825ad8e60fba87e482f8abc5593d6f54a1e3a1c
2013-07-11 12:11:11 -07:00
Doug Zongker
65c37aa0d3 am fbcfad33: am bf4a69ac: recovery: sleep after writing partition and closing it
* commit 'fbcfad33face5d3b9e6b8cb04379168bceb517df':
  recovery: sleep after writing partition and closing it
2013-07-11 10:17:48 -07:00
Doug Zongker
5d0da12878 am 2148133d: am c870a99c: recovery: write partitions more conservatively
* commit '2148133d46cb875316b01947dd5719ed995f7d67':
  recovery: write partitions more conservatively
2013-07-11 10:08:23 -07:00
Doug Zongker
bf4a69ac41 recovery: sleep after writing partition and closing it
Another speculative attempt to get everything we write actually stored
to the device.

Change-Id: Icf40b0741b4c535e55ea34848073a97d90dc0e70
2013-07-10 13:46:46 -07:00
Doug Zongker
c870a99c4a recovery: write partitions more conservatively
Write and verify partitions using write(2) and read(2) rather than the
stdio functions.  Read and write in 4kb blocks.  When writing, fsync()
every 1MB.

Bug: 9602014
Change-Id: Ie98ce38e857786fc0f4ebf36bb5ffc93b41bc96f
2013-07-09 10:42:15 -07:00
Doug Zongker
602c4ebd39 am 0ccaccf7: am 044a0b4d: recovery: try to write EMMC partitions more reliably
* commit '0ccaccf7d0f50bb9555ee13a841c246a1fea80f2':
  recovery: try to write EMMC partitions more reliably
2013-07-08 14:14:24 -07:00
Doug Zongker
044a0b4d49 recovery: try to write EMMC partitions more reliably
Nexus 4 has flash errors that manifest during large writes (eg, of the
radio partition).  Writes of some blocks seem to be dropped silently,
without any errors being returned to the user level.

Make two changes to the partition-writing code:

- break it up into 1MB writes instead of writing partitions with a
  single fwrite() call.  Pause for 50ms in between every chunk.

- read the partition back after writing and verify that we read what
  we wrote.  Drop caches before reading so we (hopefully) are reading
  off the actual flash and not some cache.

Neither of these should be necessary.

Bug: 9602014

Change-Id: Ice2e24dd4c11f1a57968277b5eb1468c772f6f63
2013-07-08 12:59:22 -07:00
Doug Zongker
bac7fba027 verifier: update to support certificates using SHA-256
Change-Id: Ifd5a29d459acf101311fa1c220f728c3d0ac2e4e
2013-04-10 11:32:17 -07:00
Doug Zongker
bf80f49edc reduce some recovery logging
Make minzip log only a count of files when extracting, not individual
filenames.  Make patching only chatter about free space if there's not
enough and compact the other messages.

Only the last 8k of the recovery log gets uploaded; this makes it more
likely that we will get all of it.

Change-Id: I529cb4947fe2185df82b9da5fae450a7480dcecd
2012-10-19 12:24:26 -07:00
Doug Zongker
a3ccba6d31 add bonus data feature to imgdiff/imgpatch/applypatch
The bonus data option lets you give an additional blob of uncompressed
data to be used when constructing a patch for chunk #1 of an image.
The same blob must be available at patch time, and can be passed to
the command-line applypatch tool (this feature is not accessible from
edify scripts).

This will be used to reduce the size of recovery-from-boot patches by
storing parts of the recovery ramdisk (the UI images) on the system
partition.

Change-Id: Iac1959cdf7f5e4582f8d434e83456e483b64c02c
2012-08-20 15:28:02 -07:00
Nick Kralevich
956cde8578 Add mode when open(O_CREAT) is used.
When creating a new file using open(..., O_CREAT), it is an error
to fail to specify a creation mode. If a mode is not specified, a
random stack provided value is used as the "mode".

This will become a compile error in a future Android change.

Change-Id: I73c1e1a39ca36bf01704b07302af4971d234b5a8
2012-06-26 15:01:03 -07:00
Doug Zongker
b07b293944 fix build
Change-Id: I44a75f5451af053778be299b23274ecce9b2db76
2012-02-28 12:07:30 -08:00
Doug Zongker
1c43c9741b fix failure to free memory
The applypatch function is somewhat sloppy about freeing memory (since
it was originally a standalone binary).  Fix some of that.

Change-Id: Ifd44d71ea189c0b5115493119fd57bc37533fd59
2012-02-28 11:07:09 -08:00
Doug Zongker
baf6e35473 am c080bc54: am fbd7ae7a: am 201cd466: remove shadowed variable declaration
Merge commit 'c080bc549aaf272c77fe7903e52c2a2c0d8de1bb'

* commit 'c080bc549aaf272c77fe7903e52c2a2c0d8de1bb':
  remove shadowed variable declaration
2010-08-16 07:44:51 -07:00
Doug Zongker
201cd46680 remove shadowed variable declaration
An accidental variable declaration ("int enough_space = ..." instead
of "enough_space = " inside a block) shadowing the real one meant we
were always using the copy-to-cache path for patching, even when not
necessary.  Remove it.  Enforce an absolute minimum of free space as
well, to avoid running into problems patching small files, now that
the copy-to-cache path is (inadvertently) well-tested.

Change-Id: Idb7d57241a9adcda2e11001fa44f0cd67ce40d19
2010-08-13 09:41:21 -07:00
Doug Zongker
80dcee145f am c4e32005: am 17986e6b: am 8cd9e4f3: fix bug in applying patches
Merge commit 'c4e3200578ad670bee9f5a88e90e7a77089d5df7'

* commit 'c4e3200578ad670bee9f5a88e90e7a77089d5df7':
  fix bug in applying patches
2010-08-12 17:57:45 -07:00
Doug Zongker
8cd9e4f3d4 fix bug in applying patches
When restarting a patch from crashing in the middle of a large file,
we're not finding the correct patch to apply to the copy saved in
cache.

Change-Id: I41cb2b87d096bb7a28a10c4cf3902facd45d4c9d
2010-08-12 17:38:09 -07:00
Hristo Bojinov
db314d69f0 Working ASLR implementation
Separate files for retouch functionality are in minelf/*

ASLR for shared libraries is controlled by "-a" in ota_from_target_files.
Binary files are self-contained. Retouch logic can recover from crashes.

Signed-off-by: Hristo Bojinov <hristo@google.com>
Change-Id: I76c596abf4febd68c14f9d807ac62e8751e0b1bd
2010-08-02 14:17:33 -07:00
Doug Zongker
f291d858f8 EMMC support in applypatch
Let applypatch read and write EMMC partitions as well as MTD ones.
This enables incremental updates that include boot image changes, as
well as OTA of new recovery partitions.

Change-Id: I3766b9e77c639769ddf693b675da51d57f6e6b1d
2010-07-07 15:18:27 -07:00
Doug Zongker
c4351c7910 refactor applypatch and friends
Change the applypatch function to take meaningful arguments instead of
argc and argv.  Move all the parsing of arguments into main.c (for the
standalone binary) and into install.c (for the updater function).
applypatch() takes patches as Value objects, so we can pass in blobs
extracted from the package without ever writing them to temp files.

The patching code is changed to read the patch from memory instead of
a file.

A bunch of compiler warnings (mostly about signed vs unsigned types)
are fixed.

Support for the IMGDIFF1 format is dropped.  (We've been generating
IMGDIFF2 packages for some time now.)

Change-Id: I217563c500012750f27110db821928a06211323f
2010-02-22 15:30:33 -08:00
Doug Zongker
512536a54a relocate applypatch; add type system and new functions to edify
- Move applypatch to this package (from build).

- Add a rudimentary type system to edify:  instead of just returning a
  char*, functions now return a Value*, which is a struct that can
  carry different types of value (currently just STRING and BLOB).
  Convert all functions to this new scheme.

- Change the one-argument form of package_extract_file to return a
  Value of the new BLOB type.

- Add read_file() to load a local file and return a blob, and
  sha1_check() to test a blob (or string) against a set of possible
  sha1s.  read_file() uses the file-loading code from applypatch so it
  can read MTD partitions as well.

This is the start of better integration between applypatch and the
rest of edify.

b/2361316 - VZW Issue PP628: Continuous reset to Droid logo:
            framework-res.apk update failed (CR LIBtt59130)

Change-Id: Ibd038074749a4d515de1f115c498c6c589ee91e5
2010-02-18 14:22:12 -08:00