This is the bb_ioctl patch for console-tools.

Ciao,
Tito
--- busybox.orig/console-tools/chvt.c	2007-05-26 23:23:40.000000000 +0200
+++ busybox/console-tools/chvt.c	2007-07-09 21:39:51.000000000 +0200
@@ -26,9 +26,7 @@
 
 	fd = get_console_fd();
 	num = xatoul_range(argv[1], 1, 63);
-	if ((-1 == ioctl(fd, VT_ACTIVATE, num))
-	|| (-1 == ioctl(fd, VT_WAITACTIVE, num))) {
-		bb_perror_msg_and_die("ioctl");
-	}
+	ioctl_or_die(fd, VT_ACTIVATE, (void *)num);
+	ioctl_or_die(fd, VT_WAITACTIVE, (void *)num);
 	return EXIT_SUCCESS;
 }
--- busybox.orig/console-tools/deallocvt.c	2007-05-26 23:23:40.000000000 +0200
+++ busybox/console-tools/deallocvt.c	2007-07-05 23:16:30.000000000 +0200
@@ -31,8 +31,6 @@
 		bb_show_usage();
 	}
 
-	if (-1 == ioctl(get_console_fd(), VT_DISALLOCATE, num)) {
-		bb_perror_msg_and_die("VT_DISALLOCATE");
-	}
+	ioctl_or_die(get_console_fd(), VT_DISALLOCATE, (void *)num);
 	return EXIT_SUCCESS;
 }
--- busybox.orig/console-tools/dumpkmap.c	2007-05-26 23:23:40.000000000 +0200
+++ busybox/console-tools/dumpkmap.c	2007-07-09 21:44:34.000000000 +0200
@@ -50,14 +50,13 @@
 			for (j = 0; j < NR_KEYS; j++) {
 				ke.kb_index = j;
 				ke.kb_table = i;
-				if (ioctl(fd, KDGKBENT, &ke) < 0) {
-					bb_perror_msg("ioctl failed with %s, %s, %p",
+				if (!ioctl_or_vperror(fd, KDGKBENT, &ke,
+						"ioctl failed with %s, %s, %p",
 						(char *)&ke.kb_index,
 						(char *)&ke.kb_table,
-						&ke.kb_value);
-				} else {
+						&ke.kb_value)
+				)
 					write(1, (void*)&ke.kb_value, 2);
-				}
 			}
 		}
 	}
--- busybox.orig/console-tools/loadfont.c	2007-06-11 21:37:27.000000000 +0200
+++ busybox/console-tools/loadfont.c	2007-07-09 21:46:18.000000000 +0200
@@ -49,13 +49,11 @@
 		cfd.charheight = unit;
 		cfd.chardata = buf;
 
-		if (ioctl(fd, PIO_FONTX, &cfd) == 0)
+		if (!ioctl_or_warn(fd, PIO_FONTX, &cfd))
 			goto ret;			/* success */
-		bb_perror_msg("PIO_FONTX ioctl (will try PIO_FONT)");
 	}
 #endif
-	if (ioctl(fd, PIO_FONT, buf))
-		bb_perror_msg_and_die("PIO_FONT ioctl");
+	ioctl_or_die(fd, PIO_FONT, buf);
  ret:
 	free(buf);
 }
@@ -92,20 +90,10 @@
 	advice.advised_hashsize = 0;
 	advice.advised_hashstep = 0;
 	advice.advised_hashlevel = 0;
-	if (ioctl(fd, PIO_UNIMAPCLR, &advice)) {
-#ifdef ENOIOCTLCMD
-		if (errno == ENOIOCTLCMD) {
-			bb_error_msg("it seems this kernel is older than 1.1.92");
-			bb_error_msg_and_die("no Unicode mapping table loaded");
-		} else
-#endif
-			bb_perror_msg_and_die("PIO_UNIMAPCLR");
-	}
+	ioctl_or_die(fd, PIO_UNIMAPCLR, &advice);
 	ud.entry_ct = ct;
 	ud.entries = up;
-	if (ioctl(fd, PIO_UNIMAP, &ud)) {
-		bb_perror_msg_and_die("PIO_UNIMAP");
-	}
+	ioctl_or_die(fd, PIO_UNIMAP, &ud);
 }
 
 static void loadnewfont(int fd)
--- busybox.orig/console-tools/setconsole.c	2007-05-26 23:23:40.000000000 +0200
+++ busybox/console-tools/setconsole.c	2007-07-07 00:35:44.000000000 +0200
@@ -42,8 +42,6 @@
 			device = DEV_CONSOLE;
 	}
 
-	if (-1 == ioctl(xopen(device, O_RDONLY), TIOCCONS)) {
-		bb_perror_msg_and_die("TIOCCONS");
-	}
+	ioctl_or_die(xopen(device, O_RDONLY), TIOCCONS, NULL);
 	return EXIT_SUCCESS;
 }
--- busybox.orig/console-tools/setkeycodes.c	2007-06-03 23:37:06.000000000 +0200
+++ busybox/console-tools/setkeycodes.c	2007-07-07 22:00:07.000000000 +0200
@@ -39,9 +39,9 @@
 			a.scancode -= 0xe000;
 			a.scancode += 128;
 		}
-		if (ioctl(fd, KDSETKEYCODE, &a)) {
-			bb_perror_msg_and_die("failed to set SCANCODE %x to KEYCODE %d", sc, a.keycode);
-		}
+		ioctl_or_vperror_and_die(fd, KDSETKEYCODE, &a,
+			"failed to set SCANCODE %x to KEYCODE %d",
+			sc, a.keycode);
 		argc -= 2;
 		argv += 2;
 	}
--- busybox.orig/console-tools/setlogcons.c	2007-05-26 23:23:40.000000000 +0200
+++ busybox/console-tools/setlogcons.c	2007-07-05 23:17:44.000000000 +0200
@@ -25,8 +25,7 @@
 	if (argc == 2)
 		arg.subarg = xatoul_range(argv[1], 0, 63);
 
-	if (ioctl(xopen(VC_1, O_RDONLY), TIOCLINUX, &arg))
-		bb_perror_msg_and_die("TIOCLINUX");
+	ioctl_or_die(xopen(VC_1, O_RDONLY), TIOCLINUX, &arg);
 
 	return 0;
 }
_______________________________________________
busybox mailing list
[email protected]
http://busybox.net/cgi-bin/mailman/listinfo/busybox

Reply via email to