Commit 21fc74ec authored by Alexey Gladkov's avatar Alexey Gladkov

Check the return code of getfd

Signed-off-by: default avatarAlexey Gladkov <gladkov.alexey@gmail.com>
parent eadc5ff5
......@@ -33,7 +33,9 @@ main(int argc, char *argv[]) {
return EXIT_FAILURE;
}
fd = getfd(NULL);
if ((fd = getfd(NULL)) < 0)
kbd_error(EXIT_FAILURE, 0, _("Couldn't get a file descriptor referring to the console"));
num = atoi(argv[1]);
if (ioctl(fd,VT_ACTIVATE,num)) {
......
......@@ -26,7 +26,8 @@ main(int argc, char *argv[]) {
if (argc >= 3 && !strcmp(argv[1], "-C"))
console = argv[2];
fd = getfd(console);
if ((fd = getfd(console)) < 0)
kbd_error(EXIT_FAILURE, 0, _("Couldn't get a file descriptor referring to the console"));
return loadunimap (fd, NULL, NULL);
}
......@@ -39,7 +39,8 @@ main(int argc, char *argv[]) {
}
}
fd = getfd(NULL);
if ((fd = getfd(NULL)) < 0)
kbd_error(EXIT_FAILURE, 0, _("Couldn't get a file descriptor referring to the console"));
if (argc == 1) {
/* deallocate all unused consoles */
......@@ -57,5 +58,5 @@ main(int argc, char *argv[]) {
"ioctl VT_DISALLOCATE"), num);
}
}
exit(0);
exit(EXIT_SUCCESS);
}
......@@ -152,7 +152,8 @@ main (int argc, char *argv[]) {
if (optind < argc)
usage();
fd = getfd(NULL);
if ((fd = getfd(NULL)) < 0)
kbd_error(EXIT_FAILURE, 0, _("Couldn't get a file descriptor referring to the console"));
/* check whether the keyboard is in Unicode mode */
if (ioctl(fd, KDGKBMODE, &kbd_mode)) {
......
......@@ -64,7 +64,9 @@ main(int argc, char **argv){
}
}
fd = getfd(NULL);
if ((fd = getfd(NULL)) < 0)
kbd_error(EXIT_FAILURE, 0, _("Couldn't get a file descriptor referring to the console"));
if (show_vt) {
if ((ioctl(fd, VT_OPENQRY, &vtno) < 0) || vtno == -1) {
kbd_error(2, errno, _("Couldn't read VTNO: "));
......
......@@ -39,7 +39,9 @@ main(int argc, char **argv) {
if (argc != 1)
usage();
fd = getfd(NULL);
if ((fd = getfd(NULL)) < 0)
kbd_error(EXIT_FAILURE, 0, _("Couldn't get a file descriptor referring to the console"));
/* Old kernels don't support changing scancodes below SC_LIM. */
a.scancode = 0;
......
......@@ -67,7 +67,9 @@ main(int argc, char **argv){
if (optind < argc)
usage();
fd = getfd(console);
if ((fd = getfd(console)) < 0)
kbd_error(EXIT_FAILURE, 0, _("Couldn't get a file descriptor referring to the console"));
if (getunimap(fd, &ud))
return EXIT_FAILURE;
......
......@@ -74,7 +74,8 @@ main(int argc, char *argv[]){
}
}
fd = getfd(console);
if ((fd = getfd(console)) < 0)
kbd_error(EXIT_FAILURE, 0, _("Couldn't get a file descriptor referring to the console"));
if (n == 0) {
/* report mode */
......
......@@ -75,7 +75,8 @@ main(int argc, char **argv) {
if (optind < argc)
value = argv[optind++];
fd = getfd(console);
if ((fd = getfd(console)) < 0)
kbd_error(EXIT_FAILURE, 0, _("Couldn't get a file descriptor referring to the console"));
if (!strcasecmp("GETMODE", action)) {
if (ioctl(fd, KDGETMODE, &mode) == -1)
......
......@@ -175,7 +175,8 @@ main(int argc, char *argv[])
if (!(options & OPT_M) && !(options & OPT_B)) {
/* get console */
fd = getfd(console);
if ((fd = getfd(NULL)) < 0)
kbd_error(EXIT_FAILURE, 0, _("Couldn't get a file descriptor referring to the console"));
/* check whether the keyboard is in Unicode mode */
if (ioctl(fd, KDGKBMODE, &kbd_mode) ||
......
......@@ -78,7 +78,8 @@ main(int argc, char *argv[]) {
if (argc > optind+1 || (argc == optind && !outfnam))
usage();
fd = getfd(console);
if ((fd = getfd(console)) < 0)
kbd_error(EXIT_FAILURE, 0, _("Couldn't get a file descriptor referring to the console"));
if (outfnam) {
saveunicodemap(fd, outfnam);
......
......@@ -55,23 +55,24 @@ main(int argc, char *argv[]) {
argv++;
}
fd = getfd(NULL);
if ((fd = getfd(NULL)) < 0)
kbd_error(EXIT_FAILURE, 0, _("Couldn't get a file descriptor referring to the console"));
if (argc >= 3 && !strcmp(argv[1], "-o")) {
saveoldmap(fd, argv[2]);
argc -= 2;
argv += 2;
if (argc == 1)
exit(0);
exit(EXIT_SUCCESS);
}
if (argc != 2) {
fprintf(stderr, _("usage: %s [-V] [-v] [-o map.orig] map-file\n"),
progname);
exit(1);
exit(EXIT_FAILURE);
}
loadnewmap(fd, argv[1]);
exit(0);
exit(EXIT_SUCCESS);
}
#endif
......
......@@ -151,7 +151,8 @@ main(int argc, char **argv) {
lk_fpclose(&fp);
}
fd = getfd(NULL);
if ((fd = getfd(NULL)) < 0)
kbd_error(EXIT_FAILURE, 0, _("Couldn't get a file descriptor referring to the console"));
if(ioctl(fd, TIOCGWINSZ, &winsize)) {
kbd_error(EXIT_FAILURE, errno, "ioctl TIOCGWINSZ");
......
......@@ -188,7 +188,8 @@ main(int argc, char *argv[]) {
exit(EX_USAGE);
}
fd = getfd(console);
if ((fd = getfd(console)) < 0)
kbd_error(EXIT_FAILURE, 0, _("Couldn't get a file descriptor referring to the console"));
int kd_mode = -1;
if (!ioctl(fd, KDGETMODE, &kd_mode) && (kd_mode == KD_GRAPHICS))
......
......@@ -45,7 +45,9 @@ main(int argc, char **argv) {
if (argc % 2 != 1)
usage(_("even number of arguments expected"));
fd = getfd(NULL);
if ((fd = getfd(NULL)) < 0)
kbd_error(EXIT_FAILURE, 0, _("Couldn't get a file descriptor referring to the console"));
while (argc > 2) {
a.keycode = atoi(argv[2]);
......
......@@ -31,7 +31,9 @@ main(int argc, char **argv){
else
cons = 0; /* current console */
fd = getfd(NULL);
if ((fd = getfd(NULL)) < 0)
kbd_error(EXIT_FAILURE, 0, _("Couldn't get a file descriptor referring to the console"));
arg.fn = 11; /* redirect kernel messages */
arg.subarg = cons; /* to specified console */
if (ioctl(fd, TIOCLINUX, &arg)) {
......
......@@ -32,7 +32,8 @@ main(int argc, char **argv){
exit(EXIT_FAILURE);
}
fd = getfd(NULL);
if ((fd = getfd(NULL)) < 0)
kbd_error(EXIT_FAILURE, 0, _("Couldn't get a file descriptor referring to the console"));
if (ioctl(fd, GIO_CMAP, cmap))
kbd_error(EXIT_FAILURE, errno, "ioctl GIO_CMAP");
......
......@@ -27,7 +27,8 @@ main(int argc, char *argv[]) {
fprintf(stderr, _("usage: %s\n"), "setvesablank ON|on|off");
return EXIT_FAILURE;
}
fd = getfd(NULL);
if ((fd = getfd(NULL)) < 0)
kbd_error(EXIT_FAILURE, 0, _("Couldn't get a file descriptor referring to the console"));
arg.ten = 10;
arg.onoff = 0;
if (!strcmp(argv[1], "on"))
......
......@@ -136,7 +136,8 @@ main(int argc, char **argv) {
fclose(f);
}
fd = getfd(NULL);
if ((fd = getfd(NULL)) < 0)
kbd_error(EXIT_FAILURE, 0, _("Couldn't get a file descriptor referring to the console"));
/* Apply the color map to the tty via ioctl */
if (ioctl(fd, PIO_CMAP, colormap) == -1)
......
......@@ -143,7 +143,8 @@ main (int argc, char **argv) {
if (optind != argc)
usage();
fd = getfd(console);
if ((fd = getfd(console)) < 0)
kbd_error(EXIT_FAILURE, 0, _("Couldn't get a file descriptor referring to the console"));
if (ioctl(fd, KDGKBMODE, &mode)) {
kbd_warning(errno, "ioctl KDGKBMODE");
......
......@@ -175,8 +175,8 @@ main (int argc, char *argv[]) {
return EXIT_SUCCESS;
}
fd = getfd(NULL);
if ((fd = getfd(NULL)) < 0)
kbd_error(EXIT_FAILURE, 0, _("Couldn't get a file descriptor referring to the console"));
/* the program terminates when there is no input for 10 secs */
signal(SIGALRM, watch_dog);
......
......@@ -32,7 +32,10 @@ main(int argc, char *argv[]) {
if (argc != 2) {
kbd_error(EXIT_FAILURE, 0, _("usage: totextmode\n"));
}
fd = getfd(NULL);
if ((fd = getfd(NULL)) < 0)
kbd_error(EXIT_FAILURE, 0, _("Couldn't get a file descriptor referring to the console"));
num = atoi(argv[1]);
if (ioctl(fd,KDSETMODE,KD_TEXT)) {
kbd_error(EXIT_FAILURE, errno, "totextmode: KDSETMODE");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment