I/O: Improve messaging when user doesn't have permissions to write to LEDs

This is e.g. the case with the newly released Raspbian 2015-09-24.
This commit is contained in:
gohai
2015-10-12 00:06:39 +02:00
parent eb240c6192
commit 59e05393a5
+4 -1
View File
@@ -87,7 +87,10 @@ public class LED {
String fn = "/sys/class/leds/" + dev + "/trigger";
int ret = NativeInterface.writeFile(fn, "none");
if (ret < 0) {
throw new RuntimeException(fn + ": " + NativeInterface.getError(ret));
if (ret == -13) { // EACCES
System.err.println("You might need to install a custom udev rule to allow regular users to modify /sys/class/leds/*.");
}
throw new RuntimeException(NativeInterface.getError(ret));
}
}