19 #include <linux/module.h>
21 #include <linux/string.h>
24 #include <linux/errno.h>
29 #include <asm/uaccess.h>
31 #include <scsi/scsi.h>
41 #define PROC_BLOCK_SIZE (3*1024)
64 n = shost->
hostt->proc_info(shost, buffer, start, offset, length, 0);
77 static int proc_scsi_write_proc(
struct file *
file,
const char __user *
buf,
78 unsigned long count,
void *data)
93 ret = shost->
hostt->proc_info(shost, page, &start, 0, count, 1);
155 sht->
proc_dir, proc_scsi_read, shost);
158 "%s\n", __func__, shost->
host_no,
174 if (!shost->
hostt->proc_dir)
188 static int proc_print_scsidevice(
struct device *
dev,
void *data)
199 "Host: scsi%d Channel: %02d Id: %02d Lun: %02d\n Vendor: ",
201 for (i = 0; i < 8; i++) {
202 if (sdev->
vendor[i] >= 0x20)
209 for (i = 0; i < 16; i++) {
210 if (sdev->
model[i] >= 0x20)
217 for (i = 0; i < 4; i++) {
218 if (sdev->
rev[i] >= 0x20)
263 error = shost->
transportt->user_scan(shost, channel,
id, lun);
280 static int scsi_remove_single_device(
uint host,
uint channel,
uint id,
uint lun)
319 static ssize_t proc_scsi_write(
struct file *file,
const char __user *buf,
320 size_t length, loff_t *ppos)
347 if (!
strncmp(
"scsi add-single-device", buffer, 22)) {
355 err = scsi_add_single_device(host, channel,
id, lun);
361 }
else if (!
strncmp(
"scsi remove-single-device", buffer, 25)) {
369 err = scsi_remove_single_device(host, channel,
id, lun);
384 static int always_match(
struct device *dev,
void *data)
389 static inline struct device *next_scsi_device(
struct device *start)
397 static void *scsi_seq_start(
struct seq_file *sfile, loff_t *
pos)
402 while ((dev = next_scsi_device(dev))) {
410 static void *scsi_seq_next(
struct seq_file *sfile,
void *
v, loff_t *pos)
414 return next_scsi_device(v);
417 static void scsi_seq_stop(
struct seq_file *sfile,
void *
v)
422 static int scsi_seq_show(
struct seq_file *sfile,
void *dev)
425 seq_puts(sfile,
"Attached devices:\n");
427 return proc_print_scsidevice(dev, sfile);
431 .start = scsi_seq_start,
432 .next = scsi_seq_next,
433 .stop = scsi_seq_stop,
434 .show = scsi_seq_show
444 static int proc_scsi_open(
struct inode *
inode,
struct file *file)
450 return seq_open(file, &scsi_seq_ops);
455 .open = proc_scsi_open,
457 .write = proc_scsi_write,
473 pde = proc_create(
"scsi/scsi", 0,
NULL, &proc_scsi_operations);