LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
12
返回列表 发新帖
楼主: landylau

在linux下面收集硬件信息地问题。

[复制链接]
一颗感谢的心 该用户已被删除
发表于 2004-6-6 16:57:16 | 显示全部楼层
提示: 作者被禁止或删除 内容自动屏蔽
 楼主| 发表于 2004-6-7 18:59:42 | 显示全部楼层
/proc/ide/ide0/hda/capacity好像我的只有一个阿?
发表于 2004-6-8 09:04:35 | 显示全部楼层

这样做:


  1. int CDisk::GetDiskPattern()
  2. {
  3.         struct statfs         vfs;
  4.         uword32         ret;
  5.         uword16                ndir,nfile;
  6.         dword32         kblocks,mblocks;
  7.         dword32                total_mb, total_gb;
  8.        
  9.         // Get the information of a hard disk       
  10.         ret = statfs(mnt,&vfs);
  11.         if( ret != 0)
  12.         {
  13.                 err_ret("GetDiskPattern()");
  14.                 return HDD_FAILURE;
  15.         }
  16.        
  17.         err_msg("f_type=%X, f_bsize=%d, _blocks=%d,f_bfree=%d,f_bavail=%d",
  18.                 vfs.f_type, vfs.f_bsize,vfs.f_blocks,vfs.f_bfree,vfs.f_bavail);
  19.        
  20.         // /////////////////////////////////////////////////////////////
  21.         // Calculate the amount of directory and file in the directory
  22.         kblocks = (vfs.f_blocks / 1024);
  23.         mblocks = (kblocks / 1024);
  24.        
  25.         total_mb = vfs.f_bsize * mblocks;  // unit: MB
  26.         total_gb = total_mb / 1024;
  27.         err_msg("total: %.1f GB",  total_gb);
  28. }

复制代码
 楼主| 发表于 2004-6-8 10:45:58 | 显示全部楼层

good!
 楼主| 发表于 2004-6-8 10:50:47 | 显示全部楼层
楼上的这位兄弟,除了硬盘的,你手头上还有其他的源码吗?
象检测显卡,网卡mac,cpu,内存,
不过我还是觉得读/proc里面的内容比较简单。
编程实现这些,需要那些方面的知识阿,是不是要分析内核阿?
 楼主| 发表于 2004-6-8 12:47:31 | 显示全部楼层
刚才在linux下面试了下,man了下statfs。
编译还差很多头文件。
我也不知道哪些。能够解释一下吗?
发表于 2004-6-16 17:51:02 | 显示全部楼层
容量
# fdisk -l

# dmesg | less
您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表