Created
August 28, 2018 13:59
-
-
Save lantw44/d440f547bdd4085998cad72bec900913 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <fcntl.h> | |
#include <linux/kd.h> | |
#include <locale.h> | |
#include <stdio.h> | |
#include <sys/ioctl.h> | |
#include <sys/stat.h> | |
#include <sys/types.h> | |
int main (int argc, char *argv[]) { | |
setlocale (LC_ALL, ""); | |
if (argc < 2) { | |
fprintf (stderr, "Usage: %s <file> <mode>\n", argv[0]); | |
return 1; | |
} | |
int fd = open (argv[1], O_RDWR); | |
if (fd < 0) { | |
perror ("open"); | |
return 2; | |
} | |
int mode; | |
if (ioctl (fd, KDGKBMODE, &mode) < 0) { | |
perror ("ioctl KDGKBMODE"); | |
return 3; | |
} | |
printf ("%d\n", mode); | |
if (argc < 3) { | |
return 0; | |
} | |
if (sscanf (argv[2], "%d", &mode) != 1) { | |
perror ("sscanf"); | |
return 4; | |
} | |
if (ioctl (fd, KDSKBMODE, mode) < 0) { | |
perror ("ioctl"); | |
return 5; | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment