In unix.c's is_on_batt() function /proc/apm and /proc/acpi/ac_adapter/*/state are checked for battery state. In newer kernels the /sys/class/power_supply/ tree has replaced these interfaces and supports more than just APM/ACPI batteries. e2fsprogs should be updated to read /sys/class/power_supply.
Hmm, as it turns out /proc/acpi is in the process of being deprecated, hence it is a really good idea to make use of /sys/class/power_supply.
Hmm, seems 2.6.36 began with removing /proc/acpi: http://kernelnewbies.org/Linux_2_6_36-DriversArch#head-bf6fc1898f64b5015f69044c727fcfa76aa8cb08 So, that basically means that this fsck feature doesn't work anymore on current kernels unless support for /sys/class/power/supply is added.
Yes, this should be fixed. I've always thought it's a little odd for filesystems to care about power sources, but this one does, so we'll need to look into fixing. Thanks, -Eric
$ ls /sys/class/power_supply/ $ Hrm. So, ah, what file under /sys/class/power_supply tells us if we're on battery or not?
You need to enumerate through all power supply devices with the "type" = "Mains" attribute, and check if any of them have the "online" attribute as "1". If so you have AC power. If don't find any power supply of "type" = "Mains" then you are on AC power too. Only if you have one or more power supplies of "type" = "Mains" and all of them have "online" = "0" then you are on battery. Yeah, sounds weird. In systemd we have this logic in this piece of code: http://cgit.freedesktop.org/systemd/tree/src/ac-power.c It links against libudev. However it is relatively trivial to implement this without libudev if you want to.
Ugh. Maybe we should just remove the code altogether ;)
tsss. but i think it actually is a useful feature. And much nicer than the crack the Debianites came up with (they just skipped fsck entirely when no AC power was on).
This bug appears to have been reported against 'rawhide' during the Fedora 19 development cycle. Changing version to '19'. (As we did not run this process for some time, it could affect also pre-Fedora 19 development cycle bugs. We are very sorry. It will help us with cleanup during Fedora 19 End Of Life. Thank you.) More information and reason for this action is here: https://fedoraproject.org/wiki/BugZappers/HouseKeeping/Fedora19
This message is a notice that Fedora 19 is now at end of life. Fedora has stopped maintaining and issuing updates for Fedora 19. It is Fedora's policy to close all bug reports from releases that are no longer maintained. Approximately 4 (four) weeks from now this bug will be closed as EOL if it remains open with a Fedora 'version' of '19'. Package Maintainer: If you wish for this bug to remain open because you plan to fix it in a currently maintained version, simply change the 'version' to a later Fedora version. Thank you for reporting this issue and we are sorry that we were not able to fix it before Fedora 19 is end of life. If you would still like to see this bug fixed and are able to reproduce it against a later version of Fedora, you are encouraged change the 'version' to a later Fedora version prior this bug is closed as described in the policy above. Although we aim to fix as many bugs as possible during every release's lifetime, sometimes those efforts are overtaken by events. Often a more recent Fedora release includes newer upstream software that fixes bugs or makes them obsolete.
Oh, hey, look at that: commit ad880a0e2bb1bef11382b4f38d440529e4cbdc2e Author: Theodore Ts'o <tytso> Date: Mon Feb 20 19:10:19 2012 -0500 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" <tytso> 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"); ...