diff options
author | Al Viro <viro@zeniv.linux.org.uk> | 2008-09-02 16:35:55 -0400 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2008-10-21 07:47:10 -0400 |
commit | 5842e51ff2e8d660756248db80ad24e4f41977d9 (patch) | |
tree | 245de9d6178271f9caa4f52f3abde6455ac4221f /block/scsi_ioctl.c | |
parent | 86d434dede14108dd917b25af0f29c0cb28b8d18 (diff) |
[PATCH] pass mode instead of file to sg_io()
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'block/scsi_ioctl.c')
-rw-r--r-- | block/scsi_ioctl.c | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/block/scsi_ioctl.c b/block/scsi_ioctl.c index c525905f9d35..9a441559118d 100644 --- a/block/scsi_ioctl.c +++ b/block/scsi_ioctl.c | |||
@@ -190,12 +190,11 @@ void blk_set_cmd_filter_defaults(struct blk_cmd_filter *filter) | |||
190 | EXPORT_SYMBOL_GPL(blk_set_cmd_filter_defaults); | 190 | EXPORT_SYMBOL_GPL(blk_set_cmd_filter_defaults); |
191 | 191 | ||
192 | static int blk_fill_sghdr_rq(struct request_queue *q, struct request *rq, | 192 | static int blk_fill_sghdr_rq(struct request_queue *q, struct request *rq, |
193 | struct sg_io_hdr *hdr, struct file *file) | 193 | struct sg_io_hdr *hdr, fmode_t mode) |
194 | { | 194 | { |
195 | if (copy_from_user(rq->cmd, hdr->cmdp, hdr->cmd_len)) | 195 | if (copy_from_user(rq->cmd, hdr->cmdp, hdr->cmd_len)) |
196 | return -EFAULT; | 196 | return -EFAULT; |
197 | if (blk_verify_command(&q->cmd_filter, rq->cmd, | 197 | if (blk_verify_command(&q->cmd_filter, rq->cmd, mode & FMODE_WRITE)) |
198 | file->f_mode & FMODE_WRITE)) | ||
199 | return -EPERM; | 198 | return -EPERM; |
200 | 199 | ||
201 | /* | 200 | /* |
@@ -260,8 +259,8 @@ static int blk_complete_sghdr_rq(struct request *rq, struct sg_io_hdr *hdr, | |||
260 | return r; | 259 | return r; |
261 | } | 260 | } |
262 | 261 | ||
263 | static int sg_io(struct file *file, struct request_queue *q, | 262 | static int sg_io(struct request_queue *q, struct gendisk *bd_disk, |
264 | struct gendisk *bd_disk, struct sg_io_hdr *hdr) | 263 | struct sg_io_hdr *hdr, fmode_t mode) |
265 | { | 264 | { |
266 | unsigned long start_time; | 265 | unsigned long start_time; |
267 | int writing = 0, ret = 0; | 266 | int writing = 0, ret = 0; |
@@ -293,7 +292,7 @@ static int sg_io(struct file *file, struct request_queue *q, | |||
293 | if (!rq) | 292 | if (!rq) |
294 | return -ENOMEM; | 293 | return -ENOMEM; |
295 | 294 | ||
296 | if (blk_fill_sghdr_rq(q, rq, hdr, file)) { | 295 | if (blk_fill_sghdr_rq(q, rq, hdr, mode)) { |
297 | blk_put_request(rq); | 296 | blk_put_request(rq); |
298 | return -EFAULT; | 297 | return -EFAULT; |
299 | } | 298 | } |
@@ -565,7 +564,7 @@ int scsi_cmd_ioctl(struct file *file, struct request_queue *q, | |||
565 | err = -EFAULT; | 564 | err = -EFAULT; |
566 | if (copy_from_user(&hdr, arg, sizeof(hdr))) | 565 | if (copy_from_user(&hdr, arg, sizeof(hdr))) |
567 | break; | 566 | break; |
568 | err = sg_io(file, q, bd_disk, &hdr); | 567 | err = sg_io(q, bd_disk, &hdr, file ? file->f_mode : 0); |
569 | if (err == -EFAULT) | 568 | if (err == -EFAULT) |
570 | break; | 569 | break; |
571 | 570 | ||
@@ -613,7 +612,7 @@ int scsi_cmd_ioctl(struct file *file, struct request_queue *q, | |||
613 | hdr.cmdp = ((struct cdrom_generic_command __user*) arg)->cmd; | 612 | hdr.cmdp = ((struct cdrom_generic_command __user*) arg)->cmd; |
614 | hdr.cmd_len = sizeof(cgc.cmd); | 613 | hdr.cmd_len = sizeof(cgc.cmd); |
615 | 614 | ||
616 | err = sg_io(file, q, bd_disk, &hdr); | 615 | err = sg_io(q, bd_disk, &hdr, file ? file->f_mode : 0); |
617 | if (err == -EFAULT) | 616 | if (err == -EFAULT) |
618 | break; | 617 | break; |
619 | 618 | ||