21 static int sg_version_num = 30534;
22 #define SG_VERSION_STR "3.5.34"
31 #include <linux/module.h>
34 #include <linux/kernel.h>
35 #include <linux/sched.h>
36 #include <linux/string.h>
38 #include <linux/errno.h>
41 #include <linux/slab.h>
42 #include <linux/fcntl.h>
44 #include <linux/poll.h>
51 #include <linux/blktrace_api.h>
64 #ifdef CONFIG_SCSI_PROC_FS
66 static char *sg_version_date =
"20061027";
68 static int sg_proc_init(
void);
69 static void sg_proc_cleanup(
void);
72 #define SG_ALLOW_DIO_DEF 0
74 #define SG_MAX_DEVS 32768
85 #define MULDIV(X,MUL,DIV) ((((X % DIV) * MUL) / DIV) + ((X / DIV) * MUL))
87 #define SG_DEFAULT_TIMEOUT MULDIV(SG_DEFAULT_TIMEOUT_USER, HZ, USER_HZ)
96 static int def_reserved_size = -1;
102 #define SG_SECTOR_SZ 512
115 .remove_dev = sg_remove,
187 static void sg_rq_end_io(
struct request *
rq,
int uptodate);
188 static int sg_start_req(
Sg_request *srp,
unsigned char *
cmd);
189 static int sg_finish_rem_req(
Sg_request * srp);
194 const char __user *
buf,
size_t count,
int blocking,
197 unsigned char *cmnd,
int timeout,
int blocking);
198 static int sg_read_oxfer(
Sg_request * srp,
char __user *
outp,
int num_read_xfer);
200 static void sg_build_reserve(
Sg_fd * sfp,
int req_size);
204 static void sg_remove_sfp(
struct kref *);
208 static int sg_res_in_use(
Sg_fd * sfp);
212 #define SZ_SG_HEADER sizeof(struct sg_header)
213 #define SZ_SG_IO_HDR sizeof(sg_io_hdr_t)
214 #define SZ_SG_IOVEC sizeof(sg_iovec_t)
215 #define SZ_SG_REQ_INFO sizeof(sg_req_info_t)
217 static int sg_allow_access(
struct file *filp,
unsigned char *
cmd)
234 spin_unlock_irqrestore(&sg_open_exclusive_lock, flags);
244 spin_unlock_irqrestore(&sg_open_exclusive_lock, flags);
248 static int sfds_list_empty(
Sg_device *sdp)
254 ret = list_empty(&sdp->
sfds);
262 int dev = iminor(inode);
272 sdp = sg_get_dev(dev);
274 retval = PTR_ERR(sdp);
285 retval = scsi_autopm_get_device(sdp->
device);
301 if (!sfds_list_empty(sdp) && (flags & O_NONBLOCK)) {
306 ((!sfds_list_empty(sdp) || get_exclude(sdp)) ? 0 : set_exclude(sdp, 1)));
311 }
else if (get_exclude(sdp)) {
312 if (flags & O_NONBLOCK) {
326 if (sfds_list_empty(sdp)) {
328 q = sdp->
device->request_queue;
331 if ((sfp = sg_add_sfp(sdp, dev)))
334 if (flags & O_EXCL) {
344 scsi_autopm_put_device(sdp->
device);
356 sg_release(
struct inode *inode,
struct file *filp)
368 scsi_autopm_put_device(sdp->
device);
369 kref_put(&sfp->
f_ref, sg_remove_sfp);
374 sg_read(
struct file *filp,
char __user *
buf,
size_t count, loff_t * ppos)
379 int req_pack_id = -1;
387 sdp->
disk->disk_name, (
int) count));
409 req_pack_id = new_hdr->
pack_id;
417 req_pack_id = old_hdr->
pack_id;
419 srp = sg_get_rq_mark(sfp, req_pack_id);
425 if (filp->
f_flags & O_NONBLOCK) {
431 (srp = sg_get_rq_mark(sfp, req_pack_id))));
442 retval = sg_new_read(sfp, buf, count, srp);
447 if (old_hdr ==
NULL) {
512 count = (old_hdr->
result == 0) ? 0 : -
EIO;
513 sg_finish_rem_req(srp);
521 sg_new_read(
Sg_fd * sfp,
char __user *buf,
size_t count,
Sg_request * srp)
537 len = 8 + (
int) srp->
sense_b[7];
538 len = (len > sb_len) ? sb_len : len;
553 err = sg_finish_rem_req(srp);
554 return (0 == err) ? count :
err;
558 sg_write(
struct file *filp,
const char __user *buf,
size_t count, loff_t * ppos)
561 int input_size, blocking;
573 sdp->
disk->disk_name, (
int) count));
576 if (!((filp->
f_flags & O_NONBLOCK) ||
588 return sg_new_write(sfp, filp, buf, count,
589 blocking, 0, 0,
NULL);
593 if (!(srp = sg_add_request(sfp))) {
603 sg_remove_request(sfp, srp);
614 "sg_write: scsi opcode=0x%02x, cmd_size=%d\n", (
int) opcode, cmd_size));
620 if (input_size < 0) {
621 sg_remove_request(sfp, srp);
626 hp->cmd_len = (
unsigned char) cmd_size;
634 hp->dxfer_len = mxsize;
636 hp->dxferp = (
char __user *)buf + cmd_size;
641 hp->flags = input_size;
655 "sg_write: data in/out %d/%d bytes "
656 "for SCSI command 0x%x-- guessing "
657 "data in;\n program %s not setting "
658 "count and/or reply_len properly\n",
660 input_size, (
unsigned int) cmnd[0],
665 k = sg_common_write(sfp, srp, cmnd, sfp->
timeout, blocking);
666 return (k < 0) ? k :
count;
670 sg_new_write(
Sg_fd *sfp,
struct file *
file,
const char __user *buf,
671 size_t count,
int blocking,
int read_only,
int sg_io_owned,
679 unsigned long ul_timeout;
687 if (!(srp = sg_add_request(sfp))) {
694 sg_remove_request(sfp, srp);
698 sg_remove_request(sfp, srp);
703 sg_remove_request(sfp, srp);
707 sg_remove_request(sfp, srp);
710 if (sg_res_in_use(sfp)) {
711 sg_remove_request(sfp, srp);
718 sg_remove_request(sfp, srp);
722 sg_remove_request(sfp, srp);
726 sg_remove_request(sfp, srp);
729 if (read_only && sg_allow_access(file, cmnd)) {
730 sg_remove_request(sfp, srp);
733 k = sg_common_write(sfp, srp, cmnd, timeout, blocking);
743 unsigned char *cmnd,
int timeout,
int blocking)
758 (
int) cmnd[0], (
int) hp->
cmd_len));
760 k = sg_start_req(srp, cmnd);
763 sg_finish_rem_req(srp);
769 sg_finish_rem_req(srp);
790 srp->
rq->timeout = timeout;
791 kref_get(&sfp->
f_ref);
793 srp->
rq, 1, sg_rq_end_io);
809 sg_ioctl(
struct file *filp,
unsigned int cmd_in,
unsigned long arg)
817 unsigned long iflags;
823 sdp->
disk->disk_name, (
int) cmd_in));
835 1, read_only, 1, &srp);
839 (srp_done(sfp, srp) || sdp->
detached));
847 return (result < 0) ? result : 0;
873 if ((0 == sfp->
low_dma) && (0 == sg_res_in_use(sfp))) {
876 sg_build_reserve(sfp, val);
902 &sg_idp->h_cmd_per_lun);
904 &sg_idp->d_queue_depth);
932 for (val = 0, srp = sfp->
headrp; srp; srp = srp->
nextrp) {
946 val =
min_t(
int, val,
947 queue_max_sectors(sdp->
device->request_queue) * 512);
952 sg_build_reserve(sfp, val);
957 queue_max_sectors(sdp->
device->request_queue) * 512);
963 sfp->
cmd_q = val ? 1 : 0;
982 return put_user(sg_version_num, ip);
985 val = (sdp->
device ? 1 : 0);
999 for (srp = sfp->
headrp, val = 0; val < SG_MAX_QUEUE;
1000 ++val, srp = srp ? srp->
nextrp : srp) {
1005 srp->header.masked_status &
1006 srp->header.host_status &
1007 srp->header.driver_status;
1010 srp->header.duration;
1014 (ms > srp->header.duration) ?
1015 (ms - srp->header.duration) : 0;
1021 srp->header.pack_id;
1023 srp->header.usr_ptr;
1029 result = result ? -
EFAULT : 0;
1040 if (filp->
f_flags & O_NONBLOCK) {
1041 if (scsi_host_in_recovery(sdp->
device->host))
1074 unsigned char opcode =
WRITE_6;
1075 Scsi_Ioctl_Command
__user *siocp =
p;
1079 if (sg_allow_access(filp, &opcode))
1097 return put_user(queue_max_sectors(sdp->
device->request_queue) * 512,
1101 sdp->
disk->disk_name,
1118 #ifdef CONFIG_COMPAT
1119 static long sg_compat_ioctl(
struct file *filp,
unsigned int cmd_in,
unsigned long arg)
1129 if (sdev->
host->hostt->compat_ioctl) {
1132 ret = sdev->
host->hostt->compat_ioctl(sdev, cmd_in, (
void __user *)arg);
1144 unsigned int res = 0;
1149 unsigned long iflags;
1169 else if (!sfp->
cmd_q) {
1172 }
else if (count < SG_MAX_QUEUE)
1175 sdp->
disk->disk_name, (
int) res));
1180 sg_fasync(
int fd,
struct file *filp,
int mode)
1188 sdp->
disk->disk_name, mode));
1202 return VM_FAULT_SIGBUS;
1205 if (offset >= rsv_schp->
bufflen)
1206 return VM_FAULT_SIGBUS;
1213 len = (len <
length) ? len : length;
1225 return VM_FAULT_SIGBUS;
1228 static const struct vm_operations_struct sg_mmap_vm_ops = {
1229 .fault = sg_vma_fault,
1236 unsigned long req_sz, len,
sa;
1244 (
void *) vma->
vm_start, (
int) req_sz));
1248 if (req_sz > rsv_schp->
bufflen)
1255 len = (len <
length) ? len : length;
1260 vma->
vm_flags |= VM_DONTEXPAND | VM_DONTDUMP;
1262 vma->
vm_ops = &sg_mmap_vm_ops;
1271 sg_finish_rem_req(srp);
1272 kref_put(&sfp->
f_ref, sg_remove_sfp);
1279 static void sg_rq_end_io(
struct request *
rq,
int uptodate)
1284 unsigned long iflags;
1301 result = rq->errors;
1302 resid = rq->resid_len;
1327 && !scsi_sense_is_deferred(&sshdr)
1329 && sdp->
device->removable) {
1332 sdp->
device->changed = 1;
1353 kref_put(&sfp->
f_ref, sg_remove_sfp);
1355 INIT_WORK(&srp->
ew.work, sg_rq_end_io_usercontext);
1365 .unlocked_ioctl = sg_ioctl,
1366 #ifdef CONFIG_COMPAT
1367 .compat_ioctl = sg_compat_ioctl,
1371 .release = sg_release,
1372 .fasync = sg_fasync,
1376 static struct class *sg_sysfs_class;
1378 static int sg_sysfs_valid = 0;
1384 unsigned long iflags;
1414 sprintf(disk->disk_name,
"sg%d", k);
1415 disk->first_minor =
k;
1418 INIT_LIST_HEAD(&sdp->
sfds);
1422 kref_init(&sdp->
d_ref);
1430 return ERR_PTR(error);
1438 "Unable to attach sg device type=%d, minor "
1448 struct gendisk *disk;
1452 unsigned long iflags;
1468 cdev->
ops = &sg_fops;
1470 sdp = sg_alloc(disk, scsidp);
1473 error = PTR_ERR(sdp);
1482 if (sg_sysfs_valid) {
1483 struct device *sg_class_member;
1488 sdp,
"%s", disk->disk_name);
1489 if (IS_ERR(sg_class_member)) {
1491 "device_create failed\n");
1492 error = PTR_ERR(sg_class_member);
1496 &sg_class_member->
kobj,
"generic");
1499 "'generic' back to sg%d\n", sdp->
index);
1504 "Attached scsi generic sg%d type %d\n", sdp->
index,
1524 static void sg_device_destroy(
struct kref *
kref)
1527 unsigned long flags;
1539 printk(
"sg_device_destroy: %s\n",
1540 sdp->
disk->disk_name));
1550 unsigned long iflags;
1587 "size (default: max(SG_SCATTER_SZ, PAGE_SIZE))");
1588 MODULE_PARM_DESC(def_reserved_size,
"size of buffer reserved for each fd");
1598 scatter_elem_sz_prev = scatter_elem_sz;
1600 if (def_reserved_size >= 0)
1610 if ( IS_ERR(sg_sysfs_class) ) {
1611 rc = PTR_ERR(sg_sysfs_class);
1617 #ifdef CONFIG_SCSI_PROC_FS
1631 #ifdef CONFIG_SCSI_PROC_FS
1642 static int sg_start_req(
Sg_request *srp,
unsigned char *cmd)
1654 struct rq_map_data *
md, map_data;
1667 rq->cmd_type = REQ_TYPE_BLOCK_PC;
1670 rq->end_io_data = srp;
1679 !sfp->
parentdp->device->host->unchecked_isa_dma &&
1680 blk_rq_aligned(q, (
unsigned long)hp->
dxferp, dxfer_len))
1686 if (!sg_res_in_use(sfp) && dxfer_len <= rsv_schp->
bufflen)
1687 sg_link_reserve(sfp, srp, dxfer_len);
1689 res = sg_build_indirect(req_schp, sfp, dxfer_len);
1694 md->pages = req_schp->pages;
1695 md->page_order = req_schp->page_order;
1696 md->nr_entries = req_schp->k_use_sg;
1698 md->null_mapped = hp->
dxferp ? 0 : 1;
1711 return PTR_ERR(iov);
1713 len = iov_length(iov, iov_count);
1731 req_schp->dio_in_use = 1;
1738 static int sg_finish_rem_req(
Sg_request * srp)
1754 sg_unlink_reserve(sfp, srp);
1756 sg_remove_scat(req_schp);
1758 sg_remove_request(sfp, srp);
1766 int sg_bufflen = tablesize *
sizeof(
struct page *);
1769 schp->
pages = kzalloc(sg_bufflen, gfp_flags);
1779 int ret_sz = 0,
i,
k, rem_sz,
num, mx_sc_elems;
1780 int sg_tablesize = sfp->
parentdp->sg_tablesize;
1791 buff_size, blk_size));
1794 mx_sc_elems = sg_build_sgat(schp, sfp, sg_tablesize);
1795 if (mx_sc_elems < 0)
1798 num = scatter_elem_sz;
1799 if (
unlikely(num != scatter_elem_sz_prev)) {
1804 scatter_elem_sz_prev = num;
1817 for (k = 0, rem_sz = blk_size; rem_sz > 0 && k < mx_sc_elems;
1818 k++, rem_sz -= ret_sz) {
1820 num = (rem_sz > scatter_elem_sz_prev) ?
1821 scatter_elem_sz_prev : rem_sz;
1824 if (!schp->
pages[k])
1827 if (num == scatter_elem_sz_prev) {
1828 if (
unlikely(ret_sz > scatter_elem_sz_prev)) {
1829 scatter_elem_sz = ret_sz;
1830 scatter_elem_sz_prev = ret_sz;
1835 "ret_sz=%d\n", k, num, ret_sz));
1841 "rem_sz=%d\n", k, rem_sz));
1848 for (
i = 0;
i <
k;
i++)
1867 "sg_remove_scat: k=%d, pg=0x%p\n",
1868 k, schp->
pages[k]));
1875 memset(schp, 0,
sizeof (*schp));
1879 sg_read_oxfer(
Sg_request * srp,
char __user *
outp,
int num_read_xfer)
1886 if ((!outp) || (num_read_xfer <= 0))
1891 if (num > num_read_xfer) {
1900 num_read_xfer -= num;
1901 if (num_read_xfer <= 0)
1911 sg_build_reserve(
Sg_fd * sfp,
int req_size)
1919 if (0 == sg_build_indirect(schp, sfp, req_size))
1922 sg_remove_scat(schp);
1939 for (k = 0; k < rsv_schp->
k_use_sg; k++) {
1973 sg_get_rq_mark(
Sg_fd * sfp,
int pack_id)
1976 unsigned long iflags;
1993 sg_add_request(
Sg_fd * sfp)
1996 unsigned long iflags;
2008 if (0 == sfp->
cmd_q)
2015 if (k < SG_MAX_QUEUE) {
2040 unsigned long iflags;
2043 if ((!sfp) || (!srp) || (!sfp->
headrp))
2047 if (srp == prev_rp) {
2052 while ((rp = prev_rp->
nextrp)) {
2070 unsigned long iflags;
2080 kref_init(&sfp->
f_ref);
2085 sdp->
device->host->unchecked_isa_dma : 1;
2097 queue_max_sectors(sdp->
device->request_queue) * 512);
2098 sg_build_reserve(sfp, bufflen);
2102 kref_get(&sdp->
d_ref);
2114 sg_finish_rem_req(sfp->
headrp);
2118 printk(
"sg_remove_sfp: bufflen=%d, k_use_sg=%d\n",
2121 sg_remove_scat(&sfp->
reserve);
2125 printk(
"sg_remove_sfp: %s, sfp=0x%p\n",
2126 sdp->
disk->disk_name,
2135 static void sg_remove_sfp(
struct kref *kref)
2139 unsigned long iflags;
2146 INIT_WORK(&sfp->
ew.work, sg_remove_sfp_usercontext);
2151 sg_res_in_use(
Sg_fd * sfp)
2154 unsigned long iflags;
2164 #ifdef CONFIG_SCSI_PROC_FS
2166 sg_idr_max_id(
int id,
void *p,
void *
data)
2180 unsigned long iflags;
2190 static Sg_device *sg_lookup_dev(
int dev)
2192 return idr_find(&sg_index_idr, dev);
2198 unsigned long flags;
2201 sdp = sg_lookup_dev(dev);
2203 sdp = ERR_PTR(-
ENXIO);
2210 kref_get(&sdp->
d_ref);
2216 static void sg_put_dev(
struct sg_device *sdp)
2218 kref_put(&sdp->
d_ref, sg_device_destroy);
2221 #ifdef CONFIG_SCSI_PROC_FS
2225 static char sg_proc_sg_dirname[] =
"scsi/sg";
2227 static int sg_proc_seq_show_int(
struct seq_file *
s,
void *
v);
2229 static int sg_proc_single_open_adio(
struct inode *inode,
struct file *file);
2230 static ssize_t sg_proc_write_adio(
struct file *filp,
const char __user *
buffer,
2231 size_t count, loff_t *off);
2234 .open = sg_proc_single_open_adio,
2237 .write = sg_proc_write_adio,
2241 static int sg_proc_single_open_dressz(
struct inode *inode,
struct file *file);
2242 static ssize_t sg_proc_write_dressz(
struct file *filp,
2243 const char __user *
buffer,
size_t count, loff_t *off);
2246 .open = sg_proc_single_open_dressz,
2249 .write = sg_proc_write_dressz,
2253 static int sg_proc_seq_show_version(
struct seq_file *
s,
void *
v);
2254 static int sg_proc_single_open_version(
struct inode *inode,
struct file *file);
2257 .open = sg_proc_single_open_version,
2263 static int sg_proc_seq_show_devhdr(
struct seq_file *
s,
void *
v);
2264 static int sg_proc_single_open_devhdr(
struct inode *inode,
struct file *file);
2267 .open = sg_proc_single_open_devhdr,
2273 static int sg_proc_seq_show_dev(
struct seq_file *
s,
void *
v);
2274 static int sg_proc_open_dev(
struct inode *inode,
struct file *file);
2275 static void * dev_seq_start(
struct seq_file *
s, loff_t *
pos);
2276 static void * dev_seq_next(
struct seq_file *
s,
void *
v, loff_t *
pos);
2277 static void dev_seq_stop(
struct seq_file *
s,
void *
v);
2280 .open = sg_proc_open_dev,
2286 .
start = dev_seq_start,
2287 .next = dev_seq_next,
2288 .stop = dev_seq_stop,
2289 .show = sg_proc_seq_show_dev,
2292 static int sg_proc_seq_show_devstrs(
struct seq_file *
s,
void *
v);
2293 static int sg_proc_open_devstrs(
struct inode *inode,
struct file *file);
2296 .open = sg_proc_open_devstrs,
2302 .
start = dev_seq_start,
2303 .next = dev_seq_next,
2304 .stop = dev_seq_stop,
2305 .show = sg_proc_seq_show_devstrs,
2308 static int sg_proc_seq_show_debug(
struct seq_file *
s,
void *
v);
2309 static int sg_proc_open_debug(
struct inode *inode,
struct file *file);
2312 .open = sg_proc_open_debug,
2318 .
start = dev_seq_start,
2319 .next = dev_seq_next,
2320 .stop = dev_seq_stop,
2321 .show = sg_proc_seq_show_debug,
2325 struct sg_proc_leaf {
2330 static const struct sg_proc_leaf sg_proc_leaf_arr[] = {
2331 {
"allow_dio", &adio_fops},
2332 {
"debug", &debug_fops},
2333 {
"def_reserved_size", &dressz_fops},
2334 {
"device_hdr", &devhdr_fops},
2335 {
"devices", &dev_fops},
2336 {
"device_strs", &devstrs_fops},
2337 {
"version", &version_fops}
2343 int num_leaves =
ARRAY_SIZE(sg_proc_leaf_arr);
2349 for (k = 0; k < num_leaves; ++
k) {
2350 const struct sg_proc_leaf *
leaf = &sg_proc_leaf_arr[
k];
2352 proc_create(leaf->name, mask, sg_proc_sgp, leaf->fops);
2358 sg_proc_cleanup(
void)
2361 int num_leaves =
ARRAY_SIZE(sg_proc_leaf_arr);
2365 for (k = 0; k < num_leaves; ++
k)
2371 static int sg_proc_seq_show_int(
struct seq_file *
s,
void *
v)
2377 static int sg_proc_single_open_adio(
struct inode *inode,
struct file *file)
2379 return single_open(file, sg_proc_seq_show_int, &sg_allow_dio);
2383 sg_proc_write_adio(
struct file *filp,
const char __user *
buffer,
2384 size_t count, loff_t *off)
2394 sg_allow_dio = num ? 1 : 0;
2398 static int sg_proc_single_open_dressz(
struct inode *inode,
struct file *file)
2404 sg_proc_write_dressz(
struct file *filp,
const char __user *buffer,
2405 size_t count, loff_t *off)
2423 static int sg_proc_seq_show_version(
struct seq_file *s,
void *v)
2430 static int sg_proc_single_open_version(
struct inode *inode,
struct file *file)
2435 static int sg_proc_seq_show_devhdr(
struct seq_file *s,
void *v)
2437 seq_printf(s,
"host\tchan\tid\tlun\ttype\topens\tqdepth\tbusy\t"
2442 static int sg_proc_single_open_devhdr(
struct inode *inode,
struct file *file)
2447 struct sg_proc_deviter {
2452 static void * dev_seq_start(
struct seq_file *s, loff_t *
pos)
2461 it->max = sg_last_dev();
2462 if (it->index >= it->max)
2467 static void * dev_seq_next(
struct seq_file *s,
void *v, loff_t *pos)
2469 struct sg_proc_deviter * it = s->
private;
2472 return (it->index < it->max) ? it :
NULL;
2475 static void dev_seq_stop(
struct seq_file *s,
void *v)
2480 static int sg_proc_open_dev(
struct inode *inode,
struct file *file)
2482 return seq_open(file, &dev_seq_ops);
2485 static int sg_proc_seq_show_dev(
struct seq_file *s,
void *v)
2487 struct sg_proc_deviter * it = (
struct sg_proc_deviter *) v;
2490 unsigned long iflags;
2493 sdp = it ? sg_lookup_dev(it->index) :
NULL;
2495 seq_printf(s,
"%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\n",
2497 scsidp->
id, scsidp->
lun, (
int) scsidp->
type,
2501 (
int) scsi_device_online(scsidp));
2503 seq_printf(s,
"-1\t-1\t-1\t-1\t-1\t-1\t-1\t-1\t-1\n");
2508 static int sg_proc_open_devstrs(
struct inode *inode,
struct file *file)
2510 return seq_open(file, &devstrs_seq_ops);
2513 static int sg_proc_seq_show_devstrs(
struct seq_file *s,
void *v)
2515 struct sg_proc_deviter * it = (
struct sg_proc_deviter *) v;
2518 unsigned long iflags;
2521 sdp = it ? sg_lookup_dev(it->index) :
NULL;
2534 int k,
m, new_interface, blen, usg;
2545 seq_printf(s,
" FD(%d): timeout=%dms bufflen=%d "
2546 "(res)sgat=%d low_dma=%d\n", k,
2551 seq_printf(s,
" cmd_q=%d f_packid=%d k_orphan=%d closed=0\n",
2554 for (m = 0, srp = fp->
headrp;
2556 ++m, srp = srp->
nextrp) {
2560 if (new_interface &&
2575 ((1 == srp->
done) ?
"rcv:" :
"fin:")
2584 (new_interface ? hp->
timeout :
2597 static int sg_proc_open_debug(
struct inode *inode,
struct file *file)
2599 return seq_open(file, &debug_seq_ops);
2602 static int sg_proc_seq_show_debug(
struct seq_file *s,
void *v)
2604 struct sg_proc_deviter * it = (
struct sg_proc_deviter *) v;
2606 unsigned long iflags;
2608 if (it && (0 == it->index)) {
2609 seq_printf(s,
"max_active_device=%d(origin 1)\n",
2615 sdp = it ? sg_lookup_dev(it->index) :
NULL;
2616 if (sdp && !list_empty(&sdp->
sfds)) {
2624 (s,
"scsi%d chan=%d id=%d lun=%d em=%d",
2625 scsidp->
host->host_no,
2628 scsidp->
host->hostt->emulated);
2631 sg_proc_debug_helper(s, sdp);