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

📄 iscsi_device.c

📁 iscsi源代码 UNH的progect 有initiator端和target端的源码
💻 C
字号:
/*	initiator/iscsi_device.c * *	This file contains the core functions for accessing iscsi initiator *	device /dev/unh_iscsi_initiator. * *	vi: set autoindent tabstop=8 shiftwidth=8 : * *	Copyright (C) 2001-2003 InterOperability Lab (IOL) *	University of New Hampshier (UNH) *	Durham, NH 03824 * *	This program is free software; you can redistribute it and/or modify *	it under the terms of the GNU General Public License as published by *	the Free Software Foundation; either version 2, or (at your option) *	any later version. * *	This program is distributed in the hope that it will be useful, *	but WITHOUT ANY WARRANTY; without even the implied warranty of *	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the *	GNU General Public License for more details. * *	You should have received a copy of the GNU General Public License *	along with this program; if not, write to the Free Software *	Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, *	USA. * *	The name of IOL and/or UNH may not be used to endorse or promote *	products derived from this software without specific prior * 	written permission.*/#include "iscsi_initiator.h"#include "initiator_utilities.h"#include <linux/devfs_fs_kernel.h>/* Ming Zhang, mingz@ele.uri.edu */#ifdef K26/* Devfs handle for the iscsi device */struct devfs_entry *iscsi_devfs_handle;#elsestatic int iscsi_init_ioctl(struct inode *inode, struct file *file, uint cmd,			    ulong arg);/* Major device number for iSCSI Initiator device */static uint iscsi_device_major;static char *init_modname = "unh_iscsi_initiator";/* * Operations permitted on iscsi device */static struct file_operations iscsi_device_fops = {	ioctl:iscsi_init_ioctl};/* Devfs handle for the iscsi device */static devfs_handle_t iscsi_devfs_handle;#endif/* * Register the Initiator device driver. * Create devfs entry for Initiator device. If devfs is mounted, the device * appears under the devfs tree. If devfs is not mounted at boot time, * the /dev/unh_iscsi_initiator entry needs to be created from userland. */intinitiator_register_device(void){/* Ming Zhang, mingz@ele.uri.edu */#ifndef K26	uint flags = DEVFS_FL_DEFAULT;	if (iscsi_device_major)		return (-EINVAL);	SET_MODULE_OWNER(&iscsi_device_fops);	iscsi_device_major = devfs_register_chrdev(0, init_modname,						   &iscsi_device_fops);	if (iscsi_device_major < 0) {		printk(KERN_WARNING		       "%s: No free major number. Unable to register iSCSI Initiator "		       "device.\n", init_modname);		return (-EINVAL);	}	/* devfs=only boot option */	if (iscsi_device_major == 0) {		flags |= DEVFS_FL_AUTO_DEVNUM;	}	iscsi_devfs_handle = devfs_register(NULL, init_modname,					    flags, iscsi_device_major, 0,					    S_IFCHR | S_IRUSR | S_IWUSR |					    S_IRGRP | S_IWGRP,					    &iscsi_device_fops, NULL);	/* Devfs mounted at boot time */	if (iscsi_devfs_handle && iscsi_device_major == 0) {		devfs_get_maj_min(iscsi_devfs_handle, &iscsi_device_major,				  NULL);	}	/* We should have a major number by now */	if (iscsi_device_major == 0) {		printk(KERN_WARNING		       "%s: Unable to register iSCSI Initiator device.\n",		       init_modname);		return (-EINVAL);	}	printk(KERN_INFO	       "%s: UNH iSCSI Initiator device registered, major number: %d, "	       "device : 0x%x \n",	       init_modname, iscsi_device_major, MKDEV(iscsi_device_major, 0));#endif	return 0;}/* * Remove devfs entry for this device. */voidinitiator_unregister_device(void){/* Ming Zhang, mingz@ele.uri.edu */#ifndef K26	if (!iscsi_device_major)		return;	if (devfs_unregister_chrdev(iscsi_device_major, init_modname)) {		printk(KERN_ERR		       "%s: Error unregistering UNH iSCSI Initaitor device. \n",		       init_modname);	}	if (iscsi_devfs_handle)		devfs_unregister(iscsi_devfs_handle);#endif}/* Ming Zhang, mingz@ele.uri.edu */#ifndef K26/* * Perform ioctl() services for the iscsi device. */static intiscsi_init_ioctl(struct inode *inode, struct file *file, uint cmd, ulong arg){	int ret_value = 0;	switch (cmd) {		/* Get the number of memory regions */	case 1:		printk(KERN_DEBUG		       "%s: iscsi init device ioctl succeeded! \n",		       init_modname);		break;	default:		ret_value = -EINVAL;		break;	}	return (ret_value);}#endif

⌨️ 快捷键说明

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