-
Notifications
You must be signed in to change notification settings - Fork 55
Fix bugs and improve error handling in emerg-shutdown #359
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -84,7 +84,6 @@ | |
| #include <fcntl.h> | ||
| #include <stdlib.h> | ||
| #include <stdint.h> | ||
| #include <stdbool.h> | ||
| #include <poll.h> | ||
| #include <linux/input.h> | ||
| #include <linux/vt.h> | ||
|
|
@@ -110,7 +109,7 @@ | |
|
|
||
| #define max_sig_num 31 | ||
|
|
||
| int console_fd = 0; | ||
| int console_fd = -1; | ||
|
Comment on lines
-113
to
+112
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Accepted. (Doesn't actually do anything but this is probably a more reasonable default.) |
||
|
|
||
| /* Adapted from kloak/src/keycodes.c */ | ||
| struct name_value { | ||
|
|
@@ -277,7 +276,7 @@ bool bitset_get(const uint64_t *bits, uint32_t i) { | |
| } | ||
|
|
||
| void print(int fd, const char *str) { | ||
| size_t len = strlen(str) + 1; | ||
| size_t len = strlen(str); | ||
|
Comment on lines
-280
to
+279
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Already applied from an earlier PR. |
||
| while (true) { | ||
| ssize_t write_len = write(fd, str, len); | ||
| if (write_len < 0) { | ||
|
|
@@ -384,6 +383,7 @@ void load_list(const char *arg, size_t *result_list_len_ref, char ***result_list | |
|
|
||
| arg_part = strtok(arg_val, sep); | ||
| if (arg_part == NULL) { | ||
| free(arg_copy); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Accepted. |
||
| return; | ||
| } | ||
|
|
||
|
|
@@ -392,7 +392,7 @@ void load_list(const char *arg, size_t *result_list_len_ref, char ***result_list | |
| result_list = safe_reallocarray(result_list, result_list_len, sizeof(char *)); | ||
| result_list[result_list_len - 1] = safe_calloc(1, strlen(arg_part) + 1); | ||
| strcpy(result_list[result_list_len - 1], arg_part); | ||
| } while ((arg_part = strtok(NULL, ",")) != NULL); | ||
| } while ((arg_part = strtok(NULL, sep)) != NULL); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Already applied from an earlier PR. |
||
|
|
||
| *result_list_len_ref = result_list_len; | ||
| *result_list_ref = result_list; | ||
|
|
@@ -691,13 +691,15 @@ void hw_monitor(int argc, char **argv) { | |
| } | ||
|
|
||
| for (pkl_idx = 0; pkl_idx < panic_key_list_len; pkl_idx++) { | ||
| bool group_supported = false; | ||
| for (kg_idx = 0; panic_key_list[pkl_idx][kg_idx] != 0; kg_idx++) { | ||
| if (!bitset_get(key_flags, panic_key_list[pkl_idx][kg_idx])) { | ||
| supports_panic = false; | ||
| if (bitset_get(key_flags, panic_key_list[pkl_idx][kg_idx])) { | ||
| group_supported = true; | ||
| break; | ||
| } | ||
| } | ||
| if (!supports_panic) { | ||
| if (!group_supported) { | ||
| supports_panic = false; | ||
|
Comment on lines
+694
to
+702
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Accepted. |
||
| break; | ||
| } | ||
| } | ||
|
|
@@ -895,6 +897,7 @@ void hw_monitor(int argc, char **argv) { | |
| if (paranoid_mode) { | ||
| /* Something was removed, we don't care what, shut down now */ | ||
| kill_system(); | ||
| exit(0); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| } | ||
|
|
||
| for (tdl_idx = 0; tdl_idx < target_dev_list_len; tdl_idx++) { | ||
|
|
@@ -952,6 +955,11 @@ void fifo_monitor(char **argv) { | |
| arg_part = strtok(arg_copy, "="); | ||
| /* returns everything after the = sign */ | ||
| arg_part = strtok(NULL, ""); | ||
| if (arg_part == NULL) { | ||
| print(fd_stderr, "Timeout value is empty!\n"); | ||
| print_usage(); | ||
| exit(1); | ||
| } | ||
|
Comment on lines
+958
to
+962
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Already accepted from an earlier PR. |
||
| errno = 0; | ||
| monitor_fifo_timeout = strtol(arg_part, &arg_num_end, 10); | ||
| if (errno == ERANGE || monitor_fifo_timeout > UINT_MAX) { | ||
|
|
@@ -1051,6 +1059,7 @@ int main(int argc, char **argv) { | |
| } | ||
|
|
||
| kill_system(); | ||
| exit(0); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| } | ||
| if (strcmp(argv[1], "--monitor-fifo") == 0) { | ||
| if (argc != 3) { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Accepted.