From ad880a0e2bb1bef11382b4f38d440529e4cbdc2e Mon Sep 17 00:00:00 2001 From: Theodore Ts'o Date: Mon, 20 Feb 2012 19:10:19 -0500 Subject: [PATCH] e2fsck: check new sysfs interface to determine if we are on battery ...since the old way is deprecated. Addresses-SourceForge-Bug: #3439277 Signed-off-by: "Theodore Ts'o" --- e2fsck/unix.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/e2fsck/unix.c b/e2fsck/unix.c index c38b67a..6f97b0f 100644 --- a/e2fsck/unix.c +++ b/e2fsck/unix.c @@ -252,6 +252,14 @@ static int is_on_batt(void) unsigned int acflag; struct dirent* de; + f = fopen("/sys/class/power_supply/AC/online", "r"); + if (f) { + if (fscanf(f, "%d\n", &acflag) == 1) { + fclose(f); + return (!acflag); + } + fclose(f); + } f = fopen("/proc/apm", "r"); if (f) { if (fscanf(f, "%s %s %s %x", tmp, tmp, tmp, &acflag) != 4) -- 1.8.3.1