namespace {
const std::string MOUNT = "mount";
+const std::string UMOUNT = "umount";
const std::string REMOVE = "remove";
void usage()
"Usage: ode-fota [Operation]" << std::endl <<
std::endl <<
"Operations :" << std::endl <<
- " mount [path] Mount internal memory using stored master key" << std::endl <<
- " remove Remove stored internal memory master key" << std::endl;
+ " mount [path] Mount internal memory using stored master key" << std::endl <<
+ " umount [path] Unmount internal memory" << std::endl <<
+ " remove Remove stored internal memory master key" << std::endl;
}
} // anonymous namespace
// mount options are ignored by mount()
dmcrypt.mount(masterKey, 0);
+ } else if (UMOUNT == argv[1]) {
+ std::string path = INTERNAL_PATH;
+ if (argc == 3)
+ path = argv[2];
+
+ DMCryptEngine dmcrypt(devpath, path, ProgressBar([](int){}));
+ dmcrypt.umount();
} else if (REMOVE == argv[1]) {
UpgradeSupport::removeMasterKey(devpath);
} else {
// Create Device (mount_name)
initDMIoctl(dmBuf, DM_MAX_BUFFER_SIZE, mountName, 0);
- if (ioctl(fd, DM_DEV_CREATE, dmBuf)) {
+ if (ioctl(fd, DM_DEV_CREATE, dmBuf) && errno != EBUSY) {
close(fd);
throw runtime::Exception("Cannot create dm-crypt device");
}
void DMCryptEngine::umount()
{
+ //TODO umount("/opt/usr/"apps") will be removed
if (::umount("/opt/usr/apps") && errno != EINVAL)
- throw runtime::Exception(runtime::GetSystemErrorMessage());
+ ERROR(SINK, runtime::GetSystemErrorMessage());
if (::umount(destination.c_str()) && errno != EINVAL)
throw runtime::Exception(runtime::GetSystemErrorMessage());