Unmount old postinstall mountpoint from previous runs.

When update_engine crashes, is killed or a developer runs
"stop update_engine" while we are waiting for postinstall to finish
the other partition will continue to be mounted (read-only) on the
/postinsall path. This will prevent to mount the new postinstall
step on top of it due to different SELinux labels when mounted and
unmounted. After failing to run postinstall due to the failed mount
operation we would cleanup the mountpoint, so this situation fixes
itself after one failed update attempt, which can then be resumed
from the very end.

This patch attempts to unmount /postinstall if a filesystem is mounted
there at the time we need to use the mountpoint.

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