📄 getharddisk.c
字号:
#include <sys/ioctl.h>#include <stdio.h>#include <sys/types.h>#include <sys/stat.h>#include <fcntl.h>#include <linux/hdreg.h>static int open_flags = O_RDONLY|O_NONBLOCK;static int errno=1;int GetHardDisk(char * HardDisk,int len){ static struct hd_driveid id; int fd; char *devname="/dev/hda"; fd = open (devname, open_flags); if (fd < 0) { perror (devname); return -1; } ioctl (fd, HDIO_GET_IDENTITY, &id); sprintf (HardDisk,"\n Model=%.40s, FwRev=%.8s, SerialNo=%.20s\n", id.model, id.fw_rev, id.serial_no); close(fd); return 0;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -