]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
backlight: handle loading truncated file
authorTopi Miettinen <toiwoton@gmail.com>
Thu, 31 Jan 2019 17:07:06 +0000 (19:07 +0200)
committerTopi Miettinen <toiwoton@gmail.com>
Sat, 2 Feb 2019 14:25:32 +0000 (16:25 +0200)
I had accidentally filled my /var partition. This caused backlight to fail to
start even with disk space, because the brightness files were truncated to zero
size:

systemd-backlight[624]: acpi_video0: Failed to parse brightness "": Invalid argument
systemd-backlight[624]: acpi_video0: Failed to write system 'brightness' attribute: No such device or address
systemd[1]: systemd-backlight@backlight:acpi_video0.service: Main process exited, code=exited, status=1/FAILURE
systemd[1]: systemd-backlight@backlight:acpi_video0.service: Failed with result 'exit-code'.
systemd[1]: Failed to start Load/Save Screen Backlight Brightness of backlight:acpi_video0.

Handle a truncated file like non-existent file.

src/backlight/backlight.c

index 780ad56eb1daa3e988b83525b6573468e8b3746a..2fcc693c48f6ad585eb2c0c9d4005542e9f2767a 100644 (file)
@@ -379,7 +379,7 @@ static int run(int argc, char *argv[]) {
                 clamp = shall_clamp(device);
 
                 r = read_one_line_file(saved, &value);
-                if (r == -ENOENT) {
+                if (IN_SET(r, -ENOENT, 0)) {
                         const char *curval;
 
                         /* Fallback to clamping current brightness or exit early if