vold: asec path cmd now returns OpFailedStorageNotFound if id doesn't exist
Change-Id: Icbe3de7c28505f7496c8f8edea126c7b616de475
Signed-off-by: San Mehat <san@google.com>
diff --git a/CommandListener.cpp b/CommandListener.cpp
index a200007..781eb91 100644
--- a/CommandListener.cpp
+++ b/CommandListener.cpp
@@ -378,12 +378,10 @@
}
char path[255];
- if (vm->getAsecMountPath(argv[2], path, sizeof(path))) {
- cli->sendMsg(ResponseCode::OperationFailed, "Failed to get path", true);
- } else {
+ if (!(rc = vm->getAsecMountPath(argv[2], path, sizeof(path)))) {
cli->sendMsg(ResponseCode::AsecPathResult, path, false);
+ return 0;
}
- return 0;
} else {
dumpArgs(argc, argv, -1);
cli->sendMsg(ResponseCode::CommandSyntaxError, "Unknown asec cmd", false);
diff --git a/ResponseCode.cpp b/ResponseCode.cpp
index d0410b6..cb9f98c 100644
--- a/ResponseCode.cpp
+++ b/ResponseCode.cpp
@@ -33,6 +33,8 @@
return(ResponseCode::OpFailedMediaCorrupt);
} else if (errno == EBUSY) {
return(ResponseCode::OpFailedStorageBusy);
+ } else if (errno == ENOENT) {
+ return(ResponseCode::OpFailedStorageNotFound);
}
LOGW("Returning OperationFailed - no handler for errno %d", errno);
diff --git a/ResponseCode.h b/ResponseCode.h
index 5e15c80..a858b99 100644
--- a/ResponseCode.h
+++ b/ResponseCode.h
@@ -42,6 +42,7 @@
static const int OpFailedMediaCorrupt = 403;
static const int OpFailedVolNotMounted = 404;
static const int OpFailedStorageBusy = 405;
+ static const int OpFailedStorageNotFound = 406;
// 500 series - The command was not accepted and the requested
// action did not take place.
diff --git a/VolumeManager.cpp b/VolumeManager.cpp
index 7a44e2e..c72482e 100644
--- a/VolumeManager.cpp
+++ b/VolumeManager.cpp
@@ -195,6 +195,14 @@
}
int VolumeManager::getAsecMountPath(const char *id, char *buffer, int maxlen) {
+ char asecFileName[255];
+ snprintf(asecFileName, sizeof(asecFileName), "%s/%s.asec", Volume::SEC_ASECDIR, id);
+
+ memset(buffer, 0, maxlen);
+ if (access(asecFileName, F_OK)) {
+ errno = ENOENT;
+ return -1;
+ }
snprintf(buffer, maxlen, "%s/%s", Volume::ASECDIR, id);
return 0;