teknoraver / rpms / systemd

Forked from rpms/systemd 3 months ago
Clone
Blob Blame History Raw
From a2911c593e9d69a2aa01d89d876e313f90e7db17 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= <zbyszek@in.waw.pl>
Date: Tue, 3 Mar 2015 19:07:28 -0500
Subject: [PATCH] shared/util: assume ac when /sys/class/power_supply is
 missing

On s390 (at least) /sys/class/power_supply is not present. We should
treat this like if this directory was empty, and not an error.

(cherry picked from commit 6d89003462484c8656b698e07b9cf0a337e3818e)
---
 src/shared/util.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/shared/util.c b/src/shared/util.c
index f24b5b4..8548723 100644
--- a/src/shared/util.c
+++ b/src/shared/util.c
@@ -5994,7 +5994,7 @@ int on_ac_power(void) {
 
         d = opendir("/sys/class/power_supply");
         if (!d)
-                return -errno;
+                return errno == ENOENT ? true : -errno;
 
         for (;;) {
                 struct dirent *de;