Loading trusty/storage/proxy/ipc.c +1 −1 Original line number Diff line number Diff line Loading @@ -102,7 +102,7 @@ int ipc_respond(struct storage_msg *msg, void *out, size_t out_size) msg->cmd |= STORAGE_RESP_BIT; rc = writev(tipc_fd, iovs, out ? 2 : 1); rc = TEMP_FAILURE_RETRY(writev(tipc_fd, iovs, out ? 2 : 1)); if (rc < 0) { ALOGE("error sending response 0x%x: %s\n", msg->cmd, strerror(errno)); Loading trusty/storage/proxy/proxy.c +25 −4 Original line number Diff line number Diff line Loading @@ -15,6 +15,7 @@ */ #include <errno.h> #include <getopt.h> #include <signal.h> #include <stdbool.h> #include <stdint.h> #include <stdlib.h> Loading @@ -37,6 +38,8 @@ #define REQ_BUFFER_SIZE 4096 static uint8_t req_buffer[REQ_BUFFER_SIZE + 1]; static volatile sig_atomic_t terminate = false; static const char* ss_data_root; static const char* trusty_devname; static const char* rpmb_devname; Loading Loading @@ -120,6 +123,10 @@ static void show_usage_and_exit(int code) { exit(code); } static void handle_sigterm(int signum __attribute__((unused))) { terminate = true; } static int handle_req(struct storage_msg* msg, const void* req, size_t req_len) { int rc; Loading Loading @@ -218,10 +225,14 @@ static int proxy_loop(void) { struct storage_msg msg; /* enter main message handling loop */ while (true) { while (!terminate) { /* get incoming message */ rc = ipc_get_msg(&msg, req_buffer, REQ_BUFFER_SIZE); if (rc < 0) return rc; if (rc == EINTR && terminate) { return 0; } else if (rc < 0) { return rc; } /* handle request */ req_buffer[rc] = 0; /* force zero termination */ Loading Loading @@ -303,6 +314,12 @@ int main(int argc, char* argv[]) { */ umask(S_IRWXG | S_IRWXO); /* catch SIGTERM for graceful shutdown */ const struct sigaction sa = { .sa_handler = handle_sigterm, }; sigaction(SIGTERM, &sa, NULL); /* parse arguments */ parse_args(argc, argv); Loading Loading @@ -332,10 +349,14 @@ int main(int argc, char* argv[]) { /* enter main loop */ rc = proxy_loop(); if (terminate) { ALOGI("proxy loop terminated with status (%d)\n", rc); } else { ALOGE("exiting proxy loop with status (%d)\n", rc); } ipc_disconnect(); rpmb_close(); return (rc < 0) ? EXIT_FAILURE : EXIT_SUCCESS; _exit((rc < 0) ? EXIT_FAILURE : EXIT_SUCCESS); } Loading
trusty/storage/proxy/ipc.c +1 −1 Original line number Diff line number Diff line Loading @@ -102,7 +102,7 @@ int ipc_respond(struct storage_msg *msg, void *out, size_t out_size) msg->cmd |= STORAGE_RESP_BIT; rc = writev(tipc_fd, iovs, out ? 2 : 1); rc = TEMP_FAILURE_RETRY(writev(tipc_fd, iovs, out ? 2 : 1)); if (rc < 0) { ALOGE("error sending response 0x%x: %s\n", msg->cmd, strerror(errno)); Loading
trusty/storage/proxy/proxy.c +25 −4 Original line number Diff line number Diff line Loading @@ -15,6 +15,7 @@ */ #include <errno.h> #include <getopt.h> #include <signal.h> #include <stdbool.h> #include <stdint.h> #include <stdlib.h> Loading @@ -37,6 +38,8 @@ #define REQ_BUFFER_SIZE 4096 static uint8_t req_buffer[REQ_BUFFER_SIZE + 1]; static volatile sig_atomic_t terminate = false; static const char* ss_data_root; static const char* trusty_devname; static const char* rpmb_devname; Loading Loading @@ -120,6 +123,10 @@ static void show_usage_and_exit(int code) { exit(code); } static void handle_sigterm(int signum __attribute__((unused))) { terminate = true; } static int handle_req(struct storage_msg* msg, const void* req, size_t req_len) { int rc; Loading Loading @@ -218,10 +225,14 @@ static int proxy_loop(void) { struct storage_msg msg; /* enter main message handling loop */ while (true) { while (!terminate) { /* get incoming message */ rc = ipc_get_msg(&msg, req_buffer, REQ_BUFFER_SIZE); if (rc < 0) return rc; if (rc == EINTR && terminate) { return 0; } else if (rc < 0) { return rc; } /* handle request */ req_buffer[rc] = 0; /* force zero termination */ Loading Loading @@ -303,6 +314,12 @@ int main(int argc, char* argv[]) { */ umask(S_IRWXG | S_IRWXO); /* catch SIGTERM for graceful shutdown */ const struct sigaction sa = { .sa_handler = handle_sigterm, }; sigaction(SIGTERM, &sa, NULL); /* parse arguments */ parse_args(argc, argv); Loading Loading @@ -332,10 +349,14 @@ int main(int argc, char* argv[]) { /* enter main loop */ rc = proxy_loop(); if (terminate) { ALOGI("proxy loop terminated with status (%d)\n", rc); } else { ALOGE("exiting proxy loop with status (%d)\n", rc); } ipc_disconnect(); rpmb_close(); return (rc < 0) ? EXIT_FAILURE : EXIT_SUCCESS; _exit((rc < 0) ? EXIT_FAILURE : EXIT_SUCCESS); }