if (k == 0)
return 0;
- log_debug("Failed to write '%s' to /sys/power/disk: %s",
- *mode, strerror(-k));
+ log_debug_errno(k, "Failed to write '%s' to /sys/power/disk: %m",
+ *mode);
if (r == 0)
r = k;
}
if (r < 0)
- log_error("Failed to write mode to /sys/power/disk: %s",
- strerror(-r));
+ log_error_errno(r, "Failed to write mode to /sys/power/disk: %m");
return r;
}
k = write_string_stream(*f, *state);
if (k == 0)
return 0;
- log_debug("Failed to write '%s' to /sys/power/state: %s",
- *state, strerror(-k));
+ log_debug_errno(k, "Failed to write '%s' to /sys/power/state: %m",
+ *state);
if (r == 0)
r = k;
fclose(*f);
*f = fopen("/sys/power/state", "we");
- if (!*f) {
- log_error("Failed to open /sys/power/state: %m");
- return -errno;
- }
+ if (!*f)
+ return log_error_errno(errno, "Failed to open /sys/power/state: %m");
}
return r;
}
static int execute(char **modes, char **states) {
- char* arguments[4];
+
+ char *arguments[] = {
+ NULL,
+ (char*) "pre",
+ arg_verb,
+ NULL
+ };
+
int r;
_cleanup_fclose_ FILE *f = NULL;
- const char* note = strappenda("SLEEP=", arg_verb);
/* This file is opened first, so that if we hit an error,
* we can abort before modifying any state. */
f = fopen("/sys/power/state", "we");
- if (!f) {
- log_error("Failed to open /sys/power/state: %m");
- return -errno;
- }
+ if (!f)
+ return log_error_errno(errno, "Failed to open /sys/power/state: %m");
/* Configure the hibernation mode */
r = write_mode(modes);
if (r < 0)
return r;
- arguments[0] = NULL;
- arguments[1] = (char*) "pre";
- arguments[2] = arg_verb;
- arguments[3] = NULL;
execute_directory(SYSTEM_SLEEP_PATH, NULL, DEFAULT_TIMEOUT_USEC, arguments);
log_struct(LOG_INFO,
- MESSAGE_ID(SD_MESSAGE_SLEEP_START),
- "MESSAGE=Suspending system...",
- note,
+ LOG_MESSAGE_ID(SD_MESSAGE_SLEEP_START),
+ LOG_MESSAGE("Suspending system..."),
+ "SLEEP=%s", arg_verb,
NULL);
r = write_state(&f, states);
return r;
log_struct(LOG_INFO,
- MESSAGE_ID(SD_MESSAGE_SLEEP_STOP),
- "MESSAGE=System resumed.",
- note,
+ LOG_MESSAGE_ID(SD_MESSAGE_SLEEP_STOP),
+ LOG_MESSAGE("System resumed."),
+ "SLEEP=%s", arg_verb,
NULL);
arguments[1] = (char*) "post";