ÔںܶàϵͳÈí¼þµÄ¿ª·¢ÖУ¬ÐèҪʹÓÃһЩϵͳµÄΨһÐÔÐÅÏ¢¡£ËùÒÔ£¬µÃµ½Ö÷»úµÄCPUID¡¢Ó²ÅÌÐòÁкż°Íø¿¨µÄMACµØÖ·£¬¾Í³É¸öÒ»¼þºÜÖØÒªµÄÓ¦Óá£
±¾È˾¹ýÒ»·¬google¼´×Ô¼ºµÄ×êÑУ¬»ù±¾ÉÏʵÏÖÁËÕ⼸¸ö¹¦ÄÜ¡£ÐèÒªµÄ×¼±¸ÖªÊ¶ÓУº
GCCµÄǶÈë»ã±à£¬¾ßÌåµÄGCCǶÈë»ã±à֪ʶ£¬Çë²Î¿¼Ïà¹ØÊÖ²á
ioctlϵͳµ÷Ó㬾ßÌåµÄµ÷Ó÷½·¨£¬Çë²é¿´ÊÖ²áÒ³
»ñÈ¡CPUID
°´ÕÕÍøÉÏÌṩµÄ˵Ã÷£¬CPUID²¢²»ÊÇËùÓеÄIntel CPU¶¼Ö§³ÖµÄ¡£Èç¹ûÖ§³Ö£¬»ã±àµ÷ÓÃΪ£ºeaxÖÃ0000_0003£¬µ÷ÓÃcpuid¡£
ÒÔÏÂΪʵÏÖ´úÂ루ÔÚÎÒµÄCPUÉÏ£¬²¢Ã»Óеõ½£©£º
#define cpuid(in,a,b,c,d) asm("cpuid": "=a" (a), "=b" (b), "=c" (c), "=d" (d) : "a" (in));
static int
getcpuid (char *id, size_t max)
{
int i;
unsigned long li, maxi, maxei, ebx, ecx, edx, unused;
cpuid (0, maxi, unused, unused, unused);
maxi &= 0xffff;
if (maxi < 3)
{
return -1;
}
cpuid (3, eax, ebx, ecx, edx);
snprintf (id, max, "%08lx %08lx %08lx %08lx", eax, ebx, ecx, edx);
fprintf (stdout, "get cpu id: %s\n", id);
return 0;
}
»ñÈ¡Ó²ÅÌÐòÁкÅ
Õâ¸öµÄʵÏÖ£¬²ÉÓõÄÊǶÁÈ¡/etc/mtabÎļþ£¬ÕÒµ½/£¨¼´¸ùĿ¼£©¹ÒÔصÄÉ豸Îļþ£¬È»ºó´ò¿ªËü£¬ÔÙÓÃϵͳµ÷ÓÃioctlÀ´ÊµÏֵġ£
ioctlµÚ¶þ¸ö²ÎÊýΪHDIO_GET_IDENTITY, »ñµÃÖ¸¶¨ÎļþÃèÊö·ûµÄ±êÖ¾ºÅ
ioctlµÄµÚÈý¸ö²ÎÊýΪstruct hd_driveid £¬ÔÚlinux/hdreg.hÖУ¬struct hd_driveidµÄÉùÃ÷ÓÐ
struct hd_driveid {
unsigned short config; / lots of obsolete bit flags */
unsigned short cyls; /* Obsolete, "physical" cyls */
unsigned short reserved2; /* reserved (word 2) */
unsigned short heads; /* Obsolete, "physical" heads */
unsigned short track_bytes; /* unformatted bytes per track */
unsigned short sector_bytes; /* unformatted bytes per sector */
unsigned short sectors; /* Obsolete, "physical" sectors per track */
unsigned short vendor0; /* vendor unique */
unsigned short vendor1; /* vendor unique */
unsigned short vendor2; /* Retired vendor unique */
unsigned char serial_no[20]; /* 0 = not_specified */
unsigned short buf_type; /* Retired */
unsigned short buf_size; /* Retired, 512 byte increments
linuxµÄ½ø³Ì¼äͨÐÅ·½Ê½Ö÷ÒªÓУºÄäÃû¹ÜµÀ¡¢ÓÐÃû¹ÜµÀ¡¢ÏûÏ¢¶ÓÁС¢¹²ÏíÄÚ´æ¡¢Ðźš¢ÐźÅÁ¿¼°Ðźŵơ¢socketÍøÂçͨÐÅ¡£½üÈÕÓÉÓÚÏîÄ¿ÐèÒª£¬ÓÃlinux±àдarmµÄÓ¦ÓóÌÐò£¬ÀïÃæÓм¸¸ö¹¦ÄÜÄ£¿é£¬Èô¸É½ø³Ì£¬½ø³Ì¼äµÄͨÐÅ·½Ê½Ñ¡ÔñÁ˹ܵÀ¡¢¹²ÏíÄÚ´æºÍÐźÅÁ¿µÄÅäºÏ¡£Õ⼸ÌìÖÕÓڰѳÌÐòµÄ¿ò¼Ü´î½¨ºÃÁË£¬¶øÎÒÒ²¶Ô¹ÜµÀͨÐÅÓÐÁ˽øÒ»²½µÄÈÏʶ¡£
......
ÓÐÁ½ÖÖÉèÖû·¾³±äÁ¿ PATH µÄ·½·¨¡£µÚÒ»ÖÖÊÊÓÃÓÚΪµ¥Ò»Óû§ÉèÖà PATH£¬µÚ¶þÖÖÊÇΪȫ¾ÖÉèÖà PATH¡£
1.ÔÚÓû§Ö÷Ŀ¼ÏÂÓÐÒ»¸ö .bashrc Îļþ£¬¿ÉÒÔÔÚ´ËÎļþÖмÓÈë PATH µÄÉèÖÃÈçÏ£º
export PATH=”$PATH:/your path1/:/your path2/…..”
×¢Ò⣺ÿһ¸ö path Ö®¼äÒªÓà “:“ ·Ö¸ô¡£
× ......