ÉîÈëÀí½âLinuxÄÚºËÖеÄÁ´±í
×î½ü£¬¿ªÊ¼ÑжÁÒ»ÏÂLinuxµÄÄں˴úÂ룬¸ÕÒ»¿ªÊ¼£¬¾ÍÓÐÁîÈ˾ªÌ¾µÄ·¢ÏÖ£¬²»µÃ²»¸Ð̾Äں˴úÂëÉè¼ÆµÃÖ®ÃÀ£¡µ¥ÊÇ×î³£ÓõÄÁ´±íÒ²Éè¼ÆµÃ²»µÃ²»ÁîÈËÅå·þ£¡
1.1.Á´±ílist_head
include/linux/list.h
ºÜ¾µä£¬Á´±íÔÚÄÚºËÖкܳ£Óã¬ÀýÈç¹ÜÀí½ø³Ì£¬½ø³ÌµÄ¸÷¸ö״̬¶ÓÁж¼ÊÇʹÓÃÕâ¸öË«ÏòÁ´±íʵÏֵġ£ÄÚºËÖеÄÁ´±í¶¨Òå³ÉºÍÊý¾ÝÎ޹صÄÐÎʽ£¬¶ø²»ÊÇͨ³£ÎÒÃÇʹÓõÄÁ´±í¸ñʽ£¬ÀýÈç
typedef struct _list{
Elemtype elem;
struct _list *next;
}list;
ÄÚºËÖеÄÁ´±í¶¨ÒåΪ
struct list_head{
struct list_head *next, *prev;
};
¿É¼û£¬Õâ¸öÁ´±í½ÚµãÖв»°üº¬ÈκÎÊý¾Ý£¬Ö»ÓÐÁ½¸öÖ¸Õë¡£µ±ÐèҪʹÓÃÁ´±íÀ´×éÖ¯Êý¾Ý½á¹¹Ê±£¬Õâ¸ö½á¹¹ÖоͰüº¬Ò»¸ölist_head³ÉÔ±£¬ÀýÈç
struct _list_struct{
Elemtype elem;
struct list_head list;
...
};
ÏÔ¶øÒ×¼û£¬Á´±íʵÏֳɺÍÊý¾Ý·ÖÀëµÄºÃ´¦ÊÇ£¬²»ÓÃΪÿÖÖÊý¾Ý¶¼¶¨ÒåÁ´±í²Ù×÷£¬¿ÉÒÔʹÓÃͳһµÄÁ´±í²Ù×÷¼´¿É¡£µ«ÊÇÎÊÌâÊÇ£ºÖ»ÖªµÀÊý¾Ý³ÉÔ±listµÄµØÖ·£¬ÔõÑùÈ¥·ÃÎÊ×ÔÉíÒÔ¼°ÆäËû³ÉÔ±ÄØ£¿
#define list_entry(ptr,type,member) \
container_of(ptr,type,member)
¶øcontainer_of(ptr,type,member)ºê¶¨ÒåÔÚinclude/list/kernel.hÖÐ
#define container_of(ptr,type,member) ({
const typeof( ((type *)0)->member) *__ptr=ptr;
(type *)( (char *)__ptr - offsetof(type,member));})
ÉÏÃæµÄºêÓм¸µãÐèÒª½âÊÍ£º
1£©typeof(type) ºê
typeof(type) ºê·µ»Ø±äÁ¿typeµÄÀàÐÍ£¬ÀýÈ磺int a; typeof(a) b;µÈ¼ÛÓÚint b;
2£©offsetof(type,member)ºê
Ëü¶¨ÒåÔÚinclude/linx/stddef.hÖУ¬ÈçÏ£º
#define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)
Õâ¸öºê·µ»ØmemberÔÚtypeÀàÐÍÖеÄÆ«ÒÆÁ¿£¬typeÊÇÒ»¸ö½á¹¹£¬ÀýÈ磺
typeof(list_head,next);·µ»Ø0£¬Ò²¾ÍÊÇ·µ»ØÏà¶ÔÓڽṹÆðʼµØÖ·µÄÆ«ÒÆÁ¿¡£
3£©ÎªÊ²Ã´ÒªÊ¹ÓÃtypeof(((type *)0)->member)À´¶¨ÒåÖ¸Õë __ptr£¬¶ø²»ÊÇÕâÑù£º
const typeof(member) *__ptr=ptr;£¿
Æäʵ£¬Õâ¸öºÜ¼òµ¥£¬ÒòΪmemberÊǽṹµÄ³É
Ïà¹ØÎĵµ£º
½éÉÜÒ»ÖÖ¶àLINUXϵͳµÄʵÏÖ·½·¨
Ä¿Ç°,LINUX°æ±¾Öڶ࣬×ÀÃæ»·¾³°üÀ¨Gnome,KDEµÈ£¬ÔÚһ̨µçÄÔÉÏ°²×°WindowsϵͳºÍ¶àLINUXϵͳºÜÓбØÒª.ÕâÀï½éÉÜÒ»ÖÖ·½·¨£¬¶à¸öLINUXϵͳ֮¼ä¸÷×Ô¶ÀÁ¢,»¥²»·ÃÎÊ£¬¸÷×Ô¶¼ÄÜ·ÃÎÊWindows×ÊÔ´£® ......
LinuxÄÚºËÔÚÆô¶¯µÄʱºò£¬ÄܽÓÊÕijЩÃüÁîÐÐÑ¡Ïî»òÆô¶¯Ê±²ÎÊý¡£µ±Äں˲»ÄÜʶ±ðijЩӲ¼þ½ø¶ø²»ÄÜÉèÖÃÓ²¼þ²ÎÊý»òÕßΪÁ˱ÜÃâÄں˸ü¸ÄijЩ²ÎÊýµÄÖµ£¬¿ÉÒÔͨ¹ýÕâÖÖ·½Ê½ÊÖ¶¯½«ÕâЩ²ÎÊý´«µÝ¸øÄںˡ£
¡¡¡¡Èç¹û²»Ê¹ÓÃÆô¶¯¹ÜÀíÆ÷£¬±ÈÈçÖ±½Ó´ÓBIOS»òÕß°ÑÄÚºËÎļþÓÓcp zImage /dev/fd0”µÈ·½·¨Ö±½Ó´ÓÉ豸Æô¶¯£¬¾Í²»Ä ......
df ÊÇÀ´×ÔÓÚcoreutils Èí¼þ°ü£¬ÏµÍ³°²×°Ê±£¬¾Í×Ô´øµÄ£»ÎÒÃÇͨ¹ýÕâ¸öÃüÁî¿ÉÒԲ鿴´ÅÅ̵ÄʹÓÃÇé¿öÒÔ¼°Îļþϵͳ±»¹ÒÔصÄλÖá£
¾ÙÀý£º
[root@localhost beinan]# df -lh
Filesystem ÈÝÁ¿ ÒÑÓà ¿ÉÓà ÒÑÓÃ% ¹ÒÔصã
/dev/hda8 11G 6.0G 4.4G 58% /
/dev/shm 236M 0 236M 0% /dev/shm
/dev/sda1 56G 22G 35G 39% /mnt/sda1
......
man -k [keyword ] ÔÚwhatis Êý¾Ý¿âÖвéÕҹؼü×Ö£»
•man -f [keyword ] ͬÉÏ£¬µ«keyword Ϊһ¸öÕû×Ö(whole word)
•man -a [keyword ] ͨ³£man »áÏÔʾµÚÒ»¸öÕÒµ½µÄkeywordµÄman page£¬µ« ......