public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Peter Osterlund <petero2@telia.com>
To: Jens Axboe <axboe@suse.de>
Cc: Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Incorrect timeout in CDROM_SEND_PACKET ioctl in 2.5 kernels
Date: 13 Jul 2003 18:12:56 +0200	[thread overview]
Message-ID: <m2u19q1k3b.fsf@telia.com> (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.

--- linux/drivers/cdrom/cdrom.c.old	Sun Jul 13 16:34:37 2003
+++ linux/drivers/cdrom/cdrom.c	Sun Jul 13 15:19:11 2003
@@ -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: {

-- 
Peter Osterlund - petero2@telia.com
http://w1.894.telia.com/~u89404340

             reply	other threads:[~2003-07-13 15:59 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-07-13 16:12 Peter Osterlund [this message]
2003-07-15 14:01 ` Incorrect timeout in CDROM_SEND_PACKET ioctl in 2.5 kernels Jens Axboe

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=m2u19q1k3b.fsf@telia.com \
    --to=petero2@telia.com \
    --cc=axboe@suse.de \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox