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

📄 hcl.c

📁 linux-2.4.29操作系统的源码
💻 C
📖 第 1 页 / 共 2 页
字号:
		hwgraph_fastinfo_set(new_handle, (arbitrary_info_t)info);	*handle = new_handle;	return(0);}/* * hwgraph_vertex_destroy - Destroy the entry */inthwgraph_vertex_destroy(vertex_hdl_t de){	void *labelcl_info = NULL;	labelcl_info = hwgfs_get_info(de);	hwgfs_unregister(de);	if (labelcl_info)		labelcl_info_destroy((labelcl_info_t *)labelcl_info);	return(0);}inthwgraph_edge_add(vertex_hdl_t from, vertex_hdl_t to, char *name){	char *path, *link;	char *s1;	char *index;	vertex_hdl_t handle = NULL;	int rv;	int i, count;	path = kmalloc(1024, GFP_KERNEL);	memset((char *)path, 0x0, 1024);	link = kmalloc(1024, GFP_KERNEL);	memset((char *)link, 0x0, 1024);	i = hwgfs_generate_path (from, path, 1024);	s1 = (char *)path;	count = 0;	while (1) {		index = strstr (s1, "/");		if (index) {			count++;			s1 = ++index;		} else {			count++;			break;		}	}	for (i = 0; i < count; i++) {		strcat((char *)link,"../");	}	memset(path, 0x0, 1024);	i = hwgfs_generate_path (to, path, 1024);	strcat((char *)link, (char *)path);	/*	 * Otherwise, just create a symlink to the vertex.	 * In this case the vertex was previous created with a REAL pathname.	 */	rv = hwgfs_mk_symlink (from, (const char *)name,			       DEVFS_FL_DEFAULT, link,			       &handle, NULL);	kfree(path);	kfree(link);	return(rv);}/* ARGSUSED */inthwgraph_edge_get(vertex_hdl_t from, char *name, vertex_hdl_t *toptr){	vertex_hdl_t target_handle = NULL;	if (name == NULL)		return(-1);	if (toptr == NULL)		return(-1);	/*	 * If the name is "." just return the current entry handle.	 */	if (!strcmp(name, HWGRAPH_EDGELBL_DOT)) {		if (toptr) {			*toptr = from;		}	} else if (!strcmp(name, HWGRAPH_EDGELBL_DOTDOT)) {		/*		 * Hmmm .. should we return the connect point or parent ..		 * see in hwgraph, the concept of parent is the connectpt!		 *		 * Maybe we should see whether the connectpt is set .. if 		 * not just return the parent!		 */		target_handle = hwgraph_connectpt_get(from);		if (target_handle) {			/*			 * Just return the connect point.			 */			*toptr = target_handle;			return(0);		}		target_handle = hwgfs_get_parent(from);		*toptr = target_handle;	} else {		target_handle = hwgfs_find_handle (from, name, 0, 0,					0, 1); /* Yes traverse symbolic links */	}	if (target_handle == NULL)		return(-1);	else	 *toptr = target_handle;	return(0);}/* * hwgraph_info_add_LBL - Adds a new label for the device.  Mark the info_desc *	of the label as INFO_DESC_PRIVATE and store the info in the label. *//* ARGSUSED */inthwgraph_info_add_LBL( vertex_hdl_t de,			char *name,			arbitrary_info_t info){	return(labelcl_info_add_LBL(de, name, INFO_DESC_PRIVATE, info));}/* * hwgraph_info_remove_LBL - Remove the label entry for the device. *//* ARGSUSED */inthwgraph_info_remove_LBL( vertex_hdl_t de,				char *name,				arbitrary_info_t *old_info){	return(labelcl_info_remove_LBL(de, name, NULL, old_info));}/* * hwgraph_info_replace_LBL - replaces an existing label with  *	a new label info value. *//* ARGSUSED */inthwgraph_info_replace_LBL( vertex_hdl_t de,				char *name,				arbitrary_info_t info,				arbitrary_info_t *old_info){	return(labelcl_info_replace_LBL(de, name,			INFO_DESC_PRIVATE, info,			NULL, old_info));}/* * hwgraph_info_get_LBL - Get and return the info value in the label of the  * 	device. *//* ARGSUSED */inthwgraph_info_get_LBL(vertex_hdl_t de,			char *name,			arbitrary_info_t *infop){	return(labelcl_info_get_LBL(de, name, NULL, infop));}/* * hwgraph_info_get_exported_LBL - Retrieve the info_desc and info pointer  *	of the given label for the device.  The weird thing is that the label  *	that matches the name is return irrespective of the info_desc value! *	Do not understand why the word "exported" is used! *//* ARGSUSED */inthwgraph_info_get_exported_LBL(vertex_hdl_t de,				char *name,				int *export_info,				arbitrary_info_t *infop){	int rc;	arb_info_desc_t info_desc;	rc = labelcl_info_get_LBL(de, name, &info_desc, infop);	if (rc == 0)		*export_info = (int)info_desc;	return(rc);}/* * hwgraph_info_get_next_LBL - Returns the next label info given the  *	current label entry in place. * *	Once again this has no locking or reference count for protection. * *//* ARGSUSED */inthwgraph_info_get_next_LBL(vertex_hdl_t de,				char *buf,				arbitrary_info_t *infop,				labelcl_info_place_t *place){	return(labelcl_info_get_next_LBL(de, buf, NULL, infop, place));}/* * hwgraph_info_export_LBL - Retrieve the specified label entry and modify  *	the info_desc field with the given value in nbytes. *//* ARGSUSED */inthwgraph_info_export_LBL(vertex_hdl_t de, char *name, int nbytes){	arbitrary_info_t info;	int rc;	if (nbytes == 0)		nbytes = INFO_DESC_EXPORT;	if (nbytes < 0)		return(-1);	rc = labelcl_info_get_LBL(de, name, NULL, &info);	if (rc != 0)		return(rc);	rc = labelcl_info_replace_LBL(de, name,				nbytes, info, NULL, NULL);	return(rc);}/* * hwgraph_info_unexport_LBL - Retrieve the given label entry and change the  * label info_descr filed to INFO_DESC_PRIVATE. *//* ARGSUSED */inthwgraph_info_unexport_LBL(vertex_hdl_t de, char *name){	arbitrary_info_t info;	int rc;	rc = labelcl_info_get_LBL(de, name, NULL, &info);	if (rc != 0)		return(rc);	rc = labelcl_info_replace_LBL(de, name,				INFO_DESC_PRIVATE, info, NULL, NULL);	return(rc);}/* * hwgraph_path_lookup - return the handle for the given path. * */inthwgraph_path_lookup(vertex_hdl_t start_vertex_handle,			char *lookup_path,			vertex_hdl_t *vertex_handle_ptr,			char **remainder){	*vertex_handle_ptr = hwgfs_find_handle(start_vertex_handle,	/* start dir */					lookup_path,		/* path */					0,			/* major */					0,			/* minor */					0,			/* char | block */					1);			/* traverse symlinks */	if (*vertex_handle_ptr == NULL)		return(-1);	else		return(0);}/* * hwgraph_traverse - Find and return the handle starting from de. * */graph_error_thwgraph_traverse(vertex_hdl_t de, char *path, vertex_hdl_t *found){	/* 	 * get the directory entry (path should end in a directory)	 */	*found = hwgfs_find_handle(de,	/* start dir */			    path,	/* path */			    0,		/* major */			    0,		/* minor */			    0,		/* char | block */			    1);		/* traverse symlinks */	if (*found == NULL)		return(GRAPH_NOT_FOUND);	else		return(GRAPH_SUCCESS);}/* * hwgraph_path_to_vertex - Return the entry handle for the given  *	pathname .. assume traverse symlinks too!. */vertex_hdl_thwgraph_path_to_vertex(char *path){	return(hwgfs_find_handle(NULL,	/* start dir */			path,		/* path */		    	0,		/* major */		    	0,		/* minor */		    	0,		/* char | block */		    	1));		/* traverse symlinks */}/* * hwgraph_inventory_remove - Removes an inventory entry. * *	Remove an inventory item associated with a vertex.   It is the caller's *	responsibility to make sure that there are no races between removing *	inventory from a vertex and simultaneously removing that vertex.*/inthwgraph_inventory_remove(	vertex_hdl_t de,				int class,				int type,				major_t controller,				minor_t unit,				int state){	return(0); /* Just a Stub for IRIX code. */}/* * Find the canonical name for a given vertex by walking back through * connectpt's until we hit the hwgraph root vertex (or until we run * out of buffer space or until something goes wrong). * *	COMPATIBILITY FUNCTIONALITY * Walks back through 'parents', not necessarily the same as connectpts. * * Need to resolve the fact that does not return the path from  * "/" but rather it just stops right before /dev .. */inthwgraph_vertex_name_get(vertex_hdl_t vhdl, char *buf, uint buflen){	char *locbuf;	int   pos;	if (buflen < 1)		return(-1);	/* XXX should be GRAPH_BAD_PARAM ? */	locbuf = kmalloc(buflen, GFP_KERNEL);	pos = hwgfs_generate_path(vhdl, locbuf, buflen);	if (pos < 0) {		kfree(locbuf);		return pos;	}	strcpy(buf, &locbuf[pos]);	kfree(locbuf);	return 0;}/*** vertex_to_name converts a vertex into a canonical name by walking** back through connect points until we hit the hwgraph root (or until** we run out of buffer space).**** Usually returns a pointer to the original buffer, filled in as** appropriate.  If the buffer is too small to hold the entire name,** or if anything goes wrong while determining the name, vertex_to_name** returns "UnknownDevice".*/#define DEVNAME_UNKNOWN "UnknownDevice"char *vertex_to_name(vertex_hdl_t vhdl, char *buf, uint buflen){	if (hwgraph_vertex_name_get(vhdl, buf, buflen) == GRAPH_SUCCESS)		return(buf);	else		return(DEVNAME_UNKNOWN);}graph_error_thwgraph_edge_remove(vertex_hdl_t from, char *name, vertex_hdl_t *toptr){	return(GRAPH_ILLEGAL_REQUEST);}graph_error_thwgraph_vertex_unref(vertex_hdl_t vhdl){	return(GRAPH_ILLEGAL_REQUEST);}voidhwgraph_debug(char *file, char * function, int line, vertex_hdl_t vhdl1, vertex_hdl_t vhdl2, char *format, ...){	int pos;	char *hwpath;	va_list ap;	if ( !hwgraph_debug_mask )		return;	hwpath = kmalloc(MAXDEVNAME, GFP_KERNEL);	if (!hwpath)		BUG();	printk("HWGRAPH_DEBUG %s %s %d : ", file, function, line);	if (vhdl1){		memset(hwpath, 0, MAXDEVNAME);		pos = hwgfs_generate_path(vhdl1, hwpath, MAXDEVNAME);		printk("vhdl1 = %s : ", &hwpath[pos]);	}	if (vhdl2){		memset(hwpath, 0, MAXDEVNAME);		pos = hwgfs_generate_path(vhdl2, hwpath, MAXDEVNAME);		printk("vhdl2 = %s :", &hwpath[pos]);	}	memset(hwpath, 0, MAXDEVNAME);        va_start(ap, format);        vsnprintf(hwpath, 500, format, ap);        va_end(ap);	hwpath[MAXDEVNAME -1] = (char)0; /* Just in case. */        printk(" %s", hwpath);	kfree(hwpath);}EXPORT_SYMBOL(hwgraph_mk_dir);EXPORT_SYMBOL(hwgraph_path_add);EXPORT_SYMBOL(hwgraph_register);EXPORT_SYMBOL(hwgraph_vertex_destroy);EXPORT_SYMBOL(hwgraph_fastinfo_get);EXPORT_SYMBOL(hwgraph_fastinfo_set);EXPORT_SYMBOL(hwgraph_connectpt_set);EXPORT_SYMBOL(hwgraph_connectpt_get);EXPORT_SYMBOL(hwgraph_info_add_LBL);EXPORT_SYMBOL(hwgraph_info_remove_LBL);EXPORT_SYMBOL(hwgraph_info_replace_LBL);EXPORT_SYMBOL(hwgraph_info_get_LBL);EXPORT_SYMBOL(hwgraph_info_get_exported_LBL);EXPORT_SYMBOL(hwgraph_info_get_next_LBL);EXPORT_SYMBOL(hwgraph_info_export_LBL);EXPORT_SYMBOL(hwgraph_info_unexport_LBL);EXPORT_SYMBOL(hwgraph_path_lookup);EXPORT_SYMBOL(hwgraph_traverse);EXPORT_SYMBOL(hwgraph_vertex_name_get);

⌨️ 快捷键说明

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