Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

LinuxÄÚºËÖжÁдÎļþ


×î½üÔÚkernel ÀïÃæ coding,  ÕÒÀ´Ò»Ð©×ÊÁÏ Ë³ÊÖÌùÀ´£¬·½±ã²éÕÒ¡££¨¸Ðлԭ×÷ÕßµÄŬÁ¦£¬ÈôÓаæȨÎÊÌ⣬ÇëÁªÏµ£©
 
 
 
ÓÐʱºòÐèÒªÔÚLinux kernel£­£­´ó¶àÊÇÔÚÐèÒªµ÷ÊÔµÄÇý¶¯³ÌÐò£­£­ÖжÁдÎļþÊý¾Ý¡£ÔÚkernelÖвÙ×÷ÎļþûÓбê×¼¿â¿ÉÓã¬ÐèÒªÀûÓÃkernelµÄһЩº¯Êý£¬ÕâЩº¯ÊýÖ÷ÒªÓУº filp_open() filp_close(), vfs_read() vfs_write()£¬set_fs()£¬get_fs()µÈ£¬ÕâЩº¯ÊýÔÚlinux/fs.hºÍasm/uaccess.hÍ·ÎļþÖÐÉùÃ÷¡£ÏÂÃæ½éÉÜÖ÷Òª²½Ö裺
1. ´ò¿ªÎļþ
filp_open()ÔÚkernelÖпÉÒÔ´ò¿ªÎļþ£¬ÆäÔ­ÐÎÈçÏ£º
strcut file* filp_open(const char* filename, int open_mode, int mode);
¸Ãº¯Êý·µ»Østrcut file*½á¹¹Ö¸Õ룬¹©ºó¼Ìº¯Êý²Ù×÷ʹÓ㬸÷µ»ØÖµÓÃIS£ßERR£¨£©À´¼ìÑéÆäÓÐЧÐÔ¡£
²ÎÊý˵Ã÷
filename£º ±íÃ÷Òª´ò¿ª»ò´´½¨ÎļþµÄÃû³Æ£¨°üÀ¨Â·¾¶²¿·Ö£©¡£ÔÚÄÚºËÖдò¿ªµÄÎļþʱÐèҪעÒâ´ò¿ªµÄʱ»ú£¬ºÜÈÝÒ׳öÏÖÐèÒª´ò¿ªÎļþµÄÇý¶¯ºÜÔç¾Í¼ÓÔز¢´ò¿ªÎļþ£¬µ«ÐèÒª´ò¿ªµÄÎļþËùÔÚÉ豸»¹²»ÓйÒÔص½ÎļþϵͳÖУ¬¶øµ¼Ö´ò¿ªÊ§°Ü¡£
open_mode£º ÎļþµÄ´ò¿ª·½Ê½£¬ÆäÈ¡ÖµÓë±ê×¼¿âÖеÄopenÏàÓ¦²ÎÊýÀàËÆ£¬¿ÉÒÔÈ¡O_CREAT,O_RDWR,O_RDONLYµÈ¡£
mode£º  ´´½¨ÎļþʱʹÓã¬ÉèÖô´½¨ÎļþµÄ¶ÁдȨÏÞ£¬ÆäËüÇé¿ö¿ÉÒÔ´ÒÂÔÉèΪ0
2. ¶ÁдÎļþ
kernelÖÐÎļþµÄ¶Áд²Ù×÷¿ÉÒÔʹÓÃvfs_read()ºÍvfs_write£¬ÔÚʹÓÃÕâÁ½¸öº¯ÊýÇ°ÐèҪ˵Ã÷Ò»ÏÂget_fs()ºÍ set_fs()ÕâÁ½¸öº¯Êý¡£
vfs_read() vfs_write()Á½º¯ÊýµÄÔ­ÐÎÈçÏ£º
ssize_t vfs_read(struct file* filp, char __user* buffer, size_t len, loff_t* pos);
ssize_t vfs_write(struct file* filp, const char __user* buffer, size_t len, loff_t* pos);
×¢ÒâÕâÁ½¸öº¯ÊýµÄµÚ¶þ¸ö²ÎÊýbuffer£¬Ç°Ã涼ÓÐ__userÐÞÊηû£¬Õâ¾ÍÒªÇóÕâÁ½¸öbufferÖ¸Õ붼Ӧ¸ÃÖ¸ÏòÓÿյÄÄڴ棬Èç¹û¶Ô¸Ã²ÎÊý´«µÝkernel¿Õ¼äµÄÖ¸Õ룬ÕâÁ½¸öº¯Êý¶¼»á·µ»Øʧ°Ü-EFAULT¡£µ«ÔÚKernelÖУ¬ÎÒÃÇÒ»°ã²»ÈÝÒ×Éú³ÉÓû§¿Õ¼äµÄÖ¸Õ룬»òÕß²»·½±ã¶ÀÁ¢Ê¹ÓÃÓû§¿Õ¼äÄڴ档ҪʹÕâÁ½¸ö¶Áдº¯ÊýʹÓÃkernel¿Õ¼äµÄbufferÖ¸ÕëÒ²ÄÜÕýÈ·¹¤×÷£¬ÐèҪʹÓÃset_fs()º¯Êý»òºê£¨set_fs()¿ÉÄÜÊǺ궨Ò壩£¬Èç¹ûΪº¯Êý£¬ÆäÔ­ÐÎÈçÏ£º
void set_fs(mm_segment_t fs);
¸Ãº¯ÊýµÄ×÷ÓÃÊǸıäkernel¶ÔÄÚ´æµØÖ·¼ì²éµÄ´¦Àí·½Ê½£¬Æäʵ¸Ãº¯ÊýµÄ²ÎÊýfsÖ»ÓÐÁ½¸öÈ¡Öµ£ºUSER£ßDS£¬KERNEL£ßDS£¬·Ö±ð´ú±íÓû§¿Õ¼äºÍÄں˿ռ䣬ĬÈÏÇé¿öÏ£¬kernelȡֵΪUSER_DS£¬¼´¶ÔÓû§¿Õ¼äµØÖ·¼ì²é²¢×ö±ä»»¡


Ïà¹ØÎĵµ£º

ʵսLinux Bluetooth±à³Ì(Áù) L2CAP±à³ÌʵÀý

ÀýÒ»£º·¢ËÍSignaling Packet£º
Signaling CommandÊÇ2¸öBluetoothʵÌåÖ®¼äµÄL2CAP²ãÃüÁî´«Êä¡£ËùÒÔµÃSignaling CommandʹÓÃCID 0x0001.
¶à¸öCommand¿ÉÒÔÔÚÒ»¸öC-frame£¨control frame£©Öз¢ËÍ¡£
 Èç¹ûÒªÖ±½Ó·¢ËÍSignaling Command.ÐèÒª½¨Á¢SOCK_RAWÀàÐ͵ÄL2CAPÁ¬½ÓSocket¡£ÕâÑù²ÅÓлú»á×Ô¼ºÌî³äCommand Code£¬Identi ......

linux 0.11 Îļþϵͳ£¨Èý£©

Ŀ¼ÏîºÍ³¬¼¶¿é£¬½ÚµãµÄ¸ÅÄͬ£¬ËüÔÚÉ豸ÉÏûÓжÔÓ¦µÄ´ÅÅÌÊý¾Ý½á¹¹¡£Ïà·´£¬ËüÊÇĿ¼ÎÄ ¼þµÄÒ»²¿·Ö¡£linuxÖÐĿ¼ҲÊÇÒ»ÖÖÎļþ£¬ÀàÐÍÊÇ'd'¡£µ«ÊÇĿ¼ÖеÄÄÚÈݺÍÆÕͨÎļþ²»Í¬£¬ËüÊÇÓÉĿ¼Ïî×é³ÉµÄ¡£×¢ÒâĿ¼Ïî²»ÊÇĿ¼¡£ÎÒÃǾ­³£Ó÷¾¶Ãû Ö´ÐÐÏà¹Ø²Ù×÷£¬Ä¿Â¼Ïî¾ÍÊÇΪÁ˲éÕÒ·½±ãµÄ¡£
struct dirt_entry{
    ......

linux dfisk, du,df(´ÅÅÌ¿Õ¼äÐÅÏ¢)ÃüÁîÏê½â


dfÃüÁîÏêϸÓ÷¨
 
a£ºÏÔʾȫ²¿µÄµµ°¸ÏµÍ³ºÍ¸÷·Ö¸îÇøµÄ´ÅÅÌʹÓÃÇéÐÎ
i£ºÏÔʾi -nodesµÄʹÓÃÁ¿
k£º´óСÓÃkÀ´±íʾ (ĬÈÏÖµ)
t£ºÏÔʾijһ¸öµµ°¸ÏµÍ³µÄËùÓзָîÇø´ÅÅÌʹÓÃÁ¿
x£ºÏÔʾ²»ÊÇijһ¸öµµ°¸ÏµÍ³µÄËùÓзָîÇø´ÅÅÌʹÓÃÁ¿
T£ºÏÔʾÿ¸ö·Ö¸îÇøËùÊôµÄµµ°¸ÏµÍ³Ãû³Æ
³£ÓÃÃüÁdf -hi
 
²Ù×÷Ïê½â
&n ......

LinuxÆô¶¯¹ý³ÌÈ«½Ó´¥

¹ØÓÚWindowsÆô¶¯¹ý³Ì½éÉܵÄÎÄÕ¿Éν¶àÈçţ룬¶ø¶ÔÓÚLinuxµÄ½éÉÜÈ´ÊÇ·ïë÷ë½Ç¡£·²ÊÇÔø¾­Ê¹ÓùýLinuxµÄÓû§¿ÉÄܶ¼»á×¢Òâµ½£¬µ±¼ÆËã»úÆô¶¯Ê±£¬ÆÁÄ»ÉÏ»á³öÏֺܶàÐÅÏ¢¡£Ò»°ãÇé¿öÏ£¬ÕâЩÐÅÏ¢ÎÒÃÇ¿ÉÒÔͨ¹ýÒÔϵÄÃüÁî¿´µ½£º
¡¡¡¡
¡¡¡¡cat /var/log/dmesg | more
¡¡¡¡
¡¡¡¡
¡¡¡¡
¡¡¡¡ÕâЩÐÅÏ¢¾¿¾¹ÓÐʲôº¬Ò壿Õâ¸öÎÊÌâ¿´Æð ......

ѧϰlinux vi ʹÓÃ

Ŀ¼
1¡¢¹ØÓÚÎı¾±à¼­Æ÷£»
2¡¢vi ±à¼­Æ÷£»
3¡¢vi ±à¼­Æ÷µÄʹÓ÷½·¨£»
3.1 ÈçºÎµ÷ÓÃvi £»
3.2 vi µÄÈýÖÖÃüÁîģʽ£»
3.3 ÎļþµÄ±£´æºÍÍ˳ö£»
3.4 ¹â±êÒƶ¯£»
3.5
²åÈëģʽ£¨Îı¾µÄ²åÈ룩£»
3.6 Îı¾ÄÚÈݵÄɾ³ý²Ù×÷£»
3.7 »Ö¸´Ð޸ļ°»Ö¸´É¾³ý²Ù×÷£»
3.8 ¿ÉÊÓģʽ£»
3.9
¸´ÖƺÍÕ³ÌûµÄ²Ù×÷£»
3.10 ¹ØÓÚÐкţ»
......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ