And move it to sperate function.
s -= 16;
}
}
+
+int update_reboot_param_file(const char *param)
+{
+ int r = 0;
+
+ if (param) {
+
+ r = write_string_file(REBOOT_PARAM_FILE, param);
+ if (r < 0)
+ log_error("Failed to write reboot param to "
+ REBOOT_PARAM_FILE": %s", strerror(-r));
+ } else
+ unlink(REBOOT_PARAM_FILE);
+
+ return r;
+}
void hexdump(FILE *f, const void *p, size_t s);
union file_handle_union {
- struct file_handle handle;
- char padding[sizeof(struct file_handle) + MAX_HANDLE_SZ];
+ struct file_handle handle;
+ char padding[sizeof(struct file_handle) + MAX_HANDLE_SZ];
};
+
+int update_reboot_param_file(const char *param);
}
}
- if (arg_action == ACTION_REBOOT && argc == optind + 1) {
- r = write_string_file(REBOOT_PARAM_FILE, argv[optind]);
- if (r < 0) {
- log_error("Failed to write reboot param to "
- REBOOT_PARAM_FILE": %s", strerror(-r));
+ if (arg_action == ACTION_REBOOT && (argc == optind || argc == optind + 1)) {
+ r = update_reboot_param_file(argc == optind + 1 ? argv[optind] : NULL);
+ if (r < 0)
return r;
- }
} else if (optind < argc) {
log_error("Too many arguments.");
return -EINVAL;