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

📄 set_driver.c

📁 HP PCI热插拔代码GUI HP内部珍贵资料!
💻 C
字号:
/* *    Compaq Hot Plug Controller Graphical User Interface  *    Copyright 2000, 2001 Compaq Computer Corporation *    All rights reserved. * *    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 of the License, 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, GOOD TITLE or *    NON INFRINGEMENT.  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., 675 Mass Ave, Cambridge, MA 02139, USA. * *    Please send all questions or concerns to linuxhotplug@compaq.com */#include "commonheader.h"#include "callbacks.h"#include "interface.h"#include "refresh_tree.h"#include "refresh_table.h"#include "set_driver.h"#include "tree.h"// checks to see if the driver name exists in /proc/modules// this process is used to account for old-style drivers that cannot be detected by the Hot Plug driverint is_driverloaded(const char* driver_name) {	FILE* fd = NULL;	char tmp_buf[MAXLEN];	int rc = 0;	fd = fopen("/proc/modules", "r");	if (!fd) return 0;	while (fgets(tmp_buf, MAXLEN, fd)) {		if (strstr(tmp_buf, driver_name)) {			rc = 1;			break;		}	}	fclose(fd);	return rc;}void set_driver_from_slot (int function, GtkCTree* tree, GtkCTreeNode* node, GtkWidget* table, GtkWidget* status_bar, pci_tree_node* user_data){	// this function is never called since driver buttons are disabled for slots}// since inserting/removing a driver is a function-based operation, the ioctl call is placed in this functionvoid set_driver_from_function (int function, GtkCTree* tree, GtkCTreeNode* node, GtkWidget* table, GtkWidget* status_bar, pci_tree_node* user_data){	int rt = 0;	char msg[MAXLEN];        char cmd[MAXLEN];	if (selected_row != NOT_SELECTED)        {		public_function_info* func = (public_function_info*) user_data->node_info;		if (func->is_bridge)			return;                if ( (func->is_driverloaded && function == INSERT_DRIVER) ||		     (!func->is_driverloaded && function == REMOVE_DRIVER) ) {			if (function == INSERT_DRIVER)                       		sprintf(msg, "Slot %d: The %s driver is already installed.", selected_row, func->driver_name);			else				sprintf(msg, "Slot %d: The %s driver is not installed.", selected_row, func->driver_name);                	gtk_statusbar_pop(GTK_STATUSBAR(status_bar), context_id);                	gtk_statusbar_push(GTK_STATUSBAR(status_bar), context_id, msg);			return;                }                if (func->driver_name)                {			if (function == INSERT_DRIVER) 	                        sprintf(cmd, "insmod %s", func->driver_name);			else                        	sprintf(cmd, "rmmod %s", func->driver_name);                        rt = system(cmd);                }		refresh_tree(tree);			refresh_table(table, g_node);		// check to see if the driver is loaded		func->is_driverloaded = is_driverloaded(func->driver_name);		if (rt != 256) {                        if (function == INSERT_DRIVER)                        	sprintf(msg, "Slot %d: The %s driver has been inserted.", selected_row, func->driver_name);			else                         	sprintf(msg, "Slot %d: The %s driver has been removed.", selected_row, func->driver_name);			gtk_statusbar_pop(GTK_STATUSBAR(status_bar), context_id);                        gtk_statusbar_push(GTK_STATUSBAR(status_bar), context_id, msg);                }                else {			if (function == INSERT_DRIVER)	                       	sprintf(msg, "Slot %d: Problems occurred while inserting the driver.", selected_row);			else                        	sprintf(msg, "Slot %d: Problems occurred while removing the driver.", selected_row);                        gtk_statusbar_pop(GTK_STATUSBAR(status_bar), context_id);                        gtk_statusbar_push(GTK_STATUSBAR(status_bar), context_id, msg);                }        }}// obtain the function pci tree node and re-direct to the function-based callvoid set_driver_from_adapter (int function, GtkCTree* tree, GtkCTreeNode* node, GtkWidget* table, GtkWidget* status_bar, pci_tree_node* user_data){	pci_tree_node* func_p_node = ctree_partner_ex(tree, node, function_based, 0);	set_driver_from_function(function, tree, node, table, status_bar, func_p_node);}

⌨️ 快捷键说明

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