Skip to contentSkip to conversation

Incorrect timeout in CDROM_SEND_PACKET ioctl in 2.5 kernels

PATCH Peter Osterlund 2 participants 2 messages Jul 13, 2003 – Jul 15, 2003 Uniform cdrom driver

lore
Share & tools
lore
#0 lore raw

The CDROM_SEND_PACKET ioctl passes a struct cdrom_generic_command from user space, which contains a timeout field. The timeout is measured in jiffies, but the conversion from user to kernel jiffies is missing, which makes the timeout 10 times shorter than it should be in 2.5 kernels on x86. This causes CDRW formatting with cdrwtool to fail. The following patch fixes this problem.

drivers/cdrom/cdrom.c renamed from drivers/cdrom/cdrom.c.old +3 -0
@@ -295,6 +295,8 @@
 #define cdinfo(type, fmt, args...) 
 #endif
 
+#define MULDIV(X,MUL,DIV) ((((X % DIV) * MUL) / DIV) + ((X / DIV) * MUL))
+
 /* These are used to simplify getting data in from and back to user land */
 #define IOCTL_IN(arg, type, in)					\
 	if (copy_from_user(&(in), (type *) (arg), sizeof (in)))	\
@@ -2171,6 +2173,7 @@
 			return -ENOSYS;
 		cdinfo(CD_DO_IOCTL, "entering CDROM_SEND_PACKET\n"); 
 		IOCTL_IN(arg, struct cdrom_generic_command, cgc);
+		cgc.timeout = MULDIV(cgc.timeout, HZ, USER_HZ);
 		return cdrom_do_cmd(cdi, &cgc);
 		}
 	case CDROM_NEXT_WRITABLE: {
Signature · 2 lines
Peter Osterlund - [email protected]
http://w1.894.telia.com/~u89404340
#1 lore raw
Quoted 6 lines · Peter Osterlund

The CDROM_SEND_PACKET ioctl passes a struct cdrom_generic_command from user space, which contains a timeout field. The timeout is measured in jiffies, but the conversion from user to kernel jiffies is missing, which makes the timeout 10 times shorter than it should be in 2.5 kernels on x86. This causes CDRW formatting with cdrwtool to fail. The following patch fixes this problem.

Looks fine, applied.

Signature · 1 line
Jens Axboe