From 94fe9f959c04586f1f19759af3945534fbfab984 Mon Sep 17 00:00:00 2001 From: Alexander Motin Date: Wed, 4 Jun 2014 12:05:47 +0000 Subject: [PATCH] - Add support for SG_GET_SG_TABLESIZE IOCTL to report that we don't support scatter/gather lists. - Return error for still unsupported SG 3.x API read/write calls. MFC after: 1 month --- sys/cam/scsi/scsi_sg.c | 14 +++++++++++++- sys/compat/linux/linux_ioctl.c | 3 +++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/sys/cam/scsi/scsi_sg.c b/sys/cam/scsi/scsi_sg.c index 715b48a1b885..3e80ac3e763f 100644 --- a/sys/cam/scsi/scsi_sg.c +++ b/sys/cam/scsi/scsi_sg.c @@ -627,6 +627,13 @@ sgioctl(struct cdev *dev, u_long cmd, caddr_t arg, int flag, struct thread *td) break; } + case SG_GET_SG_TABLESIZE: + { + int *size = (int *)arg; + *size = 0; + break; + } + case SG_EMULATED_HOST: case SG_SET_TRANSFORM: case SG_GET_TRANSFORM: @@ -638,7 +645,6 @@ sgioctl(struct cdev *dev, u_long cmd, caddr_t arg, int flag, struct thread *td) case SG_GET_ACCESS_COUNT: case SG_SET_FORCE_LOW_DMA: case SG_GET_LOW_DMA: - case SG_GET_SG_TABLESIZE: case SG_SET_FORCE_PACK_ID: case SG_GET_PACK_ID: case SG_SET_RESERVED_SIZE: @@ -684,6 +690,12 @@ sgwrite(struct cdev *dev, struct uio *uio, int ioflag) if (error) goto out_hdr; + /* XXX: We don't support SG 3.x read/write API. */ + if (hdr->reply_len < 0) { + error = ENODEV; + goto out_hdr; + } + ccb = xpt_alloc_ccb(); if (ccb == NULL) { error = ENOMEM; diff --git a/sys/compat/linux/linux_ioctl.c b/sys/compat/linux/linux_ioctl.c index e1e13716aa1a..77feed0870ee 100644 --- a/sys/compat/linux/linux_ioctl.c +++ b/sys/compat/linux/linux_ioctl.c @@ -2751,6 +2751,9 @@ linux_ioctl_sg(struct thread *td, struct linux_ioctl_args *args) case LINUX_SG_GET_SCSI_ID: args->cmd = SG_GET_SCSI_ID; break; + case LINUX_SG_GET_SG_TABLESIZE: + args->cmd = SG_GET_SG_TABLESIZE; + break; default: return (ENODEV); }