Function report

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

Source Code:block\scsi_ioctl.c Create Date:2022-07-28 17:36:50
Last Modify:2020-03-12 14:18:49 Copyright©Brick
home page Tree
Annotation kernel can get tool activityDownload SCCTChinese

Name:scsi_cmd_ioctl

Proto:int scsi_cmd_ioctl(struct request_queue *q, struct gendisk *bd_disk, fmode_t mode, unsigned int cmd, void __user *arg)

Type:int

Parameter:

TypeParameterName
struct request_queue *q
struct gendisk *bd_disk
fmode_tmode
unsigned intcmd
void __user *arg
647  If Not q Then Return -ENXIO
654  Case cmd == Example: version 2.1.34 yields 20134
655  err = sg_get_version(arg)
656  Break
657  Case cmd == Used to obtain PUN and LUN info. Conflicts with CDROMAUDIOBUFSIZ
658  err = scsi_get_idlun(q, arg)
659  Break
660  Case cmd == Used to obtain the bus number for a device
661  err = scsi_get_bus(q, arg)
662  Break
663  Case cmd == unit: jiffies (10ms on i386)
664  err = sg_set_timeout(q, arg)
665  Break
666  Case cmd == yield timeout as _return_ value
667  err = sg_get_timeout(q)
668  Break
669  Case cmd == actual size of reserved buffer
670  err = sg_get_reserved_size(q, arg)
671  Break
672  Case cmd == quest a new reserved buffer size
673  err = sg_set_reserved_size(q, arg)
674  Break
675  Case cmd == rue for emulated host adapter (ATAPI)
676  err = will always return that we are ATAPI even for a real SCSI drive, I'm not* so sure this is worth doing anything about (why would you care??)
677  Break
678  Case cmd == similar effect as write() followed by read()
681  err = get_sg_io_hdr( & hdr, arg)
682  If err Then Break
684  err = sg_io(q, bd_disk, & hdr, mode)
685  If err == -EFAULT Then Break
688  If put_sg_io_hdr( & hdr, arg) Then err = -EFAULT
690  Break
692  Case cmd == send a packet to the drive
696  err = -EFAULT
697  If copy_from_user( & cgc, arg, size of cgc ) Then Break
699  timeout = clock_t_to_jiffies(timeout)
700  memset( & hdr, 0, size of hdr )
701  [i] 'S' for SCSI generic (required) = 'S'
702  [i] SCSI command length = size of cmd
703  [i] byte count of data transfer = buflen
704  err = 0
708  Break
711  Break
714  Break
717  Break
718  Default
719  err = -EINVAL
721  If err Then Break
724  [i], [*io] points to data transfer memory or scatter gather list = buffer
725  [i], [*o] points to sense_buffer memory = sense
726  If [i], [*o] points to sense_buffer memory Then [i] max length to write to sbp = sizeof(structrequest_sense)
728  [i] MAX_UINT->no timeout (unit: millisec) = Convert jiffies to milliseconds and back.* Avoid unnecessary multiplications/divisions in the* two most common HZ cases:
729  [i], [*i] points to command to perform = cmd
730  [i] SCSI command length = size of cmd
732  err = sg_io(q, bd_disk, & hdr, mode)
733  If err == -EFAULT Then Break
736  If [o] scsi status Then err = -EIO
739  stat = err
740  buflen = [o] dxfer_len - actual_transferred
741  If copy_to_user(arg, & cgc, size of cgc ) Then err = -EFAULT
744  Break
750  Case cmd == SCSI_IOCTL_SEND_COMMAND
751  printk - print a kernel message*@fmt: format string* This is printk(). It can be called from any context. We want it to work.* We try to grab the console_lock. If we succeed, it's easy - we log the* output and call the console drivers
752  err = -EINVAL
753  If Not arg Then Break
756  err = sg_scsi_ioctl -- handle deprecated SCSI_IOCTL_SEND_COMMAND ioctl*@q: request queue to send scsi commands down*@disk: gendisk to operate on (option)*@mode: mode used to open the file through which the ioctl has been* submitted*@sic: userspace structure
757  Break
758  Case cmd == pendant of CDROMEJECT
759  err = blk_send_start_stop(q, bd_disk, 0x03)
760  Break
761  Case cmd == Ejects the cdrom media
762  err = blk_send_start_stop(q, bd_disk, 0x02)
763  Break
764  Default
765  err = -ENOTTY
768  Return err
Caller
NameDescribe
scsi_cmd_blk_ioctl
bsg_ioctl