]>
git.ipfire.org Git - thirdparty/systemd.git/blob - src/hibernate-resume/hibernate-resume.c
2 This file is part of systemd.
4 Copyright 2014 Ivan Shapovalov
6 systemd is free software; you can redistribute it and/or modify it
7 under the terms of the GNU Lesser General Public License as published by
8 the Free Software Foundation; either version 2.1 of the License, or
9 (at your option) any later version.
11 systemd is distributed in the hope that it will be useful, but
12 WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Lesser General Public License for more details.
16 You should have received a copy of the GNU Lesser General Public License
17 along with systemd; If not, see <http://www.gnu.org/licenses/>.
24 #include "alloc-util.h"
29 int main(int argc
, char *argv
[]) {
32 _cleanup_free_
char *major_minor
= NULL
;
36 log_error("This program expects one argument.");
40 log_set_target(LOG_TARGET_AUTO
);
41 log_parse_environment();
46 /* Refuse to run unless we are in an initrd() */
52 if (stat(device
, &st
) < 0) {
53 log_error_errno(errno
, "Failed to stat '%s': %m", device
);
57 if (!S_ISBLK(st
.st_mode
)) {
58 log_error("Resume device '%s' is not a block device.", device
);
62 if (asprintf(&major_minor
, "%d:%d", major(st
.st_rdev
), minor(st
.st_rdev
)) < 0) {
67 r
= write_string_file("/sys/power/resume", major_minor
, WRITE_STRING_FILE_CREATE
);
69 log_error_errno(r
, "Failed to write '%s' to /sys/power/resume: %m", major_minor
);
74 * The write above shall not return.
76 * However, failed resume is a normal condition (may mean that there is
77 * no hibernation image).
80 log_info("Could not resume from '%s' (%s).", device
, major_minor
);