Linux ÄÚºË/sys Îļþϵͳ½éÉÜ[ת]
ת×Ô:http://www.xxlinux.com/linux/article/development/kernel/20090112/14828.html
sysfs ÊÇ Linux ÄÚºË
ÖÐÉè¼Æ½ÏеÄÒ»ÖÖÐéÄâµÄ»ùÓÚÄÚ´æµÄÎļþϵͳ£¬ËüµÄ×÷ÓÃÓë proc ÓÐЩÀàËÆ£¬µ«³ýÁËÓë proc ÏàͬµÄ¾ßÓв鿴ºÍÉ趨ÄÚºË
²ÎÊý¹¦ÄÜÖ®Í⣬»¹ÓÐΪ Linux ͳһÉ豸ģÐÍ×÷Ϊ¹ÜÀíÖ®Óá£Ïà±ÈÓÚ proc Îļþϵͳ£¬Ê¹Óà sysfs µ¼³öÄÚºË
Êý¾ÝµÄ·½Ê½¸üΪͳһ£¬²¢ÇÒ×éÖ¯µÄ·½Ê½¸üºÃ£¬ËüµÄÉè¼Æ´Ó proc ÖÐÎüÈ¡Á˺ܶà½Ìѵ¡£±¾ÎÄ¾Í sysfs µÄ¹ÒÔصã /sys Ŀ¼½á¹¹¡¢ÆäÓë Linux ͳһÉ豸ģÐ͵ĹØϵ¡¢³£¼ûÊôÐÔÎļþµÄÓ÷¨µÈ·½Ãæ¶Ô sysfs ×÷ÈëÃÅ
½éÉÜ£¬²¢ÇÒ¾ÍÄÚºË
±à³Ì·½Ã棬ÒÔ¾ßÌåµÄÀý×ÓÀ´Õ¹Ê¾ÈçºÎÌí¼Ó sysfs Ö§³Ö¡£
sysfs µÄÀúÊ·£¬ÆäÓë proc µÄ¹Øϵ£¿
sysfs ±¾Éí²¢²»ÊÇÒ»ÏîºÜеļ¼Êõ£¬µ«±ÊÕß·¢ÏÖ£¬ËäÈ» sysfs ´Ó2003Äêµ®ÉúÖÁ½ñÒÑÓÐ5Ä꣬µ«ÈËÃÇ¶Ô sysfs ÒÀȻȱ·¦Á˽⣻һ¸öºÜÖØÒªµÄÔÒò¿ÉÄÜÊÇȱ·¦Îĵµ£¬ Linux ÄÚºË
·½Ãæ×îÖØÒªµÄÀíÂÛÊé¼®“Linux É豸Çý¶¯µÚ3°æ”ºÍ“Àí½â Linux ÄÚºË
µÚ2°æ”¶¼µ®ÉúÓÚ2003ÄêÇ°ºó£¬²¢ÇÒ´ÓÄÇÒÔºóÉÐδÓÐÔÙ°æ¹ý£¬ÆäËüһЩÖØÒªÎÄÕÂÔò¶à¶Ô sysfs Óë proc ÏàÌá²¢ÂÛÇÒ¾ÙÀý³£³£Ö»ÓÐ proc£¬Õâµ¼ÖÂÁË sysfs µÄºÜ¶àÖØÒª¸ÅÄîÖÁ½ñÈÔÏÊΪÈËÖª£¬Òò´ËÓбØÒª¶Ô sysfs ×÷¸ü¶à½éÉÜ£¬ÕâÊÇд×÷±¾ÎĵijõÖÔ¡£
sysfs Óë /sys
sysfs Îļþϵͳ×ÜÊDZ»¹ÒÔØÔÚ /sys ¹ÒÔصãÉÏ¡£ËäÈ»ÔÚ½ÏÔçÆÚµÄ2.6ÄÚºË
ϵͳÉϲ¢Ã»Óй涨 sysfs µÄ±ê×¼¹ÒÔØλÖ㬿ÉÒÔ°Ñ sysfs ¹ÒÔØÔÚÈκÎλÖ㬵«½Ï½üµÄ2.6ÄÚºË
ÐÞ
ÕýÁËÕâÒ»¹æÔò£¬ÒªÇó sysfs ×ÜÊǹÒÔØÔÚ /sys Ŀ¼ÉÏ£»Õë¶ÔÒÔÇ°µÄ sysfs ¹ÒÔØλÖò»¹Ì¶¨»òûÓбê×¼±»¹ÒÔØ£¬ÓÐЩ³ÌÐò´Ó
/proc/mounts ÖнâÎö³ö sysfs ÊÇ·ñ±»¹ÒÔØÒÔ¼°¾ßÌåµÄ¹ÒÔص㣬Õâ¸ö²½ÖèÏÖÔÚÒѾ²»ÐèÒªÁË¡£Çë²Î¿¼¸½Â¼¸ø³öµÄ
sysfs-rules.txt ÎļþÁ´½Ó¡£
sysfs Óë proc
sysfs Óë proc Ïà±ÈÓкܶàÓŵ㣬×îÖØÒªµÄĪ¹ýÓÚÉè¼ÆÉϵÄÇåÎú¡£Ò»¸ö proc ÐéÄâÎļþ¿ÉÄÜÓÐÄÚ²¿¸ñʽ£¬Èç /proc/scsi/scsi £¬ËüÊǿɶÁ¿ÉдµÄ£¬(ÆäÎļþȨÏÞ±»´íÎóµØ±ê¼ÇΪÁË 0444 £¡£¬ÕâÊÇÄÚºË
µÄ
Ò»¸öBUG)£¬²¢ÇÒ¶Áд¸ñʽ²»Ò»Ñù£¬´ú±í²»Í¬µÄ²Ù×÷£¬Ó¦ÓóÌÐòÖжÁµ½ÁËÕâ¸öÎļþµÄÄÚÈÝÒ»°ã»¹ÐèÒª½øÐÐ×Ö·û´®½âÎö£¬¶øÔÚдÈëʱÐèÒªÏÈÓÃ×Ö·û´®¸ñʽ»¯°´Ö¸¶¨µÄ
¸ñʽдÈë×Ö·û´®½øÐвÙ×÷£»Ïà±È¶øÑÔ£¬ sysfs µÄÉè¼ÆÔÔòÊÇÒ»¸öÊôÐÔÎļþÖ»×öÒ»¼þÊÂÇ飬 sysfs
ÊôÐÔÎļþÒ»°ãÖ»ÓÐÒ»¸öÖµ£¬Ö±½Ó¶ÁÈ¡»òдÈë¡
Ïà¹ØÎĵµ£º
Ò»¡¢ÏµÍ³ÉèÖÃÓë¹ÜÀí
1.alias
˵Ã÷£ºÎªÃüÁîÉèÖñðÃû¡¢ÏÔʾ±ðÃûÉèÖá£
Óï·¨£ºalias [±ðÃû]=[Ö¸ÁîÃû³Æ]£ºÎª[Ö¸ÁîÃû³Æ]ÆðÒ»¸ö±ðÃû¡£
alias [±ðÃû]£ºÏÔʾ³ö[±ðÃû]Ëù¶ÔÓ¦µÄÃüÁî¡£
alias£ºÏÔʾËùÓбðÃûÉèÖá£
2.apmsleep
˵Ã÷£º½øÈë¹ÒÆð»òµÈ´ý״̬¡£
Óï·¨£ºapmsleep hh:mm
²ÎÊý£ºhh:mmÖ¸¶¨½øÈë¹ÒÆð»òµÈ´ý״̬µÄʱ¼ä¡£
......
linux/unixÏÂûÓÐWaitforMultipleObjects,ҲûÓÐÀàËƵÄAPI,ͬÑù»ùÓÚBSD UnixÄں˵ÄMac OS ҲûÓÐÏàËƹ¦Äܵĺ¯Êý£¬ÕâÊÇ´ó¼Ò¶¼ÖªµÀ²¢ÇÒÓôÃƵġ£Èç¹ûÒª½«Ò»¸ö¶àÏ̳߳ÌÐò´ÓwindowsÏÂÒÆÖ²µ½Ê¹ÓÃPosix¶àÏ̵߳ÄϵͳÏ£¬×îºÃÏÈÔÚÐÄÖÐĬÄîÊ®±é“no have WaitforMultipleObjects... ...”È»ºóÖ»ÄÜ¿´ÄãµÄRPÈçºÎÄòÍÞ.
......
Ò»)ANSI clockº¯Êý
1)¸ÅÊö:
clock º¯ÊýµÄ·µ»ØÖµÀàÐÍÊÇclock_t,Ëü³ýÒÔCLOCKS_PER_SECÀ´µÃ³öʱ¼ä,Ò»°ãÓÃÁ½´Îclockº¯ÊýÀ´¼ÆËã½ø³Ì×ÔÉíÔËÐеÄʱ¼ä.
ANSI clockÓÐÈý¸öÎÊÌâ:
1)Èç¹û³¬¹ýÒ»¸öСʱ,½«Òªµ¼ÖÂÒç³ö.
2)º¯ÊýclockûÓп¼ÂÇCPU±»×Ó½ø³ÌʹÓõÄÇé¿ö.
3)Ò²²»ÄÜÇø·ÖÓû§¿Õ¼äºÍÄں˿ռä.
ËùÒÔclockº¯ÊýÔÚlinuxϵͳÉϱäµÃ ......
1¡¢vi /etc/resolv.conf
Ôö¼ÓÒÔÏÂÄÚÈÝ£º
nameserver DNSserver_ip_address1
nameserver
DNSserver_ip_address2
ÈçÏ£º
[root@REDHATAS5 /]# cat /etc/resolv.conf
nameserver 192.168.88.1
2¡¢²âÊÔDNSÊÇ·ñÉúЧ
[root@Develop-Server ~]# nslookup www.baidu.com
Server: &nb ......
Linux»·¾³½ø³Ì¼äͨÐÅ£¨Î壩: ¹²ÏíÄڴ棨Ï£©
ÎĵµÑ¡Ïî
´òÓ¡±¾Ò³
½«´ËÒ³×÷Ϊµç×ÓÓʼþ·¢ËÍ
¼¶±ð£º ³õ¼¶
Ö£ÑåÐË (mlinux@163.com), ¹ú·À¿Æ´ó¹¥¶Á²©Ê¿Ñ§Î»
2003 Äê 5 ÔÂ 01 ÈÕ
ÔÚ¹²ÏíÄڴ棨ÉÏ£©ÖУ¬Ö÷ҪΧÈÆ×Åϵͳµ÷ÓÃmmap()½øÐÐÌÖÂ۵ģ¬±¾²¿·Ö½«ÌÖÂÛϵͳV¹²ÏíÄڴ棬²¢Í¨¹ýʵÑé½á¹û¶Ô±ÈÀ´²ûÊöÁ½ÕßµÄÒìͬ¡£Ïµ ......