This is the bb_ioctl patch for util-linux.
Ciao,
Tito
--- busybox.orig/util-linux/fbset.c 2007-05-26 23:23:58.000000000 +0200
+++ busybox/util-linux/fbset.c 2007-07-06 23:24:36.000000000 +0200
@@ -385,8 +385,7 @@
}
fh = xopen(fbdev, O_RDONLY);
- if (ioctl(fh, FBIOGET_VSCREENINFO, &var))
- bb_perror_msg_and_die("ioctl(%sT_VSCREENINFO)", "GE");
+ ioctl_or_die(fh, FBIOGET_VSCREENINFO, &var);
if (g_options & OPT_READMODE) {
if (!readmode(&var, modefile, mode)) {
bb_error_msg_and_die("unknown video mode '%s'", mode);
@@ -397,8 +396,7 @@
if (g_options & OPT_CHANGE) {
if (g_options & OPT_ALL)
var.activate = FB_ACTIVATE_ALL;
- if (ioctl(fh, FBIOPUT_VSCREENINFO, &var))
- bb_perror_msg_and_die("ioctl(%sT_VSCREENINFO)", "PU");
+ ioctl_or_die(fh, FBIOPUT_VSCREENINFO, &var);
}
showmode(&var);
/* Don't close the file, as exiting will take care of that */
--- busybox.orig/util-linux/fdformat.c 2007-05-26 23:23:58.000000000 +0200
+++ busybox/util-linux/fdformat.c 2007-07-06 23:26:20.000000000 +0200
@@ -45,13 +45,6 @@
#define FDGETPRM _IOR(2, 0x04, struct floppy_struct)
#define FD_FILL_BYTE 0xF6 /* format fill byte. */
-static void xioctl(int fd, int request, void *argp, const char *string)
-{
- if (ioctl(fd, request, argp) < 0) {
- bb_perror_msg_and_die(string);
- }
-}
-
int fdformat_main(int argc,char **argv);
int fdformat_main(int argc,char **argv)
{
@@ -77,7 +70,7 @@
fd = xopen(*argv, O_RDWR);
/* original message was: "Could not determine current format type" */
- xioctl(fd, FDGETPRM, ¶m, "FDGETPRM");
+ ioctl_or_die(fd, FDGETPRM, ¶m);
printf("%s-sided, %d tracks, %d sec/track. Total capacity %d kB\n",
(param.head == 2) ? "Double" : "Single",
@@ -85,21 +78,21 @@
/* FORMAT */
printf("Formatting... ");
- xioctl(fd, FDFMTBEG, NULL, "FDFMTBEG");
+ ioctl_or_die(fd, FDFMTBEG, NULL);
/* n == track */
for (n = 0; n < param.track; n++) {
descr.head = 0;
descr.track = n;
- xioctl(fd, FDFMTTRK, &descr, "FDFMTTRK");
+ ioctl_or_die(fd, FDFMTTRK, &descr);
printf("%3d\b\b\b", n);
if (param.head == 2) {
descr.head = 1;
- xioctl(fd, FDFMTTRK, &descr, "FDFMTTRK");
+ ioctl_or_die(fd, FDFMTTRK, &descr);
}
}
- xioctl(fd, FDFMTEND, NULL, "FDFMTEND");
+ ioctl_or_die(fd, FDFMTEND, NULL);
printf("done\n");
/* VERIFY */
--- busybox.orig/util-linux/fdisk.c 2007-06-25 13:53:32.000000000 +0200
+++ busybox/util-linux/fdisk.c 2007-07-07 22:36:25.000000000 +0200
@@ -2434,23 +2434,9 @@
printf("Calling ioctl() to re-read partition table\n");
sync();
/* sleep(2); Huh? */
- i = ioctl(fd, BLKRRPART);
-#if 0
- else {
- /* some kernel versions (1.2.x) seem to have trouble
- rereading the partition table, but if asked to do it
- twice, the second time works. - [EMAIL PROTECTED] */
- sync();
- sleep(2);
- i = ioctl(fd, BLKRRPART);
- }
-#endif
-
- if (i) {
- bb_perror_msg("WARNING: rereading partition table "
+ i = ioctl(fd, BLKRRPART, NULL,
+ "WARNING: rereading partition table "
"failed, kernel still uses old table");
- }
-
#if 0
if (dos_changed)
printf(
--- busybox.orig/util-linux/freeramdisk.c 2007-05-26 23:23:58.000000000 +0200
+++ busybox/util-linux/freeramdisk.c 2007-07-07 22:15:55.000000000 +0200
@@ -17,7 +17,6 @@
int freeramdisk_main(int argc, char **argv);
int freeramdisk_main(int argc, char **argv)
{
- int result;
int fd;
if (argc != 2) bb_show_usage();
@@ -25,11 +24,10 @@
fd = xopen(argv[1], O_RDWR);
// Act like freeramdisk, fdflush, or both depending on configuration.
- result = ioctl(fd, (ENABLE_FREERAMDISK && applet_name[1]=='r')
- || !ENABLE_FDFLUSH ? BLKFLSBUF : FDFLUSH);
+ ioctl_or_vperror_and_die(fd, (ENABLE_FREERAMDISK && applet_name[1]=='r')
+ || !ENABLE_FDFLUSH ? BLKFLSBUF : FDFLUSH, NULL, "%s", argv[1]);
if (ENABLE_FEATURE_CLEAN_UP) close(fd);
- if (result) bb_perror_msg_and_die("%s", argv[1]);
return EXIT_SUCCESS;
}
--- busybox.orig/util-linux/hwclock.c 2007-06-17 21:28:44.000000000 +0200
+++ busybox/util-linux/hwclock.c 2007-07-07 22:16:12.000000000 +0200
@@ -59,8 +59,7 @@
int rtc = xopen_rtc(O_RDONLY);
memset(&tm, 0, sizeof(struct tm));
- if (ioctl(rtc, RTC_RD_TIME, &tm) < 0)
- bb_perror_msg_and_die("cannot read time from RTC");
+ ioctl_or_die(rtc, RTC_RD_TIME, &tm);
tm.tm_isdst = -1; /* not known */
close(rtc);
@@ -91,8 +90,7 @@
tm = *(utc ? gmtime(&t) : localtime(&t));
tm.tm_isdst = 0;
- if (ioctl(rtc, RTC_SET_TIME, &tm) < 0)
- bb_perror_msg_and_die("cannot set the RTC time");
+ ioctl_or_die(rtc, RTC_SET_TIME, &tm);
close(rtc);
}
_______________________________________________
busybox mailing list
[email protected]
http://busybox.net/cgi-bin/mailman/listinfo/busybox