summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStephen Crane <cranes@google.com>2021-08-18 15:10:14 -0700
committerJaegeuk Kim <jaegeuk@google.com>2021-10-05 09:54:58 -0700
commit4ee811ee46d451d1f408d9aebecb7b254a2bcbf1 (patch)
tree53539e1d6566c0d0533eabf6af039dbcb9ed6046
parent1a9cad816de296b3f5ee026869cab4413ec7527c (diff)
downloadcore-4ee811ee46d451d1f408d9aebecb7b254a2bcbf1.tar.gz
storageproxyd: Add file handle param to debug buffer print
Adds a file handle parameter to the debug print_buf function to allow printing to either stdout or stderr. Test: m storageproxyd Bug: 195544379 Change-Id: Iade322a21312a676b3599bddafdfc43b599617ea Merged-In: Iade322a21312a676b3599bddafdfc43b599617ea (cherry picked from commit 3bb483b196678a9cae7237c9abad3e3c7ad3781f)
-rw-r--r--trusty/storage/proxy/rpmb.c19
1 files changed, 9 insertions, 10 deletions
diff --git a/trusty/storage/proxy/rpmb.c b/trusty/storage/proxy/rpmb.c
index b59fb67f6..094e5687f 100644
--- a/trusty/storage/proxy/rpmb.c
+++ b/trusty/storage/proxy/rpmb.c
@@ -105,17 +105,16 @@ static enum dev_type dev_type = UNKNOWN_RPMB;
static const char* UFS_WAKE_LOCK_NAME = "ufs_seq_wakelock";
#ifdef RPMB_DEBUG
-
-static void print_buf(const char* prefix, const uint8_t* buf, size_t size) {
+static void print_buf(FILE* handle, const char* prefix, const uint8_t* buf, size_t size) {
size_t i;
- printf("%s @%p [%zu]", prefix, buf, size);
+ fprintf(handle, "%s @%p [%zu]", prefix, buf, size);
for (i = 0; i < size; i++) {
- if (i && i % 32 == 0) printf("\n%*s", (int)strlen(prefix), "");
- printf(" %02x", buf[i]);
+ if (i && i % 32 == 0) fprintf(handle, "\n%*s", (int)strlen(prefix), "");
+ fprintf(handle, " %02x", buf[i]);
}
- printf("\n");
- fflush(stdout);
+ fprintf(handle, "\n");
+ fflush(handle);
}
#endif
@@ -153,7 +152,7 @@ static int send_mmc_rpmb_req(int mmc_fd, const struct storage_rpmb_send_req* req
mmc_ioc_cmd_set_data((*cmd), write_buf);
#ifdef RPMB_DEBUG
ALOGI("opcode: 0x%x, write_flag: 0x%x\n", cmd->opcode, cmd->write_flag);
- print_buf("request: ", write_buf, req->reliable_write_size);
+ print_buf(stdout, "request: ", write_buf, req->reliable_write_size);
#endif
write_buf += req->reliable_write_size;
mmc.multi.num_of_cmds++;
@@ -169,7 +168,7 @@ static int send_mmc_rpmb_req(int mmc_fd, const struct storage_rpmb_send_req* req
mmc_ioc_cmd_set_data((*cmd), write_buf);
#ifdef RPMB_DEBUG
ALOGI("opcode: 0x%x, write_flag: 0x%x\n", cmd->opcode, cmd->write_flag);
- print_buf("request: ", write_buf, req->write_size);
+ print_buf(stdout, "request: ", write_buf, req->write_size);
#endif
write_buf += req->write_size;
mmc.multi.num_of_cmds++;
@@ -353,7 +352,7 @@ int rpmb_send(struct storage_msg* msg, const void* r, size_t req_len) {
goto err_response;
}
#ifdef RPMB_DEBUG
- if (req->read_size) print_buf("response: ", read_buf, req->read_size);
+ if (req->read_size) print_buf(stdout, "response: ", read_buf, req->read_size);
#endif
if (msg->flags & STORAGE_MSG_FLAG_POST_COMMIT) {