⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 i2o_proc.c

📁 linux-2.6.15.6
💻 C
📖 第 1 页 / 共 4 页
字号:
	seq_printf(seq, "Event_enable : 0x%02X\n", result.event_enable);	seq_printf(seq, "    [%s] Operational state change. \n",		   (result.event_enable & 0x01) ? "+" : "-");	seq_printf(seq, "    [%s] Low catastrophic. \n",		   (result.event_enable & 0x02) ? "+" : "-");	seq_printf(seq, "    [%s] Low reading. \n",		   (result.event_enable & 0x04) ? "+" : "-");	seq_printf(seq, "    [%s] Low warning. \n",		   (result.event_enable & 0x08) ? "+" : "-");	seq_printf(seq,		   "    [%s] Change back to normal from out of range state. \n",		   (result.event_enable & 0x10) ? "+" : "-");	seq_printf(seq, "    [%s] High warning. \n",		   (result.event_enable & 0x20) ? "+" : "-");	seq_printf(seq, "    [%s] High reading. \n",		   (result.event_enable & 0x40) ? "+" : "-");	seq_printf(seq, "    [%s] High catastrophic. \n",		   (result.event_enable & 0x80) ? "+" : "-");	return 0;}static int i2o_seq_open_hrt(struct inode *inode, struct file *file){	return single_open(file, i2o_seq_show_hrt, PDE(inode)->data);};static int i2o_seq_open_lct(struct inode *inode, struct file *file){	return single_open(file, i2o_seq_show_lct, PDE(inode)->data);};static int i2o_seq_open_status(struct inode *inode, struct file *file){	return single_open(file, i2o_seq_show_status, PDE(inode)->data);};static int i2o_seq_open_hw(struct inode *inode, struct file *file){	return single_open(file, i2o_seq_show_hw, PDE(inode)->data);};static int i2o_seq_open_ddm_table(struct inode *inode, struct file *file){	return single_open(file, i2o_seq_show_ddm_table, PDE(inode)->data);};static int i2o_seq_open_driver_store(struct inode *inode, struct file *file){	return single_open(file, i2o_seq_show_driver_store, PDE(inode)->data);};static int i2o_seq_open_drivers_stored(struct inode *inode, struct file *file){	return single_open(file, i2o_seq_show_drivers_stored, PDE(inode)->data);};static int i2o_seq_open_groups(struct inode *inode, struct file *file){	return single_open(file, i2o_seq_show_groups, PDE(inode)->data);};static int i2o_seq_open_phys_device(struct inode *inode, struct file *file){	return single_open(file, i2o_seq_show_phys_device, PDE(inode)->data);};static int i2o_seq_open_claimed(struct inode *inode, struct file *file){	return single_open(file, i2o_seq_show_claimed, PDE(inode)->data);};static int i2o_seq_open_users(struct inode *inode, struct file *file){	return single_open(file, i2o_seq_show_users, PDE(inode)->data);};static int i2o_seq_open_priv_msgs(struct inode *inode, struct file *file){	return single_open(file, i2o_seq_show_priv_msgs, PDE(inode)->data);};static int i2o_seq_open_authorized_users(struct inode *inode, struct file *file){	return single_open(file, i2o_seq_show_authorized_users,			   PDE(inode)->data);};static int i2o_seq_open_dev_identity(struct inode *inode, struct file *file){	return single_open(file, i2o_seq_show_dev_identity, PDE(inode)->data);};static int i2o_seq_open_ddm_identity(struct inode *inode, struct file *file){	return single_open(file, i2o_seq_show_ddm_identity, PDE(inode)->data);};static int i2o_seq_open_uinfo(struct inode *inode, struct file *file){	return single_open(file, i2o_seq_show_uinfo, PDE(inode)->data);};static int i2o_seq_open_sgl_limits(struct inode *inode, struct file *file){	return single_open(file, i2o_seq_show_sgl_limits, PDE(inode)->data);};static int i2o_seq_open_sensors(struct inode *inode, struct file *file){	return single_open(file, i2o_seq_show_sensors, PDE(inode)->data);};static int i2o_seq_open_dev_name(struct inode *inode, struct file *file){	return single_open(file, i2o_seq_show_dev_name, PDE(inode)->data);};static struct file_operations i2o_seq_fops_lct = {	.open = i2o_seq_open_lct,	.read = seq_read,	.llseek = seq_lseek,	.release = single_release,};static struct file_operations i2o_seq_fops_hrt = {	.open = i2o_seq_open_hrt,	.read = seq_read,	.llseek = seq_lseek,	.release = single_release,};static struct file_operations i2o_seq_fops_status = {	.open = i2o_seq_open_status,	.read = seq_read,	.llseek = seq_lseek,	.release = single_release,};static struct file_operations i2o_seq_fops_hw = {	.open = i2o_seq_open_hw,	.read = seq_read,	.llseek = seq_lseek,	.release = single_release,};static struct file_operations i2o_seq_fops_ddm_table = {	.open = i2o_seq_open_ddm_table,	.read = seq_read,	.llseek = seq_lseek,	.release = single_release,};static struct file_operations i2o_seq_fops_driver_store = {	.open = i2o_seq_open_driver_store,	.read = seq_read,	.llseek = seq_lseek,	.release = single_release,};static struct file_operations i2o_seq_fops_drivers_stored = {	.open = i2o_seq_open_drivers_stored,	.read = seq_read,	.llseek = seq_lseek,	.release = single_release,};static struct file_operations i2o_seq_fops_groups = {	.open = i2o_seq_open_groups,	.read = seq_read,	.llseek = seq_lseek,	.release = single_release,};static struct file_operations i2o_seq_fops_phys_device = {	.open = i2o_seq_open_phys_device,	.read = seq_read,	.llseek = seq_lseek,	.release = single_release,};static struct file_operations i2o_seq_fops_claimed = {	.open = i2o_seq_open_claimed,	.read = seq_read,	.llseek = seq_lseek,	.release = single_release,};static struct file_operations i2o_seq_fops_users = {	.open = i2o_seq_open_users,	.read = seq_read,	.llseek = seq_lseek,	.release = single_release,};static struct file_operations i2o_seq_fops_priv_msgs = {	.open = i2o_seq_open_priv_msgs,	.read = seq_read,	.llseek = seq_lseek,	.release = single_release,};static struct file_operations i2o_seq_fops_authorized_users = {	.open = i2o_seq_open_authorized_users,	.read = seq_read,	.llseek = seq_lseek,	.release = single_release,};static struct file_operations i2o_seq_fops_dev_name = {	.open = i2o_seq_open_dev_name,	.read = seq_read,	.llseek = seq_lseek,	.release = single_release,};static struct file_operations i2o_seq_fops_dev_identity = {	.open = i2o_seq_open_dev_identity,	.read = seq_read,	.llseek = seq_lseek,	.release = single_release,};static struct file_operations i2o_seq_fops_ddm_identity = {	.open = i2o_seq_open_ddm_identity,	.read = seq_read,	.llseek = seq_lseek,	.release = single_release,};static struct file_operations i2o_seq_fops_uinfo = {	.open = i2o_seq_open_uinfo,	.read = seq_read,	.llseek = seq_lseek,	.release = single_release,};static struct file_operations i2o_seq_fops_sgl_limits = {	.open = i2o_seq_open_sgl_limits,	.read = seq_read,	.llseek = seq_lseek,	.release = single_release,};static struct file_operations i2o_seq_fops_sensors = {	.open = i2o_seq_open_sensors,	.read = seq_read,	.llseek = seq_lseek,	.release = single_release,};/* * IOP specific entries...write field just in case someone * ever wants one. */static i2o_proc_entry i2o_proc_generic_iop_entries[] = {	{"hrt", S_IFREG | S_IRUGO, &i2o_seq_fops_hrt},	{"lct", S_IFREG | S_IRUGO, &i2o_seq_fops_lct},	{"status", S_IFREG | S_IRUGO, &i2o_seq_fops_status},	{"hw", S_IFREG | S_IRUGO, &i2o_seq_fops_hw},	{"ddm_table", S_IFREG | S_IRUGO, &i2o_seq_fops_ddm_table},	{"driver_store", S_IFREG | S_IRUGO, &i2o_seq_fops_driver_store},	{"drivers_stored", S_IFREG | S_IRUGO, &i2o_seq_fops_drivers_stored},	{NULL, 0, NULL}};/* * Device specific entries */static i2o_proc_entry generic_dev_entries[] = {	{"groups", S_IFREG | S_IRUGO, &i2o_seq_fops_groups},	{"phys_dev", S_IFREG | S_IRUGO, &i2o_seq_fops_phys_device},	{"claimed", S_IFREG | S_IRUGO, &i2o_seq_fops_claimed},	{"users", S_IFREG | S_IRUGO, &i2o_seq_fops_users},	{"priv_msgs", S_IFREG | S_IRUGO, &i2o_seq_fops_priv_msgs},	{"authorized_users", S_IFREG | S_IRUGO, &i2o_seq_fops_authorized_users},	{"dev_identity", S_IFREG | S_IRUGO, &i2o_seq_fops_dev_identity},	{"ddm_identity", S_IFREG | S_IRUGO, &i2o_seq_fops_ddm_identity},	{"user_info", S_IFREG | S_IRUGO, &i2o_seq_fops_uinfo},	{"sgl_limits", S_IFREG | S_IRUGO, &i2o_seq_fops_sgl_limits},	{"sensors", S_IFREG | S_IRUGO, &i2o_seq_fops_sensors},	{NULL, 0, NULL}};/* *  Storage unit specific entries (SCSI Periph, BS) with device names */static i2o_proc_entry rbs_dev_entries[] = {	{"dev_name", S_IFREG | S_IRUGO, &i2o_seq_fops_dev_name},	{NULL, 0, NULL}};/** *	i2o_proc_create_entries - Creates proc dir entries *	@dir: proc dir entry under which the entries should be placed *	@i2o_pe: pointer to the entries which should be added *	@data: pointer to I2O controller or device * *	Create proc dir entries for a I2O controller or I2O device. * *	Returns 0 on success or negative error code on failure. */static int i2o_proc_create_entries(struct proc_dir_entry *dir,				   i2o_proc_entry * i2o_pe, void *data){	struct proc_dir_entry *tmp;	while (i2o_pe->name) {		tmp = create_proc_entry(i2o_pe->name, i2o_pe->mode, dir);		if (!tmp)			return -1;		tmp->data = data;		tmp->proc_fops = i2o_pe->fops;		i2o_pe++;	}	return 0;}/** *	i2o_proc_subdir_remove - Remove child entries from a proc entry *	@dir: proc dir entry from which the childs should be removed * *	Iterate over each i2o proc entry under dir and remove it. If the child *	also has entries, remove them too. */static void i2o_proc_subdir_remove(struct proc_dir_entry *dir){	struct proc_dir_entry *pe, *tmp;	pe = dir->subdir;	while (pe) {		tmp = pe->next;		i2o_proc_subdir_remove(pe);		remove_proc_entry(pe->name, dir);		pe = tmp;	}};/** *	i2o_proc_device_add - Add an I2O device to the proc dir *	@dir: proc dir entry to which the device should be added *	@dev: I2O device which should be added * *	Add an I2O device to the proc dir entry dir and create the entries for *	the device depending on the class of the I2O device. */static void i2o_proc_device_add(struct proc_dir_entry *dir,				struct i2o_device *dev){	char buff[10];	struct proc_dir_entry *devdir;	i2o_proc_entry *i2o_pe = NULL;	sprintf(buff, "%03x", dev->lct_data.tid);	osm_debug("adding device /proc/i2o/%s/%s\n", dev->iop->name, buff);	devdir = proc_mkdir(buff, dir);	if (!devdir) {		osm_warn("Could not allocate procdir!\n");		return;	}	devdir->data = dev;	i2o_proc_create_entries(devdir, generic_dev_entries, dev);	/* Inform core that we want updates about this device's status */	switch (dev->lct_data.class_id) {	case I2O_CLASS_SCSI_PERIPHERAL:	case I2O_CLASS_RANDOM_BLOCK_STORAGE:		i2o_pe = rbs_dev_entries;		break;	default:		break;	}	if (i2o_pe)		i2o_proc_create_entries(devdir, i2o_pe, dev);}/** *	i2o_proc_iop_add - Add an I2O controller to the i2o proc tree *	@dir: parent proc dir entry *	@c: I2O controller which should be added * *	Add the entries to the parent proc dir entry. Also each device is added *	to the controllers proc dir entry. * *	Returns 0 on success or negative error code on failure. */static int i2o_proc_iop_add(struct proc_dir_entry *dir,			    struct i2o_controller *c){	struct proc_dir_entry *iopdir;	struct i2o_device *dev;	osm_debug("adding IOP /proc/i2o/%s\n", c->name);	iopdir = proc_mkdir(c->name, dir);	if (!iopdir)		return -1;	iopdir->data = c;	i2o_proc_create_entries(iopdir, i2o_proc_generic_iop_entries, c);	list_for_each_entry(dev, &c->devices, list)	    i2o_proc_device_add(iopdir, dev);	return 0;}/** *	i2o_proc_iop_remove - Removes an I2O controller from the i2o proc tree *	@dir: parent proc dir entry *	@c: I2O controller which should be removed * *	Iterate over each i2o proc entry and search controller c. If it is found *	remove it from the tree. */static void i2o_proc_iop_remove(struct proc_dir_entry *dir,				struct i2o_controller *c){	struct proc_dir_entry *pe, *tmp;	pe = dir->subdir;	while (pe) {		tmp = pe->next;		if (pe->data == c) {			i2o_proc_subdir_remove(pe);			remove_proc_entry(pe->name, dir);		}		osm_debug("removing IOP /proc/i2o/%s\n", c->name);		pe = tmp;	}}/** *	i2o_proc_fs_create - Create the i2o proc fs. * *	Iterate over each I2O controller and create the entries for it. * *	Returns 0 on success or negative error code on failure. */static int __init i2o_proc_fs_create(void){	struct i2o_controller *c;	i2o_proc_dir_root = proc_mkdir("i2o", NULL);	if (!i2o_proc_dir_root)		return -1;	i2o_proc_dir_root->owner = THIS_MODULE;	list_for_each_entry(c, &i2o_controllers, list)	    i2o_proc_iop_add(i2o_proc_dir_root, c);	return 0;};/** *	i2o_proc_fs_destroy - Cleanup the all i2o proc entries * *	Iterate over each I2O controller and remove the entries for it. * *	Returns 0 on success or negative error code on failure. */static int __exit i2o_proc_fs_destroy(void){	struct i2o_controller *c;	list_for_each_entry(c, &i2o_controllers, list)	    i2o_proc_iop_remove(i2o_proc_dir_root, c);	remove_proc_entry("i2o", NULL);	return 0;};/** *	i2o_proc_init - Init function for procfs * *	Registers Proc OSM and creates procfs entries. * *	Returns 0 on success or negative error code on failure. */static int __init i2o_proc_init(void){	int rc;	printk(KERN_INFO OSM_DESCRIPTION " v" OSM_VERSION "\n");	rc = i2o_driver_register(&i2o_proc_driver);	if (rc)		return rc;	rc = i2o_proc_fs_create();	if (rc) {		i2o_driver_unregister(&i2o_proc_driver);		return rc;	}	return 0;};/** *	i2o_proc_exit - Exit function for procfs * *	Unregisters Proc OSM and removes procfs entries. */static void __exit i2o_proc_exit(void){	i2o_driver_unregister(&i2o_proc_driver);	i2o_proc_fs_destroy();};MODULE_AUTHOR("Deepak Saxena");MODULE_LICENSE("GPL");MODULE_DESCRIPTION(OSM_DESCRIPTION);MODULE_VERSION(OSM_VERSION);module_init(i2o_proc_init);module_exit(i2o_proc_exit);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -