[systemd-devel] [PATCH] Add support for initial state of NumLock
Cristian Rodríguez
crrodriguez at opensuse.org
Fri Apr 12 14:15:49 PDT 2013
El 12/04/13 13:53, Stanislav Brabec escribió:
> Add support for setting of initial state of NumLock. Supported values
> are "yes", "no" and "bios" (on x86 platforms).
>
> It sets NumLock in virtual consoles. If NumLock should be turned on, it
> also creates empty /run/numlock-on, which can be used e. g. for setting
> of X session default.
>
> This ports a feature that exists for a long time in SUSE to systemd.
> +AC_PATH_PROG([SETLEDS], [setleds], [/bin/setleds], [/usr/sbin:/sbin:/usr/bin:/bin])
> +#include "config.h"
> +#include <fcntl.h>
> +#include <sysexits.h>
> +#include <unistd.h>
> +
> +int main (int argc, char *argv[]) {
> + static char *args[] = { SETLEDS, "-D", "+num", NULL };
> +
> + if (argc != 2)
> + return EX_USAGE;
> + close (STDIN_FILENO);
> + if (open (argv[1], O_RDONLY) != STDIN_FILENO)
> + return EX_IOERR;
> + return execv(args[0], args);
> +}
my objections start here ;)
Why do we need a third party binary for an operation that could be done
with single ioctl(0, KDSETLED... ?
> +#if defined(__i386__) || defined(__x86_64__)
> + if (vc_kbd_numlock && strcasecmp(vc_kbd_numlock, "bios") == 0) {
> + int fd;
> + char c;
> +
> + fd = open ("/dev/mem", O_RDONLY);
> + lseek (fd, BIOS_DATA_AREA + BDA_KEYBOARD_STATUS_FLAGS_4, SEEK_SET);
> + read (fd, &c, sizeof(char));
> + if (c & BDA_KSF4_NUMLOCK_MASK)
> + numlock = true;
> + close(fd);
> + } else
> +#endif
huh, there is no error handling here..
> + if (numlock)
> + close(open("/run/numlock-on", O_WRONLY|O_CREAT, 0644));
> + else
There is a touch function defined in util.h for that.,.
More information about the systemd-devel
mailing list