ide.c

来自「IPcop软路由防火墙 FREE 开源源代码」· C语言 代码 · 共 62 行

C
62 行
字号
/* SmoothWall install program. * * This program is distributed under the terms of the GNU General Public * Licence.  See the file COPYING for details. * * (c) Lawrence Manning, 2001 * Contains some functs for scanning /proc for ide info on CDROMS and * harddisks. *  * $Id: ide.c,v 1.4 2003/12/11 11:25:53 riddles Exp $ *  */#include "install.h"/* checkide().  Scans the named drive letter and returns the IDE_??? type. */int checkide(char letter){	FILE *f = NULL;	char filename[STRING_SIZE];	char buffer[STRING_SIZE];		sprintf(filename, "/proc/ide/hd%c/media", letter);		if (!(f = fopen(filename, "r")))		return IDE_EMPTY;			if (!(fgets(buffer, STRING_SIZE, f)))	{		printf("Couldn't read from %s\n", filename);		fclose(f);		return IDE_EMPTY;	}			fclose(f);		stripnl(buffer);		if (strcmp(buffer, "cdrom") == 0)		return IDE_CDROM;	else if (strcmp(buffer, "disk") == 0)		return IDE_HD;	else		return IDE_UNKNOWN;}/* findidetype().  Finds the first ide deveice of the given IDE_?? type. */char findidetype(int type){	char letter;		for (letter = 'a'; letter <= 'z'; letter++)	{		if ((checkide(letter)) == type)		{			return letter;		}	}	return '\0';}

⌨️ 快捷键说明

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