Function report

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

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

Name: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

Proto:int sg_scsi_ioctl(struct request_queue *q, struct gendisk *disk, fmode_t mode, struct scsi_ioctl_command __user *sic)

Type:int

Parameter:

TypeParameterName
struct request_queue *q
struct gendisk *disk
fmode_tmode
struct scsi_ioctl_command __user *sic
416  enum{OMAX_SB_LEN = 16}
421  char * buffer = NULL
423  If Not sic Then Return -EINVAL
429  If Get a simple variable from user space(in_len, & inlen) Then Return -EFAULT
431  If Get a simple variable from user space(out_len, & outlen) Then Return -EFAULT
433  If in_len > PAGE_SIZE || out_len > PAGE_SIZE Then Return -EINVAL
435  If Get a simple variable from user space(opcode, data) Then Return -EFAULT
438  bytes = max - return maximum of two values of the same or compatible types*@x: first value*@y: second value(in_len, out_len)
439  If bytes Then
440  buffer = kzalloc - allocate memory. The memory is set to zero.*@size: how many bytes of memory are required.*@flags: the type of memory to allocate (see kmalloc).
441  If Not buffer Then Return -ENOMEM
446  rq = lk_get_request - allocate a request*@q: request queue to allocate a request for*@op: operation (REQ_OP_*) and REQ_* flags, e.g. REQ_SYNC.*@flags: BLK_MQ_REQ_* flags, e.g. BLK_MQ_REQ_NOWAIT.
447  If IS_ERR(rq) Then
448  err = PTR_ERR(rq)
449  Go to error_free_buffer
451  req = scsi_req(rq)
453  cmdlen = COMMAND_SIZE(opcode)
458  err = -EFAULT
459  cmd_len = cmdlen
460  If copy_from_user(cmd, data, cmdlen) Then Go to error
463  If in_len && copy_from_user(buffer, data + cmdlen, in_len) Then Go to error
466  err = blk_verify_command(cmd, mode)
467  If err Then Go to error
471  retries = 5
474  Case opcode == SEND_DIAGNOSTIC
475  Case opcode == FORMAT_UNIT
476  timeout = default timeouts
477  retries = 1
478  Break
479  Case opcode == START_STOP
480  timeout = START_STOP_TIMEOUT
481  Break
482  Case opcode == MOVE_MEDIUM
483  timeout = MOVE_MEDIUM_TIMEOUT
484  Break
485  Case opcode == READ_ELEMENT_STATUS
486  timeout = READ_ELEMENT_STATUS_TIMEOUT
487  Break
488  Case opcode == READ_DEFECT_DATA
489  timeout = READ_DEFECT_DATA_TIMEOUT
490  retries = 1
491  Break
492  Default
493  timeout = default timeout for SG_IO if none specified
494  Break
497  If bytes && lk_rq_map_kern - map kernel data to a request, for passthrough requests*@q: request queue where request should be inserted*@rq: request to fill*@kbuf: the kernel buffer*@len: length of user data*@gfp_mask: memory allocation flags* Description: Then
498  err = DRIVER_ERROR << 24
499  Go to error
502  lk_execute_rq - insert a request into queue for execution*@q: queue to insert the request in*@bd_disk: matching gendisk*@rq: request to insert*@at_head: insert request at head or tail of queue* Description:* Insert a fully prepared request at the back of
504  err = result & 0xff
505  If err Then
506  If sense_len && sense Then
509  If copy_to_user(data, sense, bytes) Then err = -EFAULT
512  Else
513  If copy_to_user(data, buffer, out_len) Then err = -EFAULT
517  error :
518  blk_put_request(rq)
520  error_free_buffer :
521  kfree(buffer)
523  Return err
Caller
NameDescribe
scsi_cmd_ioctl