Release 4.7 drivers/scsi/scsi_proc.c
/*
* linux/drivers/scsi/scsi_proc.c
*
* The functions in this file provide an interface between
* the PROC file system and the SCSI device drivers
* It is mainly used for debugging, statistics and to pass
* information directly to the lowlevel driver.
*
* (c) 1995 Michael Neuffer neuffer@goofy.zdv.uni-mainz.de
* Version: 0.99.8 last change: 95/09/13
*
* generic command parser provided by:
* Andreas Heilwagen <crashcar@informatik.uni-koblenz.de>
*
* generic_proc_info() support of xxxx_info() by:
* Michael A. Griffith <grif@acm.org>
*/
#include <linux/module.h>
#include <linux/init.h>
#include <linux/string.h>
#include <linux/mm.h>
#include <linux/proc_fs.h>
#include <linux/errno.h>
#include <linux/blkdev.h>
#include <linux/seq_file.h>
#include <linux/mutex.h>
#include <linux/gfp.h>
#include <asm/uaccess.h>
#include <scsi/scsi.h>
#include <scsi/scsi_device.h>
#include <scsi/scsi_host.h>
#include <scsi/scsi_transport.h>
#include "scsi_priv.h"
#include "scsi_logging.h"
/* 4K page size, but our output routines, use some slack for overruns */
#define PROC_BLOCK_SIZE (3*1024)
static struct proc_dir_entry *proc_scsi;
/* Protect sht->present and sht->proc_dir */
static DEFINE_MUTEX(global_host_template_mutex);
static ssize_t proc_scsi_host_write(struct file *file, const char __user *buf,
size_t count, loff_t *ppos)
{
struct Scsi_Host *shost = PDE_DATA(file_inode(file));
ssize_t ret = -ENOMEM;
char *page;
if (count > PROC_BLOCK_SIZE)
return -EOVERFLOW;
if (!shost->hostt->write_info)
return -EINVAL;
page = (char *)__get_free_page(GFP_KERNEL);
if (page) {
ret = -EFAULT;
if (copy_from_user(page, buf, count))
goto out;
ret = shost->hostt->write_info(shost, page, count);
}
out:
free_page((unsigned long)page);
return ret;
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
al viro | al viro | 135 | 100.00% | 2 | 100.00% |
| Total | 135 | 100.00% | 2 | 100.00% |
static int proc_scsi_show(struct seq_file *m, void *v)
{
struct Scsi_Host *shost = m->private;
return shost->hostt->show_info(m, shost);
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
al viro | al viro | 36 | 100.00% | 1 | 100.00% |
| Total | 36 | 100.00% | 1 | 100.00% |
static int proc_scsi_host_open(struct inode *inode, struct file *file)
{
return single_open_size(file, proc_scsi_show, PDE_DATA(inode),
4 * PAGE_SIZE);
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
al viro | al viro | 33 | 100.00% | 3 | 100.00% |
| Total | 33 | 100.00% | 3 | 100.00% |
static const struct file_operations proc_scsi_fops = {
.open = proc_scsi_host_open,
.release = single_release,
.read = seq_read,
.llseek = seq_lseek,
.write = proc_scsi_host_write
};
/**
* scsi_proc_hostdir_add - Create directory in /proc for a scsi host
* @sht: owner of this directory
*
* Sets sht->proc_dir to the new directory.
*/
void scsi_proc_hostdir_add(struct scsi_host_template *sht)
{
if (!sht->show_info)
return;
mutex_lock(&global_host_template_mutex);
if (!sht->present++) {
sht->proc_dir = proc_mkdir(sht->proc_name, proc_scsi);
if (!sht->proc_dir)
printk(KERN_ERR "%s: proc_mkdir failed for %s\n",
__func__, sht->proc_name);
}
mutex_unlock(&global_host_template_mutex);
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
christoph hellwig | christoph hellwig | 22 | 30.56% | 4 | 28.57% |
mike anderson | mike anderson | 20 | 27.78% | 2 | 14.29% |
pre-git | pre-git | 13 | 18.06% | 4 | 28.57% |
linus torvalds | linus torvalds | 11 | 15.28% | 1 | 7.14% |
arjan van de ven | arjan van de ven | 4 | 5.56% | 1 | 7.14% |
al viro | al viro | 1 | 1.39% | 1 | 7.14% |
harvey harrison | harvey harrison | 1 | 1.39% | 1 | 7.14% |
| Total | 72 | 100.00% | 14 | 100.00% |
/**
* scsi_proc_hostdir_rm - remove directory in /proc for a scsi host
* @sht: owner of directory
*/
void scsi_proc_hostdir_rm(struct scsi_host_template *sht)
{
if (!sht->show_info)
return;
mutex_lock(&global_host_template_mutex);
if (!--sht->present && sht->proc_dir) {
remove_proc_entry(sht->proc_name, proc_scsi);
sht->proc_dir = NULL;
}
mutex_unlock(&global_host_template_mutex);
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
mike anderson | mike anderson | 47 | 79.66% | 1 | 25.00% |
christoph hellwig | christoph hellwig | 7 | 11.86% | 1 | 25.00% |
arjan van de ven | arjan van de ven | 4 | 6.78% | 1 | 25.00% |
al viro | al viro | 1 | 1.69% | 1 | 25.00% |
| Total | 59 | 100.00% | 4 | 100.00% |
/**
* scsi_proc_host_add - Add entry for this host to appropriate /proc dir
* @shost: host to add
*/
void scsi_proc_host_add(struct Scsi_Host *shost)
{
struct scsi_host_template *sht = shost->hostt;
struct proc_dir_entry *p;
char name[10];
if (!sht->proc_dir)
return;
sprintf(name,"%d", shost->host_no);
p = proc_create_data(name, S_IRUGO | S_IWUSR,
sht->proc_dir, &proc_scsi_fops, shost);
if (!p)
printk(KERN_ERR "%s: Failed to register host %d in"
"%s\n", __func__, shost->host_no,
sht->proc_name);
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
mike anderson | mike anderson | 50 | 54.95% | 2 | 25.00% |
al viro | al viro | 25 | 27.47% | 1 | 12.50% |
pre-git | pre-git | 14 | 15.38% | 3 | 37.50% |
christoph hellwig | christoph hellwig | 1 | 1.10% | 1 | 12.50% |
harvey harrison | harvey harrison | 1 | 1.10% | 1 | 12.50% |
| Total | 91 | 100.00% | 8 | 100.00% |
/**
* scsi_proc_host_rm - remove this host's entry from /proc
* @shost: which host
*/
void scsi_proc_host_rm(struct Scsi_Host *shost)
{
char name[10];
if (!shost->hostt->proc_dir)
return;
sprintf(name,"%d", shost->host_no);
remove_proc_entry(name, shost->hostt->proc_dir);
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
mike anderson | mike anderson | 38 | 79.17% | 2 | 40.00% |
christoph hellwig | christoph hellwig | 8 | 16.67% | 2 | 40.00% |
pre-git | pre-git | 2 | 4.17% | 1 | 20.00% |
| Total | 48 | 100.00% | 5 | 100.00% |
/**
* proc_print_scsidevice - return data about this host
* @dev: A scsi device
* @data: &struct seq_file to output to.
*
* Description: prints Host, Channel, Id, Lun, Vendor, Model, Rev, Type,
* and revision.
*/
static int proc_print_scsidevice(struct device *dev, void *data)
{
struct scsi_device *sdev;
struct seq_file *s = data;
int i;
if (!scsi_is_sdev_device(dev))
goto out;
sdev = to_scsi_device(dev);
seq_printf(s,
"Host: scsi%d Channel: %02d Id: %02d Lun: %02llu\n Vendor: ",
sdev->host->host_no, sdev->channel, sdev->id, sdev->lun);
for (i = 0; i < 8; i++) {
if (sdev->vendor[i] >= 0x20)
seq_putc(s, sdev->vendor[i]);
else
seq_putc(s, ' ');
}
seq_puts(s, " Model: ");
for (i = 0; i < 16; i++) {
if (sdev->model[i] >= 0x20)
seq_putc(s, sdev->model[i]);
else
seq_putc(s, ' ');
}
seq_puts(s, " Rev: ");
for (i = 0; i < 4; i++) {
if (sdev->rev[i] >= 0x20)
seq_putc(s, sdev->rev[i]);
else
seq_putc(s, ' ');
}
seq_putc(s, '\n');
seq_printf(s, " Type: %s ", scsi_device_type(sdev->type));
seq_printf(s, " ANSI SCSI revision: %02x",
sdev->scsi_level - (sdev->scsi_level > 1));
if (sdev->scsi_level == 2)
seq_puts(s, " CCS\n");
else
seq_putc(s, '\n');
out:
return 0;
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
christoph hellwig | christoph hellwig | 151 | 51.54% | 3 | 25.00% |
pre-git | pre-git | 98 | 33.45% | 3 | 25.00% |
hannes reinecke | hannes reinecke | 21 | 7.17% | 2 | 16.67% |
rasmus villemoes | rasmus villemoes | 16 | 5.46% | 2 | 16.67% |
alan stern | alan stern | 4 | 1.37% | 1 | 8.33% |
matthew wilcox | matthew wilcox | 3 | 1.02% | 1 | 8.33% |
| Total | 293 | 100.00% | 12 | 100.00% |
/**
* scsi_add_single_device - Respond to user request to probe for/add device
* @host: user-supplied decimal integer
* @channel: user-supplied decimal integer
* @id: user-supplied decimal integer
* @lun: user-supplied decimal integer
*
* Description: called by writing "scsi add-single-device" to /proc/scsi/scsi.
*
* does scsi_host_lookup() and either user_scan() if that transport
* type supports it, or else scsi_scan_host_selected()
*
* Note: this seems to be aimed exclusively at SCSI parallel busses.
*/
static int scsi_add_single_device(uint host, uint channel, uint id, uint lun)
{
struct Scsi_Host *shost;
int error = -ENXIO;
shost = scsi_host_lookup(host);
if (!shost)
return error;
if (shost->transportt->user_scan)
error = shost->transportt->user_scan(shost, channel, id, lun);
else
error = scsi_scan_host_selected(shost, channel, id, lun,
SCSI_SCAN_MANUAL);
scsi_host_put(shost);
return error;
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
christoph hellwig | christoph hellwig | 86 | 92.47% | 3 | 42.86% |
patrick mansfield | patrick mansfield | 3 | 3.23% | 1 | 14.29% |
james smart | james smart | 2 | 2.15% | 1 | 14.29% |
mike anderson | mike anderson | 1 | 1.08% | 1 | 14.29% |
hannes reinecke | hannes reinecke | 1 | 1.08% | 1 | 14.29% |
| Total | 93 | 100.00% | 7 | 100.00% |
/**
* scsi_remove_single_device - Respond to user request to remove a device
* @host: user-supplied decimal integer
* @channel: user-supplied decimal integer
* @id: user-supplied decimal integer
* @lun: user-supplied decimal integer
*
* Description: called by writing "scsi remove-single-device" to
* /proc/scsi/scsi. Does a scsi_device_lookup() and scsi_remove_device()
*/
static int scsi_remove_single_device(uint host, uint channel, uint id, uint lun)
{
struct scsi_device *sdev;
struct Scsi_Host *shost;
int error = -ENXIO;
shost = scsi_host_lookup(host);
if (!shost)
return error;
sdev = scsi_device_lookup(shost, channel, id, lun);
if (sdev) {
scsi_remove_device(sdev);
scsi_device_put(sdev);
error = 0;
}
scsi_host_put(shost);
return error;
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
christoph hellwig | christoph hellwig | 87 | 96.67% | 5 | 71.43% |
james smart | james smart | 2 | 2.22% | 1 | 14.29% |
mike anderson | mike anderson | 1 | 1.11% | 1 | 14.29% |
| Total | 90 | 100.00% | 7 | 100.00% |
/**
* proc_scsi_write - handle writes to /proc/scsi/scsi
* @file: not used
* @buf: buffer to write
* @length: length of buf, at most PAGE_SIZE
* @ppos: not used
*
* Description: this provides a legacy mechanism to add or remove devices by
* Host, Channel, ID, and Lun. To use,
* "echo 'scsi add-single-device 0 1 2 3' > /proc/scsi/scsi" or
* "echo 'scsi remove-single-device 0 1 2 3' > /proc/scsi/scsi" with
* "0 1 2 3" replaced by the Host, Channel, Id, and Lun.
*
* Note: this seems to be aimed at parallel SCSI. Most modern busses (USB,
* SATA, Firewire, Fibre Channel, etc) dynamically assign these values to
* provide a unique identifier and nothing more.
*/
static ssize_t proc_scsi_write(struct file *file, const char __user *buf,
size_t length, loff_t *ppos)
{
int host, channel, id, lun;
char *buffer, *p;
int err;
if (!buf || length > PAGE_SIZE)
return -EINVAL;
buffer = (char *)__get_free_page(GFP_KERNEL);
if (!buffer)
return -ENOMEM;
err = -EFAULT;
if (copy_from_user(buffer, buf, length))
goto out;
err = -EINVAL;
if (length < PAGE_SIZE)
buffer[length] = '\0';
else if (buffer[PAGE_SIZE-1])
goto out;
/*
* Usage: echo "scsi add-single-device 0 1 2 3" >/proc/scsi/scsi
* with "0 1 2 3" replaced by your "Host Channel Id Lun".
*/
if (!strncmp("scsi add-single-device", buffer, 22)) {
p = buffer + 23;
host = simple_strtoul(p, &p, 0);
channel = simple_strtoul(p + 1, &p, 0);
id = simple_strtoul(p + 1, &p, 0);
lun = simple_strtoul(p + 1, &p, 0);
err = scsi_add_single_device(host, channel, id, lun);
/*
* Usage: echo "scsi remove-single-device 0 1 2 3" >/proc/scsi/scsi
* with "0 1 2 3" replaced by your "Host Channel Id Lun".
*/
} else if (!strncmp("scsi remove-single-device", buffer, 25)) {
p = buffer + 26;
host = simple_strtoul(p, &p, 0);
channel = simple_strtoul(p + 1, &p, 0);
id = simple_strtoul(p + 1, &p, 0);
lun = simple_strtoul(p + 1, &p, 0);
err = scsi_remove_single_device(host, channel, id, lun);
}
/*
* convert success returns so that we return the
* number of bytes consumed.
*/
if (!err)
err = length;
out:
free_page((unsigned long)buffer);
return err;
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
christoph hellwig | christoph hellwig | 308 | 94.19% | 5 | 62.50% |
james bottomley | james bottomley | 12 | 3.67% | 2 | 25.00% |
pre-git | pre-git | 7 | 2.14% | 1 | 12.50% |
| Total | 327 | 100.00% | 8 | 100.00% |
static int always_match(struct device *dev, void *data)
{
return 1;
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
christoph hellwig | christoph hellwig | 10 | 55.56% | 1 | 50.00% |
jeff mahoney | jeff mahoney | 8 | 44.44% | 1 | 50.00% |
| Total | 18 | 100.00% | 2 | 100.00% |
static inline struct device *next_scsi_device(struct device *start)
{
struct device *next = bus_find_device(&scsi_bus_type, start, NULL,
always_match);
put_device(start);
return next;
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
jeff mahoney | jeff mahoney | 33 | 84.62% | 1 | 50.00% |
christoph hellwig | christoph hellwig | 6 | 15.38% | 1 | 50.00% |
| Total | 39 | 100.00% | 2 | 100.00% |
static void *scsi_seq_start(struct seq_file *sfile, loff_t *pos)
{
struct device *dev = NULL;
loff_t n = *pos;
while ((dev = next_scsi_device(dev))) {
if (!n--)
break;
sfile->private++;
}
return dev;
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
jeff mahoney | jeff mahoney | 57 | 100.00% | 1 | 100.00% |
| Total | 57 | 100.00% | 1 | 100.00% |
static void *scsi_seq_next(struct seq_file *sfile, void *v, loff_t *pos)
{
(*pos)++;
sfile->private++;
return next_scsi_device(v);
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
jeff mahoney | jeff mahoney | 37 | 100.00% | 1 | 100.00% |
| Total | 37 | 100.00% | 1 | 100.00% |
static void scsi_seq_stop(struct seq_file *sfile, void *v)
{
put_device(v);
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
jeff mahoney | jeff mahoney | 20 | 100.00% | 1 | 100.00% |
| Total | 20 | 100.00% | 1 | 100.00% |
static int scsi_seq_show(struct seq_file *sfile, void *dev)
{
if (!sfile->private)
seq_puts(sfile, "Attached devices:\n");
return proc_print_scsidevice(dev, sfile);
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
jeff mahoney | jeff mahoney | 31 | 83.78% | 1 | 50.00% |
christoph hellwig | christoph hellwig | 6 | 16.22% | 1 | 50.00% |
| Total | 37 | 100.00% | 2 | 100.00% |
static const struct seq_operations scsi_seq_ops = {
.start = scsi_seq_start,
.next = scsi_seq_next,
.stop = scsi_seq_stop,
.show = scsi_seq_show
};
/**
* proc_scsi_open - glue function
* @inode: not used
* @file: passed to single_open()
*
* Associates proc_scsi_show with this file
*/
static int proc_scsi_open(struct inode *inode, struct file *file)
{
/*
* We don't really need this for the write case but it doesn't
* harm either.
*/
return seq_open(file, &scsi_seq_ops);
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
christoph hellwig | christoph hellwig | 22 | 84.62% | 1 | 33.33% |
jeff mahoney | jeff mahoney | 3 | 11.54% | 1 | 33.33% |
rob landley | rob landley | 1 | 3.85% | 1 | 33.33% |
| Total | 26 | 100.00% | 3 | 100.00% |
static const struct file_operations proc_scsi_operations = {
.owner = THIS_MODULE,
.open = proc_scsi_open,
.read = seq_read,
.write = proc_scsi_write,
.llseek = seq_lseek,
.release = seq_release,
};
/**
* scsi_init_procfs - create scsi and scsi/scsi in procfs
*/
int __init scsi_init_procfs(void)
{
struct proc_dir_entry *pde;
proc_scsi = proc_mkdir("scsi", NULL);
if (!proc_scsi)
goto err1;
pde = proc_create("scsi/scsi", 0, NULL, &proc_scsi_operations);
if (!pde)
goto err2;
return 0;
err2:
remove_proc_entry("scsi", NULL);
err1:
return -ENOMEM;
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
christoph hellwig | christoph hellwig | 50 | 71.43% | 2 | 40.00% |
pre-git | pre-git | 14 | 20.00% | 1 | 20.00% |
denis v. lunev | denis v. lunev | 4 | 5.71% | 1 | 20.00% |
mika kukkonen | mika kukkonen | 2 | 2.86% | 1 | 20.00% |
| Total | 70 | 100.00% | 5 | 100.00% |
/**
* scsi_exit_procfs - Remove scsi/scsi and scsi from procfs
*/
void scsi_exit_procfs(void)
{
remove_proc_entry("scsi/scsi", NULL);
remove_proc_entry("scsi", NULL);
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
christoph hellwig | christoph hellwig | 16 | 76.19% | 1 | 33.33% |
pre-git | pre-git | 3 | 14.29% | 1 | 33.33% |
mika kukkonen | mika kukkonen | 2 | 9.52% | 1 | 33.33% |
| Total | 21 | 100.00% | 3 | 100.00% |
Overall Contributors
| Person | Tokens | Prop | Commits | CommitProp |
christoph hellwig | christoph hellwig | 837 | 46.97% | 18 | 31.03% |
al viro | al viro | 259 | 14.53% | 3 | 5.17% |
jeff mahoney | jeff mahoney | 218 | 12.23% | 1 | 1.72% |
pre-git | pre-git | 179 | 10.04% | 11 | 18.97% |
mike anderson | mike anderson | 162 | 9.09% | 3 | 5.17% |
hannes reinecke | hannes reinecke | 22 | 1.23% | 3 | 5.17% |
rasmus villemoes | rasmus villemoes | 16 | 0.90% | 2 | 3.45% |
arjan van de ven | arjan van de ven | 14 | 0.79% | 2 | 3.45% |
james bottomley | james bottomley | 12 | 0.67% | 2 | 3.45% |
rob landley | rob landley | 12 | 0.67% | 1 | 1.72% |
linus torvalds | linus torvalds | 11 | 0.62% | 1 | 1.72% |
denis v. lunev | denis v. lunev | 9 | 0.51% | 1 | 1.72% |
patrick mansfield | patrick mansfield | 5 | 0.28% | 2 | 3.45% |
jan beulich | jan beulich | 5 | 0.28% | 1 | 1.72% |
james smart | james smart | 4 | 0.22% | 1 | 1.72% |
alan stern | alan stern | 4 | 0.22% | 1 | 1.72% |
mika kukkonen | mika kukkonen | 4 | 0.22% | 1 | 1.72% |
tejun heo | tejun heo | 3 | 0.17% | 1 | 1.72% |
matthew wilcox | matthew wilcox | 3 | 0.17% | 1 | 1.72% |
harvey harrison | harvey harrison | 2 | 0.11% | 1 | 1.72% |
adrian bunk | adrian bunk | 1 | 0.06% | 1 | 1.72% |
| Total | 1782 | 100.00% | 58 | 100.00% |
Information contained on this website is for historical information purposes only and does not indicate or represent copyright ownership.