diff options
author | Weston Carvalho <westoncarvalho@google.com> | 2024-02-16 05:15:11 +0000 |
---|---|---|
committer | Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> | 2024-02-16 05:15:11 +0000 |
commit | 174c3347bfca3ccfdbc71db44d1933f18410c941 (patch) | |
tree | dfe55c6926c1c4ace5d4e2efe001c2016cc71ece | |
parent | b1e9bce9e26f56adbccd1ef99c6e6a13d3e344b9 (diff) | |
parent | 9d650493b4e391ca658bb69eea4ea3781a9d4b09 (diff) | |
download | storage-174c3347bfca3ccfdbc71db44d1933f18410c941.tar.gz |
Split storage_file_close am: 9d650493b4
Original change: https://android-review.googlesource.com/c/trusty/app/storage/+/2806240
Change-Id: I125f794f28800e94e9649cb86af5875de604cfb0
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
-rw-r--r-- | client_tipc.c | 40 |
1 files changed, 22 insertions, 18 deletions
diff --git a/client_tipc.c b/client_tipc.c index e214a08..2332fd7 100644 --- a/client_tipc.c +++ b/client_tipc.c @@ -554,34 +554,25 @@ done: } static enum storage_err storage_file_close( - struct storage_msg* msg, - struct storage_file_close_req* req, - size_t req_size, - struct storage_client_session* session) { + struct storage_client_session* session, + uint32_t handle, + struct storage_op_flags flags) { struct file_handle* file; - if (req_size < sizeof(*req)) { - SS_ERR("%s: invalid request size (%zu)\n", __func__, req_size); + file = get_file_handle(session, handle); + if (!file) { return STORAGE_ERR_NOT_VALID; } - file = get_file_handle(session, req->handle); - if (!file) - return STORAGE_ERR_NOT_VALID; - file_close(file); + free_file_handle(session, handle); - free_file_handle(session, req->handle); - - if (msg->flags & STORAGE_MSG_FLAG_TRANSACT_COMPLETE) { - transaction_complete_etc( - &session->tr, - msg->flags & STORAGE_MSG_FLAG_TRANSACT_CHECKPOINT); + if (flags.complete_transaction) { + transaction_complete_etc(&session->tr, flags.update_checkpoint); if (session->tr.failed) { SS_ERR("%s: transaction commit failed\n", __func__); return STORAGE_ERR_GENERIC; } - return STORAGE_NO_ERROR; } return STORAGE_NO_ERROR; @@ -1148,6 +1139,19 @@ static enum storage_err storage_tipc_file_move( extract_storage_op_flags(msg->flags)); } +static enum storage_err storage_tipc_file_close( + struct storage_client_session* session, + struct storage_msg* msg, + struct storage_file_close_req* req, + size_t req_size) { + if (req_size != sizeof(*req)) { + SS_ERR("%s: invalid request size (%zu)\n", __func__, req_size); + return STORAGE_ERR_NOT_VALID; + } + return storage_file_close(session, req->handle, + extract_storage_op_flags(msg->flags)); +} + static struct storage_tipc_client_session* chan_context_to_client_session( struct ipc_channel_context* ctx) { assert(ctx != NULL); @@ -1351,7 +1355,7 @@ static int client_handle_msg(struct ipc_channel_context* ctx, case STORAGE_FILE_OPEN: return storage_file_open(msg, payload, payload_len, tipc_session); case STORAGE_FILE_CLOSE: - result = storage_file_close(msg, payload, payload_len, session); + result = storage_tipc_file_close(session, msg, payload, payload_len); break; case STORAGE_FILE_WRITE: result = storage_file_write(msg, payload, payload_len, session); |