sleep-config.c revision 442e00839e4fc3c11506f5c8a9477b465865aecc
/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
/***
This file is part of systemd.
Copyright 2013 Zbigniew Jędrzejewski-Szmek
under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 2.1 of the License, or
(at your option) any later version.
systemd is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with systemd; If not, see <http://www.gnu.org/licenses/>.
***/
#include <stdio.h>
#include "conf-parser.h"
#include "sleep-config.h"
#include "fileio.h"
#include "log.h"
#include "strv.h"
#include "util.h"
_cleanup_strv_free_ char
const ConfigTableItem items[] = {
{}};
int r;
FILE _cleanup_fclose_ *f;
if (!f)
else {
if (r < 0)
}
/* empty by default */
*modes = suspend_mode;
if (suspend_state)
*states = suspend_state;
else
if (hibernate_mode)
*modes = hibernate_mode;
else
if (hibernate_state)
else
if (hybrid_mode)
*modes = hybrid_mode;
else
if (hybrid_state)
*states = hybrid_state;
else
} else
assert_not_reached("what verb");
return log_oom();
}
return 0;
}
int can_sleep_state(char **types) {
int r;
_cleanup_free_ char *p = NULL;
if (strv_isempty(types))
return true;
/* If /sys is read-only we cannot sleep */
return false;
r = read_one_line_file("/sys/power/state", &p);
if (r < 0)
return false;
size_t l, k;
return true;
}
return false;
}
int can_sleep_disk(char **types) {
int r;
_cleanup_free_ char *p = NULL;
if (strv_isempty(types))
return true;
/* If /sys is read-only we cannot sleep */
return false;
r = read_one_line_file("/sys/power/disk", &p);
if (r < 0)
return false;
size_t l, k;
return true;
return true;
}
}
return false;
}
#define HIBERNATION_SWAP_THRESHOLD 0.98
static bool enough_memory_for_hibernation(void) {
int r;
if (r < 0) {
return false;
}
if (r < 0) {
return false;
}
if (r < 0) {
return false;
}
if (r < 0) {
return false;
}
log_debug("Hibernation is %spossible, Active(anon)=%llu kB, SwapFree=%llu kB, threshold=%.2g%%",
return r;
}
int r;
if (r < 0)
return false;
return false;
}