From: Theodore Ts'o <tytso@mit.edu>
To: Ext4 Developers List <linux-ext4@vger.kernel.org>
Cc: Theodore Ts'o <tytso@mit.edu>
Subject: [PATCH] e2fsck: check new sysfs interface to determine if we are on battery
Date: Mon, 20 Feb 2012 19:11:43 -0500 [thread overview]
Message-ID: <1329783103-4017-1-git-send-email-tytso@mit.edu> (raw)
...since the old way is deprecated.
Addresses-SourceForge-Bug: #3439277
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
---
e2fsck/unix.c | 8 ++++++++
1 files changed, 8 insertions(+), 0 deletions(-)
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.7.9.107.g97f9a
next reply other threads:[~2012-02-21 0:11 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-02-21 0:11 Theodore Ts'o [this message]
2012-02-21 0:17 ` [PATCH] e2fsck: check new sysfs interface to determine if we are on battery Eric Sandeen
2012-02-21 1:24 ` Ted Ts'o
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1329783103-4017-1-git-send-email-tytso@mit.edu \
--to=tytso@mit.edu \
--cc=linux-ext4@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).