diff options
Diffstat (limited to 'trusty/storage')
-rw-r--r-- | trusty/storage/interface/include/trusty/interface/storage.h | 4 | ||||
-rw-r--r-- | trusty/storage/proxy/Android.bp | 2 | ||||
-rw-r--r-- | trusty/storage/proxy/proxy.c | 9 | ||||
-rw-r--r-- | trusty/storage/proxy/storage.c | 35 |
4 files changed, 45 insertions, 5 deletions
diff --git a/trusty/storage/interface/include/trusty/interface/storage.h b/trusty/storage/interface/include/trusty/interface/storage.h index 3f1dcb8c6..255ade127 100644 --- a/trusty/storage/interface/include/trusty/interface/storage.h +++ b/trusty/storage/interface/include/trusty/interface/storage.h @@ -70,6 +70,9 @@ enum storage_cmd { * @STORAGE_ERR_TRANSACT returned by various operations to indicate that current transaction * is in error state. Such state could be only cleared by sending * STORAGE_END_TRANSACTION message. + * @STORAGE_ERR_SYNC_FAILURE indicates that the current operation failed to sync + * to disk. Only returned if STORAGE_MSG_FLAG_PRE_COMMIT or + * STORAGE_MSG_FLAG_POST_COMMIT was set for the request. */ enum storage_err { STORAGE_NO_ERROR = 0, @@ -80,6 +83,7 @@ enum storage_err { STORAGE_ERR_NOT_FOUND = 5, STORAGE_ERR_EXIST = 6, STORAGE_ERR_TRANSACT = 7, + STORAGE_ERR_SYNC_FAILURE = 8, }; /** diff --git a/trusty/storage/proxy/Android.bp b/trusty/storage/proxy/Android.bp index 94f26d8a6..e952ee0bc 100644 --- a/trusty/storage/proxy/Android.bp +++ b/trusty/storage/proxy/Android.bp @@ -32,11 +32,11 @@ cc_binary { shared_libs: [ "libbase", + "libcutils", "liblog", "libhardware_legacy", ], header_libs: [ - "libcutils_headers", "libgsi_headers", ], diff --git a/trusty/storage/proxy/proxy.c b/trusty/storage/proxy/proxy.c index 262003427..f01589287 100644 --- a/trusty/storage/proxy/proxy.c +++ b/trusty/storage/proxy/proxy.c @@ -116,10 +116,11 @@ static int drop_privs(void) { static int handle_req(struct storage_msg* msg, const void* req, size_t req_len) { int rc; - if ((msg->flags & STORAGE_MSG_FLAG_POST_COMMIT) && (msg->cmd != STORAGE_RPMB_SEND)) { + if ((msg->flags & STORAGE_MSG_FLAG_POST_COMMIT) && msg->cmd != STORAGE_RPMB_SEND && + msg->cmd != STORAGE_FILE_WRITE) { /* - * handling post commit messages on non rpmb commands are not - * implemented as there is no use case for this yet. + * handling post commit messages on commands other than rpmb and write + * operations are not implemented as there is no use case for this yet. */ ALOGE("cmd 0x%x: post commit option is not implemented\n", msg->cmd); msg->result = STORAGE_ERR_UNIMPLEMENTED; @@ -129,7 +130,7 @@ static int handle_req(struct storage_msg* msg, const void* req, size_t req_len) if (msg->flags & STORAGE_MSG_FLAG_PRE_COMMIT) { rc = storage_sync_checkpoint(); if (rc < 0) { - msg->result = STORAGE_ERR_GENERIC; + msg->result = STORAGE_ERR_SYNC_FAILURE; return ipc_respond(msg, NULL, 0); } } diff --git a/trusty/storage/proxy/storage.c b/trusty/storage/proxy/storage.c index c00c399d9..033dc2117 100644 --- a/trusty/storage/proxy/storage.c +++ b/trusty/storage/proxy/storage.c @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +#include <cutils/properties.h> #include <errno.h> #include <fcntl.h> #include <inttypes.h> @@ -43,6 +44,22 @@ enum sync_state { static const char *ssdir_name; +/* + * Property set to 1 after we have opened a file under ssdir_name. The backing + * files for both TD and TDP are currently located under /data/vendor/ss and can + * only be opened once userdata is mounted. This storageproxyd service is + * restarted when userdata is available, which causes the Trusty storage service + * to reconnect and attempt to open the backing files for TD and TDP. Once we + * set this property, other users can expect that the Trusty storage service + * ports will be available (although they may block if still being initialized), + * and connections will not be reset after this point (assuming the + * storageproxyd service stays running). + */ +#define FS_READY_PROPERTY "ro.vendor.trusty.storage.fs_ready" + +/* has FS_READY_PROPERTY been set? */ +static bool fs_ready_initialized = false; + static enum sync_state fs_state; static enum sync_state fd_state[FD_TBL_SIZE]; @@ -336,6 +353,16 @@ int storage_file_open(struct storage_msg* msg, const void* r, size_t req_len) { ALOGV("%s: \"%s\": fd = %u: handle = %d\n", __func__, path, rc, resp.handle); + /* a backing file has been opened, notify any waiting init steps */ + if (!fs_ready_initialized) { + rc = property_set(FS_READY_PROPERTY, "1"); + if (rc == 0) { + fs_ready_initialized = true; + } else { + ALOGE("Could not set property %s, rc: %d\n", FS_READY_PROPERTY, rc); + } + } + return ipc_respond(msg, &resp, sizeof(resp)); err_response: @@ -407,6 +434,14 @@ int storage_file_write(struct storage_msg *msg, goto err_response; } + if (msg->flags & STORAGE_MSG_FLAG_POST_COMMIT) { + rc = storage_sync_checkpoint(); + if (rc < 0) { + msg->result = STORAGE_ERR_SYNC_FAILURE; + goto err_response; + } + } + msg->result = STORAGE_NO_ERROR; err_response: |