aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAl Viro <viro@zeniv.linux.org.uk>2008-09-02 17:16:41 -0400
committerAl Viro <viro@zeniv.linux.org.uk>2008-10-21 07:47:12 -0400
commite915e872ed921d707bc32b3f2184d43abfa8c9e2 (patch)
tree698142e0a56622c3a3c0740522537dbff703732a
parent5842e51ff2e8d660756248db80ad24e4f41977d9 (diff)
[PATCH] switch sg_scsi_ioctl() to passing fmode_t
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
-rw-r--r--block/scsi_ioctl.c13
-rw-r--r--drivers/scsi/scsi_ioctl.c2
-rw-r--r--drivers/scsi/sg.c2
-rw-r--r--include/linux/blkdev.h4
4 files changed, 8 insertions, 13 deletions
diff --git a/block/scsi_ioctl.c b/block/scsi_ioctl.c
index 9a441559118d..375e25df8adc 100644
--- a/block/scsi_ioctl.c
+++ b/block/scsi_ioctl.c
@@ -379,12 +379,11 @@ out:
379 * bytes in one int) where the lowest byte is the SCSI status. 379 * bytes in one int) where the lowest byte is the SCSI status.
380 */ 380 */
381#define OMAX_SB_LEN 16 /* For backward compatibility */ 381#define OMAX_SB_LEN 16 /* For backward compatibility */
382int sg_scsi_ioctl(struct file *file, struct request_queue *q, 382int sg_scsi_ioctl(struct request_queue *q, struct gendisk *disk, fmode_t mode,
383 struct gendisk *disk, struct scsi_ioctl_command __user *sic) 383 struct scsi_ioctl_command __user *sic)
384{ 384{
385 struct request *rq; 385 struct request *rq;
386 int err; 386 int err;
387 fmode_t write_perm = 0;
388 unsigned int in_len, out_len, bytes, opcode, cmdlen; 387 unsigned int in_len, out_len, bytes, opcode, cmdlen;
389 char *buffer = NULL, sense[SCSI_SENSE_BUFFERSIZE]; 388 char *buffer = NULL, sense[SCSI_SENSE_BUFFERSIZE];
390 389
@@ -426,11 +425,7 @@ int sg_scsi_ioctl(struct file *file, struct request_queue *q,
426 if (in_len && copy_from_user(buffer, sic->data + cmdlen, in_len)) 425 if (in_len && copy_from_user(buffer, sic->data + cmdlen, in_len))
427 goto error; 426 goto error;
428 427
429 /* scsi_ioctl passes NULL */ 428 err = blk_verify_command(&q->cmd_filter, rq->cmd, mode & FMODE_WRITE);
430 if (file && (file->f_mode & FMODE_WRITE))
431 write_perm = FMODE_WRITE;
432
433 err = blk_verify_command(&q->cmd_filter, rq->cmd, write_perm);
434 if (err) 429 if (err)
435 goto error; 430 goto error;
436 431
@@ -636,7 +631,7 @@ int scsi_cmd_ioctl(struct file *file, struct request_queue *q,
636 if (!arg) 631 if (!arg)
637 break; 632 break;
638 633
639 err = sg_scsi_ioctl(file, q, bd_disk, arg); 634 err = sg_scsi_ioctl(q, bd_disk, file ? file->f_mode : 0, arg);
640 break; 635 break;
641 case CDROMCLOSETRAY: 636 case CDROMCLOSETRAY:
642 err = blk_send_start_stop(q, bd_disk, 0x03); 637 err = blk_send_start_stop(q, bd_disk, 0x03);
diff --git a/drivers/scsi/scsi_ioctl.c b/drivers/scsi/scsi_ioctl.c
index 28b19ef26309..1f08f5a2f8fd 100644
--- a/drivers/scsi/scsi_ioctl.c
+++ b/drivers/scsi/scsi_ioctl.c
@@ -237,7 +237,7 @@ int scsi_ioctl(struct scsi_device *sdev, int cmd, void __user *arg)
237 case SCSI_IOCTL_SEND_COMMAND: 237 case SCSI_IOCTL_SEND_COMMAND:
238 if (!capable(CAP_SYS_ADMIN) || !capable(CAP_SYS_RAWIO)) 238 if (!capable(CAP_SYS_ADMIN) || !capable(CAP_SYS_RAWIO))
239 return -EACCES; 239 return -EACCES;
240 return sg_scsi_ioctl(NULL, sdev->request_queue, NULL, arg); 240 return sg_scsi_ioctl(sdev->request_queue, NULL, 0, arg);
241 case SCSI_IOCTL_DOORLOCK: 241 case SCSI_IOCTL_DOORLOCK:
242 return scsi_set_medium_removal(sdev, SCSI_REMOVAL_PREVENT); 242 return scsi_set_medium_removal(sdev, SCSI_REMOVAL_PREVENT);
243 case SCSI_IOCTL_DOORUNLOCK: 243 case SCSI_IOCTL_DOORUNLOCK:
diff --git a/drivers/scsi/sg.c b/drivers/scsi/sg.c
index 93bd59a1ed79..9adf35bd8b56 100644
--- a/drivers/scsi/sg.c
+++ b/drivers/scsi/sg.c
@@ -1059,7 +1059,7 @@ sg_ioctl(struct inode *inode, struct file *filp,
1059 if (sg_allow_access(filp, &opcode)) 1059 if (sg_allow_access(filp, &opcode))
1060 return -EPERM; 1060 return -EPERM;
1061 } 1061 }
1062 return sg_scsi_ioctl(filp, sdp->device->request_queue, NULL, p); 1062 return sg_scsi_ioctl(sdp->device->request_queue, NULL, filp->f_mode, p);
1063 case SG_SET_DEBUG: 1063 case SG_SET_DEBUG:
1064 result = get_user(val, ip); 1064 result = get_user(val, ip);
1065 if (result) 1065 if (result)
diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
index a4413ec3cb3a..8945c30e9936 100644
--- a/include/linux/blkdev.h
+++ b/include/linux/blkdev.h
@@ -719,8 +719,8 @@ extern int blk_remove_plug(struct request_queue *);
719extern void blk_recount_segments(struct request_queue *, struct bio *); 719extern void blk_recount_segments(struct request_queue *, struct bio *);
720extern int scsi_cmd_ioctl(struct file *, struct request_queue *, 720extern int scsi_cmd_ioctl(struct file *, struct request_queue *,
721 struct gendisk *, unsigned int, void __user *); 721 struct gendisk *, unsigned int, void __user *);
722extern int sg_scsi_ioctl(struct file *, struct request_queue *, 722extern int sg_scsi_ioctl(struct request_queue *, struct gendisk *, fmode_t,
723 struct gendisk *, struct scsi_ioctl_command __user *); 723 struct scsi_ioctl_command __user *);
724 724
725/* 725/*
726 * Temporary export, until SCSI gets fixed up. 726 * Temporary export, until SCSI gets fixed up.