Don't write artifacts under staging
The staging dir (.../com.android.art/staging) is where odrefresh
creates artifacts before moving (well, copying) them to the final
target directory, typically .../com.android.art/dalvik-cache, or
compos-pending in our case).
But we were creating directories .../com.android.art/staging/staging
and .../com.android.art/staging/dalvik-cache instead.
So we need to pass the staging dir and the output dir separately, and
also specify the sub-directory name under the output directory where
the final artifacts should end up.
While I'm modifying the signature of odrefresh() I also made it return
just the odrefresh exit code.
Modified the implementation and callers to handle the new signature.
Also made a couple of small fixes.
Bug: 209572296
Bug: 210460516
Test: composd_cmd forced-odrefresh
Test: composd_cmd async-odrefresh
Test: (both with selinux in microdroid disabled)
Change-Id: I3dcdab7d9ae042e46f73d716f81f834de0f4c4f0
diff --git a/compos/src/compsvc.rs b/compos/src/compsvc.rs
index 19f2f47..4540cd8 100644
--- a/compos/src/compsvc.rs
+++ b/compos/src/compsvc.rs
@@ -106,9 +106,11 @@
&self,
system_dir_fd: i32,
output_dir_fd: i32,
+ staging_dir_fd: i32,
+ target_dir_name: &str,
zygote_arch: &str,
- ) -> BinderResult<CompilationResult> {
- if system_dir_fd < 0 || output_dir_fd < 0 {
+ ) -> BinderResult<i8> {
+ if system_dir_fd < 0 || output_dir_fd < 0 || staging_dir_fd < 0 {
return Err(new_binder_exception(
ExceptionCode::ILLEGAL_ARGUMENT,
"The remote FDs are expected to be non-negative",
@@ -122,10 +124,12 @@
}
let authfs_service = get_authfs_service()?;
- let output = odrefresh(
+ odrefresh(
&self.odrefresh_path,
+ target_dir_name,
system_dir_fd,
output_dir_fd,
+ staging_dir_fd,
zygote_arch,
authfs_service,
)
@@ -135,13 +139,7 @@
ExceptionCode::SERVICE_SPECIFIC,
format!("odrefresh failed: {}", e),
)
- })?;
- match output {
- CompilerOutput::ExitCode(exit_code) => {
- Ok(CompilationResult { exitCode: exit_code, ..Default::default() })
- }
- _ => Err(new_binder_exception(ExceptionCode::SERVICE_SPECIFIC, "odrefresh failed")),
- }
+ })
}
fn compile_cmd(