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 */
相关文档:
2009 年 4 月 23 日
本文中我们针对 Linux 上多线程编程的主要特性总结出 5 条经验,用以改善 Linux 多线程编程的习惯和避免其中的开发陷阱。在本文中,我们穿插一些 Windows 的编程用例用以对比 Linux 特性,以加深读者印象。
背景
Linux 平台上的多线程程序开发相对应其他平台(比如 Windows)的多线程 API 有一些细微 ......
Linux操作系统定时任务系统 Cron 入门
cron是一个linux下的定时执行工具,可以在无需人工干预的情况下运行作业。由于Cron 是Linux的内置服务,但它不自动起来,可以用以下的方法启动、关闭这个服务:
/sbin/service crond start //启动服务
/sbin/service crond stop //关闭服务
/sbin/service cr ......
linux 多线程编程非常简单。
一、多线程编程的流程:
创建线程--->当前线程继续工作--->[与创建的线程同步]--->[等待创建的线程结束与返回]--->当前线程继续工作。
--->创建的线程开始工作--->[与别的线程同步]---> ......
[url=http://www.netdigedu.com/jiagoubaike/13063.html]Linux:Linux文件命令精通指南[/url]
[url=http://www.netdigedu.com]网讯通信学院[/url]
为刚接触 Linux 文件命令的初学者提供的速成教程
虽然 GUI 桌面(如 KDE 和 GNOME)能够帮助用户利用 Linux 特性,而无需关于命令行接口的功能知识,但还是经常会需要更多的 ......
在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 ......