Discard the tail of the target partitions when updating.

The partition is normally way bigger than the data it holds and the
remainder of the partition is often ignored by the system. This patch
discards the tail of the partition, past the end of the updated data.

This would ensure that the unused blocks in these partitions can be
reallocated by the SSD controller to other blocks, and that data from
previous updates does not interfere with the current version.

Bug: 28744609
TEST=strace -e trace=file,ioctl shows the device discarding the end of the updated partitions.

Change-Id: Ie6135ee1aef2fa594c40d84af4d1d46a8f53cc3a
4 files changed
tree: e5670f2ebc62b08dac64e2e52c12bc6cd24c2406
  1. .gitignore
  2. Android.mk
  3. MODULE_LICENSE_APACHE2
  4. NOTICE
  5. OWNERS
  6. PRESUBMIT.cfg
  7. UpdateEngine.conf
  8. WATCHLISTS
  9. binder_bindings/
  10. binder_service_android.cc
  11. binder_service_android.h
  12. binder_service_brillo.cc
  13. binder_service_brillo.h
  14. boot_control_android.cc
  15. boot_control_android.h
  16. boot_control_chromeos.cc
  17. boot_control_chromeos.h
  18. boot_control_chromeos_unittest.cc
  19. chrome_browser_proxy_resolver.cc
  20. chrome_browser_proxy_resolver.h
  21. chrome_browser_proxy_resolver_unittest.cc
  22. client_library/
  23. common/
  24. common_service.cc
  25. common_service.h
  26. common_service_unittest.cc
  27. connection_manager.cc
  28. connection_manager.h
  29. connection_manager_interface.h
  30. connection_manager_unittest.cc
  31. daemon.cc
  32. daemon.h
  33. daemon_state_android.cc
  34. daemon_state_android.h
  35. daemon_state_interface.h
  36. dbus_bindings/
  37. dbus_service.cc
  38. dbus_service.h
  39. dbus_test_utils.h
  40. fake_file_writer.h
  41. fake_p2p_manager.h
  42. fake_p2p_manager_configuration.h
  43. fake_shill_proxy.cc
  44. fake_shill_proxy.h
  45. fake_system_state.cc
  46. fake_system_state.h
  47. generate_pc_file.sh
  48. hardware_android.cc
  49. hardware_android.h
  50. hardware_chromeos.cc
  51. hardware_chromeos.h
  52. hardware_chromeos_unittest.cc
  53. image_properties.h
  54. image_properties_android.cc
  55. image_properties_chromeos.cc
  56. image_properties_chromeos_unittest.cc
  57. include/
  58. init/
  59. libcros_proxy.cc
  60. libcros_proxy.h
  61. libupdate_engine-client-test.pc.in
  62. libupdate_engine-client.pc.in
  63. local_coverage_rate
  64. main.cc
  65. metrics.cc
  66. metrics.h
  67. metrics_utils.cc
  68. metrics_utils.h
  69. metrics_utils_unittest.cc
  70. mock_connection_manager.h
  71. mock_file_writer.h
  72. mock_omaha_request_params.h
  73. mock_p2p_manager.h
  74. mock_payload_state.h
  75. mock_proxy_resolver.h
  76. mock_update_attempter.h
  77. omaha_request_action.cc
  78. omaha_request_action.h
  79. omaha_request_action_unittest.cc
  80. omaha_request_params.cc
  81. omaha_request_params.h
  82. omaha_request_params_unittest.cc
  83. omaha_response.h
  84. omaha_response_handler_action.cc
  85. omaha_response_handler_action.h
  86. omaha_response_handler_action_unittest.cc
  87. omaha_utils.cc
  88. omaha_utils.h
  89. omaha_utils_unittest.cc
  90. p2p_manager.cc
  91. p2p_manager.h
  92. p2p_manager_unittest.cc
  93. parcelable_update_engine_status.cc
  94. parcelable_update_engine_status.h
  95. payload_consumer/
  96. payload_generator/
  97. payload_state.cc
  98. payload_state.h
  99. payload_state_interface.h
  100. payload_state_unittest.cc
  101. proxy_resolver.cc
  102. proxy_resolver.h
  103. real_system_state.cc
  104. real_system_state.h
  105. run_unittests
  106. sample_images/
  107. sample_omaha_v3_response.xml
  108. scripts/
  109. service_delegate_android_interface.h
  110. service_observer_interface.h
  111. shill_proxy.cc
  112. shill_proxy.h
  113. shill_proxy_interface.h
  114. system_state.h
  115. tar_bunzip2.gypi
  116. test_http_server.cc
  117. test_subprocess.cc
  118. testrunner.cc
  119. unittest_key.pem
  120. unittest_key2.pem
  121. update_attempter.cc
  122. update_attempter.h
  123. update_attempter_android.cc
  124. update_attempter_android.h
  125. update_attempter_unittest.cc
  126. update_engine-client.gyp
  127. update_engine.conf
  128. update_engine.gyp
  129. update_engine.rc
  130. update_engine_client.cc
  131. update_engine_client_android.cc
  132. update_manager/
  133. update_metadata.proto
  134. update_payload_key/
  135. update_status_utils.cc
  136. update_status_utils.h
  137. weave_service.cc
  138. weave_service.h
  139. weave_service_factory.cc
  140. weave_service_factory.h
  141. weave_service_interface.h
  142. weaved/