anitazha / rpms / systemd

Forked from rpms/systemd 3 years ago
Clone

Blame SOURCES/0042-shared-util-assume-ac-when-sys-class-power_supply-is.patch

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