This is the bb_ioctl patch for miscutils.

Ciao,
Tito
--- busybox.orig/miscutils/devfsd.c	2007-07-02 16:39:41.000000000 +0200
+++ busybox/miscutils/devfsd.c	2007-07-05 23:19:33.000000000 +0200
@@ -234,7 +234,6 @@
 static char *write_old_sd_name(char *, unsigned, unsigned, const char *);
 
 /* busybox functions */
-static void do_ioctl_or_die(int fd, int request, unsigned long event_mask_flag);
 static int get_uid_gid(int flag, const char *string);
 static void safe_memcpy(char * dest, const char * src, int len);
 static unsigned int scan_dev_name_common(const char *d, unsigned int n, int addendum, const char *ptr);
@@ -298,12 +297,6 @@
 #define error_logger_and_die(p, fmt, args...)         exit(1)
 #endif
 
-static void do_ioctl_or_die(int fd, int request, unsigned long event_mask_flag)
-{
-	if (ioctl(fd, request, event_mask_flag) == -1)
-		msg_logger_and_die(LOG_ERR, "ioctl");
-}
-
 static void safe_memcpy(char *dest, const char *src, int len)
 {
 	memcpy(dest , src, len);
@@ -386,8 +379,7 @@
 	if (fcntl(fd, F_SETFD, FD_CLOEXEC) != 0)
 		bb_perror_msg_and_die("FD_CLOEXEC");
 
-	if (ioctl(fd, DEVFSDIOC_GET_PROTO_REV, &proto_rev) == -1)
-		bb_perror_msg_and_die("ioctl");
+	ioctl_or_die(fd, DEVFSDIOC_GET_PROTO_REV, &proto_rev);
 
 	/*setup initial entries */
 	for (curr = initial_symlinks; curr->dest != NULL; ++curr)
@@ -404,7 +396,7 @@
 		exit(EXIT_SUCCESS); /* -v */
 	}
 	/*  Tell kernel we are special(i.e. we get to see hidden entries)  */
-	do_ioctl_or_die(fd, DEVFSDIOC_SET_EVENT_MASK, 0);
+	ioctl_or_die(fd, DEVFSDIOC_SET_EVENT_MASK, 0);
 
 	sigemptyset(&new_action.sa_mask);
 	new_action.sa_flags = 0;
@@ -435,7 +427,7 @@
 
 	if (do_daemon) {
 		/*  Release so that the child can grab it  */
-		do_ioctl_or_die(fd, DEVFSDIOC_RELEASE_EVENT_QUEUE, 0);
+		ioctl_or_die(fd, DEVFSDIOC_RELEASE_EVENT_QUEUE, 0);
 		bb_daemonize_or_rexec(0, argv);
 	} else if (ENABLE_DEVFSD_FG_NP) {
 		setpgid(0, 0);  /*  Become process group leader                    */
@@ -661,7 +653,7 @@
 
 	/*  Tell devfs what events we care about  */
 	tmp_event_mask = event_mask;
-	do_ioctl_or_die(fd, DEVFSDIOC_SET_EVENT_MASK, tmp_event_mask);
+	ioctl_or_die(fd, DEVFSDIOC_SET_EVENT_MASK, tmp_event_mask);
 	while (!caught_signal) {
 		errno = 0;
 		bytes = read(fd,(char *) &info, sizeof info);
--- busybox.orig/miscutils/eject.c	2007-05-26 23:23:52.000000000 +0200
+++ busybox/miscutils/eject.c	2007-07-07 22:06:13.000000000 +0200
@@ -50,9 +50,8 @@
 	if (flags & FLAG_CLOSE
 	 || (flags & FLAG_SMART && ioctl(dev, CDROM_DRIVE_STATUS) == CDS_TRAY_OPEN))
 		cmd = CDROMCLOSETRAY;
-	if (ioctl(dev, cmd)) {
-		bb_perror_msg_and_die("%s", device);
-	}
+
+	ioctl_or_vperror_and_die(dev, cmd, NULL, "%s", device);
 
 	if (ENABLE_FEATURE_CLEAN_UP)
 		close(dev);
--- busybox.orig/miscutils/mt.c	2007-05-26 23:23:52.000000000 +0200
+++ busybox/miscutils/mt.c	2007-07-07 22:25:46.000000000 +0200
@@ -106,14 +106,12 @@
 
 	switch (code->value) {
 		case MTTELL:
-			if (ioctl(fd, MTIOCPOS, &position) < 0)
-				bb_perror_msg_and_die("%s", file);
+			ioctl_or_vperror_and_die(fd, MTIOCPOS, &position, "%s", file);
 			printf("At block %d.\n", (int) position.mt_blkno);
 			break;
 
 		default:
-			if (ioctl(fd, MTIOCTOP, &op) != 0)
-				bb_perror_msg_and_die("%s", file);
+			ioctl_or_vperror_and_die(fd, MTIOCTOP, &op, "%s", file);
 			break;
 	}
 
--- busybox.orig/miscutils/raidautorun.c	2007-05-26 23:23:52.000000000 +0200
+++ busybox/miscutils/raidautorun.c	2007-07-07 00:41:19.000000000 +0200
@@ -19,9 +19,7 @@
 	if (argc != 2)
 		bb_show_usage();
 
-	if (ioctl(xopen(argv[1], O_RDONLY), RAID_AUTORUN, NULL) != 0) {
-		bb_perror_msg_and_die("ioctl");
-	}
+	ioctl_or_die(xopen(argv[1], O_RDONLY), RAID_AUTORUN, NULL);
 
 	return EXIT_SUCCESS;
 }
_______________________________________________
busybox mailing list
[email protected]
http://busybox.net/cgi-bin/mailman/listinfo/busybox

Reply via email to