public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Ben Collins <bcollins@ubuntu.com>
To: axboe@suse.de, torvalds@osdl.org
Cc: linux-kernel@vger.kernel.org
Subject: [PATCH rc6] block: Fix CDROMEJECT to work in more cases
Date: Mon, 19 Dec 2005 11:50:14 -0800	[thread overview]
Message-ID: <20051219195014.GA13578@swissdisk.com> (raw)

This changes the request to a READ instead of WRITE. Also adds and calls
blk_send_allow_medium_removal() for CDROMEJECT case.

Signed-off-by: Ben Collins <bcollins@ubuntu.com>

--- a/block/scsi_ioctl.c~	2005-12-19 15:44:06.000000000 -0500
+++ b/block/scsi_ioctl.c	2005-12-19 15:46:43.000000000 -0500
@@ -449,7 +449,7 @@
 	struct request *rq;
 	int err;
 
-	rq = blk_get_request(q, WRITE, __GFP_WAIT);
+	rq = blk_get_request(q, READ, __GFP_WAIT);
 	rq->flags |= REQ_BLOCK_PC;
 	rq->data = NULL;
 	rq->data_len = 0;
@@ -469,6 +469,11 @@
 	return __blk_send_generic(q, bd_disk, GPCMD_START_STOP_UNIT, data);
 }
 
+static inline int blk_send_allow_medium_removal(request_queue_t *q, struct gendisk *bd_disk)
+{
+	return __blk_send_generic(q, bd_disk, GPCMD_PREVENT_ALLOW_MEDIUM_REMOVAL, 0);
+}
+
 int scsi_cmd_ioctl(struct file *file, struct gendisk *bd_disk, unsigned int cmd, void __user *arg)
 {
 	request_queue_t *q;
@@ -593,7 +598,11 @@
 			err = blk_send_start_stop(q, bd_disk, 0x03);
 			break;
 		case CDROMEJECT:
-			err = blk_send_start_stop(q, bd_disk, 0x02);
+			err = 0;
+
+			err |= blk_send_allow_medium_removal(q, bd_disk);
+			err |= blk_send_start_stop(q, bd_disk, 0x01);
+			err |= blk_send_start_stop(q, bd_disk, 0x02);
 			break;
 		default:
 			err = -ENOTTY;

             reply	other threads:[~2005-12-19 20:59 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-12-19 19:50 Ben Collins [this message]
2005-12-20 17:34 ` [PATCH rc6] block: Fix CDROMEJECT to work in more cases Linus Torvalds
2005-12-20 17:49   ` Jens Axboe
2005-12-20 18:08     ` Linus Torvalds
2005-12-20 18:38       ` Jens Axboe
2005-12-20 18:53         ` Linus Torvalds
2005-12-20 19:08           ` Jens Axboe
2005-12-20 20:38       ` Ben Collins
2005-12-20 20:53         ` Jens Axboe
2005-12-20 21:46           ` Ben Collins
2005-12-21  7:04             ` 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=20051219195014.GA13578@swissdisk.com \
    --to=bcollins@ubuntu.com \
    --cc=axboe@suse.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=torvalds@osdl.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