chiark / gitweb /
backlight,random-seed: move state files into /var/lib/systemd
[elogind.git] / src / backlight / backlight.c
index 3378907..9b2eada 100644 (file)
@@ -42,7 +42,7 @@ int main(int argc, char *argv[]) {
 
         umask(0022);
 
-        r = mkdir_p("/var/lib/backlight", 0755);
+        r = mkdir_p("/var/lib/systemd/backlight", 0755);
         if (r < 0) {
                 log_error("Failed to create backlight directory: %s", strerror(-r));
                 goto finish;
@@ -54,9 +54,15 @@ int main(int argc, char *argv[]) {
                 goto finish;
         }
 
-        device = udev_device_new_from_syspath(udev, argv[2]);
+        errno = 0;
+        device = udev_device_new_from_subsystem_sysname(udev, "backlight", argv[2]);
         if (!device) {
-                r = log_oom();
+                if (errno != 0) {
+                        log_error("Failed to get backlight device: %m");
+                        r = -errno;
+                } else
+                        r = log_oom();
+
                 goto finish;
         }
 
@@ -66,7 +72,7 @@ int main(int argc, char *argv[]) {
                 goto finish;
         }
 
-        saved = strappend("/var/lib/backlight/", udev_device_get_sysname(device));
+        saved = strappend("/var/lib/systemd/backlight/", udev_device_get_sysname(device));
         if (!saved) {
                 r = log_oom();
                 goto finish;