ryantimwilson / rpms / systemd

Forked from rpms/systemd 2 months ago
Clone
1ff636
From a2911c593e9d69a2aa01d89d876e313f90e7db17 Mon Sep 17 00:00:00 2001
1ff636
From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= <zbyszek@in.waw.pl>
1ff636
Date: Tue, 3 Mar 2015 19:07:28 -0500
1ff636
Subject: [PATCH] shared/util: assume ac when /sys/class/power_supply is
1ff636
 missing
1ff636
1ff636
On s390 (at least) /sys/class/power_supply is not present. We should
1ff636
treat this like if this directory was empty, and not an error.
1ff636
1ff636
(cherry picked from commit 6d89003462484c8656b698e07b9cf0a337e3818e)
1ff636
---
1ff636
 src/shared/util.c | 2 +-
1ff636
 1 file changed, 1 insertion(+), 1 deletion(-)
1ff636
1ff636
diff --git a/src/shared/util.c b/src/shared/util.c
c62b8e
index f24b5b4ec5..85487230a2 100644
1ff636
--- a/src/shared/util.c
1ff636
+++ b/src/shared/util.c
1ff636
@@ -5994,7 +5994,7 @@ int on_ac_power(void) {
1ff636
 
1ff636
         d = opendir("/sys/class/power_supply");
1ff636
         if (!d)
1ff636
-                return -errno;
1ff636
+                return errno == ENOENT ? true : -errno;
1ff636
 
1ff636
         for (;;) {
1ff636
                 struct dirent *de;