From c4cd1d4d93e4a45a088edb6517555aa7e06e5f86 Mon Sep 17 00:00:00 2001 From: Aaro Koskinen Date: Wed, 30 Sep 2015 15:57:55 +0300 Subject: fileio: make get_status_field() more generic All users of get_status_field() expect the field pattern to occur in the beginning of a line, and the delimiter is ':'. Hardcode this into the function, and also skip any whitespace before ':' to support fields in files like /proc/cpuinfo. Add support for returning the full field value (currently stops on first whitespace). Rename the function so it's easier to ensure all callers switch to new semantics. --- src/shared/sleep-config.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/shared/sleep-config.c') diff --git a/src/shared/sleep-config.c b/src/shared/sleep-config.c index 1064fd5cbd..3dedbd1f62 100644 --- a/src/shared/sleep-config.c +++ b/src/shared/sleep-config.c @@ -226,7 +226,7 @@ static bool enough_memory_for_hibernation(void) { if (r < 0) return false; - r = get_status_field("/proc/meminfo", "\nActive(anon):", &active); + r = get_proc_field("/proc/meminfo", "Active(anon)", WHITESPACE, &active); if (r < 0) { log_error_errno(r, "Failed to retrieve Active(anon) from /proc/meminfo: %m"); return false; -- cgit v1.2.3-54-g00ecf