On Wed, 08.04.15 19:05, Jan Janssen ([email protected]) wrote: > What's the point in retrying if you got EOPNOTSUPP the first time? > :P
Well, dunno. Actually the main reason I swapped around the order of the two ways, is to avoid whitelisting or blacklisting error cases... I mean, there are certain cases where it makes sense to try the other way (EPERM, EACCES, ...), and others where it clearly doesn't (ENOTSUPP, ...), but I really wanted to avoid to list them all here. Hence I figured we should do the cheap thing first, and then the expensive thing, without any kind of optimizations via error code whitelists/blacklists... If you follow what I mean... Does that make any sense? > > Jan > > On 2015-04-08 18:24, Lennart Poettering wrote: > >On Wed, 08.04.15 16:49, Jan Janssen ([email protected]) wrote: > > > >Awesome! Thanks! > > > >Applied! (Though I took the liberty to swap the order around, to first > >try direct access, and only the fall back via logind. > > > >Thanks, > > > >Lennart > > > >>--- > >> src/systemctl/systemctl.c | 43 ++++++++++++++++++++++++++++++++++++++----- > >> 1 file changed, 38 insertions(+), 5 deletions(-) > >> > >>diff --git a/src/systemctl/systemctl.c b/src/systemctl/systemctl.c > >>index ae87e44..caa8d07 100644 > >>--- a/src/systemctl/systemctl.c > >>+++ b/src/systemctl/systemctl.c > >>@@ -2913,6 +2913,41 @@ static int check_inhibitors(sd_bus *bus, enum action > >>a) { > >> #endif > >> } > >> > >>+static int prepare_firmware_setup(sd_bus *bus) { > >>+ int r; > >>+ _cleanup_bus_error_free_ sd_bus_error error = SD_BUS_ERROR_NULL; > >>+ > >>+ if (!arg_firmware_setup) > >>+ return 0; > >>+ > >>+#ifdef HAVE_LOGIND > >>+ r = sd_bus_call_method( > >>+ bus, > >>+ "org.freedesktop.login1", > >>+ "/org/freedesktop/login1", > >>+ "org.freedesktop.login1.Manager", > >>+ "SetRebootToFirmwareSetup", > >>+ &error, > >>+ NULL, > >>+ "b", true); > >>+ if (r < 0) > >>+ log_error("Cannot indicate to EFI to boot into setup mode: > >>%s", bus_error_message(&error, r)); > >>+ > >>+ /* No point trying to fall back. */ > >>+ if (r == -EOPNOTSUPP) > >>+ return r; > >>+#endif > >>+ > >>+ if (arg_transport != BUS_TRANSPORT_LOCAL) > >>+ return log_error_errno(-EINVAL, "Cannot remotely indicate > >>to EFI to boot into setup mode."); > >>+ > >>+ r = efi_set_reboot_to_firmware(true); > >>+ if (r < 0) > >>+ return log_error_errno(r, "Cannot indicate to EFI to boot > >>into setup mode: %m"); > >>+ > >>+ return 0; > >>+} > >>+ > >> static int start_special(sd_bus *bus, char **args) { > >> enum action a; > >> int r; > >>@@ -2930,11 +2965,9 @@ static int start_special(sd_bus *bus, char **args) { > >> return -EPERM; > >> } > >> > >>- if (arg_firmware_setup) { > >>- r = efi_set_reboot_to_firmware(true); > >>- if (r < 0) > >>- return log_error_errno(r, "Cannot indicate to EFI > >>to boot into setup mode: %m"); > >>- } > >>+ r = prepare_firmware_setup(bus); > >>+ if (r < 0) > >>+ return r; > >> > >> if (a == ACTION_REBOOT && args[1]) { > >> r = update_reboot_param_file(args[1]); > >>-- > >>2.3.5 > >> > >>_______________________________________________ > >>systemd-devel mailing list > >>[email protected] > >>http://lists.freedesktop.org/mailman/listinfo/systemd-devel > > > > > >Lennart > > Lennart -- Lennart Poettering, Red Hat _______________________________________________ systemd-devel mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/systemd-devel
