Use unique_fd
Also allow the state just before doMount() as a valid state for setting
fuse fd.
Test: manual
BUG:140173712
Change-Id: I012f8a83fef00e68f33010954fbc2ebc53cf8f1d
diff --git a/model/EmulatedVolume.cpp b/model/EmulatedVolume.cpp
index ca314ef..022ff42 100644
--- a/model/EmulatedVolume.cpp
+++ b/model/EmulatedVolume.cpp
@@ -88,13 +88,13 @@
if (isFuse) {
LOG(INFO) << "Mounting emulated fuse volume";
- int fd = -1;
+ android::base::unique_fd fd;
int result = MountUserFuse(getMountUserId(), label, &fd);
if (result != 0) {
PLOG(ERROR) << "Failed to mount emulated fuse volume";
return -result;
}
- setDeviceFd(fd);
+ setFuseFd(std::move(fd));
return OK;
}
@@ -170,7 +170,7 @@
}
rmdir(path.c_str());
- setDeviceFd(-1);
+ setFuseFd(android::base::unique_fd());
return OK;
}