Linux下读硬盘序列号的程序
Linux下读硬盘序列号的程序
/*
* gethddsn.c
*
* Get serial number of ide hard disk.
* example: my Maxtor 15G 's s/n is K306S04C.
*
* Compile with: gcc -O2 gethddsn.c
*
* Xiaoming DONG <xmdong@263.net>
* Aug 24, 2000
*
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h> /* ioperm() */
#include <asm/io.h> /* outb(), inb() */
/* get serial number */
int gethddsn(char *ide)
{
unsigned int ide_info[257];
unsigned int info_off;
unsigned long loop2=0;
int loop, loop1=0;
if (ioperm(0x1f6, 1, 1)) {
perror("ioperm"); exit(-1);
}
outb(0xa0, 0x1f6);
if (ioperm(0x1f7, 1, 1)) {
perror("ioperm"); exit(-1);
}
outb(0xec, 0x1f7);
do {
if (ioperm(0x1f7, 1, 1)) {
perror("ioperm"); exit(-1);
}
} while (inb(0x1f7) != 0x58 && loop2++ < 0xffff);
for (info_off=0; info_off != 256; info_off++) {
if (ioperm(0x1f0, 2, 1)) {
perror("ioperm"); exit(-1);
}
ide_info[info_off] = inw(0x1f0);
}
for (loop=10, loop1=0; loop<=19; loop++)
{
ide[loop1++] = (char)(ide_info[loop] / 256);
ide[loop1++] = (char)(ide_info[loop] % 256);
}
ide[loop1] = 0;
if (loop1 > 40) printf("*error*\n");
return 0;
}
void main() /* print hard disk number */
{
static char serial[41];
gethddsn(serial);
printf("IDE hard disk s/n: %s\n", serial);
}
/* end of gethddsn.c */
相关文档:
一、引言:
本文档的内容大部份内容都是从网上收集而来,然后配合一些新的截图(内核版本:V2.4.19)。在每一配置项后会有一个选择指南的部份,用来指导大家怎么样根据自己的情况来做相应的选择;还有在每一个大项和文档的最后会有一个经验谈,它是一些高手们在应对问题和处理特有硬件时的一些经验(这个还� ......
由于 Linux 良好的用户权限管理体系,病毒往往是 Linux 系统管理员最后才需要考虑的问题。以往,Linux 上的杀毒软件主要是为企业的邮件和文件服务器所设计的。如今,随着 Linux 桌面用户数量的增长,桌面用户在受益于 Linux 系统对病毒较强的天然免疫力的同时,也需要杀毒软件清理从网络或U盘带来的WIndows病毒。尽管那些 ......
在TimesTen的优化中,如果涉及到 Replication 或者Cache Group的话,那么针对 TCP/IP相关的参数的优化对性能是有益的。因为它们俩都是通过TCP/IP协议进行数据交互的。在安装文档(install.pdf)的39页有具体的说明:
For replication, TCP send and receive buffers should be increased to a minimum of 512KB. To ......
=======================================================================
一些关于Linux的资源站点,希望对大家有帮助
http://www.linux.org/ ;
Linux官方新闻和信息网站。
http://freesoft.cei.gov.cn/ ;
中国软件行业协会国际自由软件应用研究发展分会的自由软件库,上面提供有各种Linux软件可供下载,并有Linux ......