ÏàʶLinuxÖÐext2ÎļþϵͳµÄ´ÅÅ̽ṹ
ÔÚLinux²Ù×÷ϵͳÖУ¬Ê¹ÓõÄÎļþϵͳÓÐÐí¶àÖÖ£¬ÆäÖÐext2ÎļþϵͳÊÇ×îΪ»ù´¡ºÍ³£¼ûµÄÒ»ÖÖ¡£Ïàʶext2ÎļþϵͳµÄ´ÅÅ̽ṹ¹ØÓÚÃ÷È·ÎļþϵͳµÄÊÂÇéÔÀíºÍÊý¾Ý´æ´¢·½·¨ºÜÊÇÖ÷Òª¡£ÔÚ±¾ÎÄÖУ¬½«ÏÈÈÝext2ÎļþϵͳµÄ´ÅÅ̽ṹ£¬°üÀ¨³¬µÈ¿é¡¢¿é×éÐÎò·û±í¡¢inode±í¡¢Êý¾Ý¿éµÈÄÚÈÝ£¬²¢ÌṩÏêϸµÄ´úÂëʾÀý×ÊÖú¶ÁÕ߸üºÃµØÃ÷È·¡£
Ò»¡¢³¬µÈ¿é£¨Super Block£©
ÔÚext2ÎļþϵͳÖУ¬³¬µÈ¿éÊÇÎļþϵͳµÄÔªÊý¾ÝÖ®Ò»£¬ÓÃÓڼͼÕû¸öÎļþϵͳµÄ»ù±¾ÐÅÏ¢¡£³¬µÈ¿éͨ³£Î»ÓÚ´ÅÅ̵ÄÆðʼλÖã¬ÓÃÓÚÐÎòÕû¸öÎļþϵͳµÄ״̬ºÍ½á¹¹¡£ÏÂÃæÊÇÒ»¸ö¼ò»¯µÄ³¬µÈ¿é½á¹¹Ê¾Àý£º
struct ext2_super_block { uint32_t s_inodes_count; // ÎļþϵͳÖÐinode×ÜÊý uint32_t s_blocks_count; // ÎļþϵͳÖпé×ÜÊý uint32_t s_free_blocks_count; // ¿ÕÏпéÊýÄ¿ uint32_t s_free_inodes_count; // ¿ÕÏÐinodeÊýÄ¿ // ÆäËû×ֶΠ// ... };
µÇ¼ºó¸´ÖÆ
³¬µÈ¿éÖаüÀ¨ÁËÎļþϵͳÖÐinode×ÜÊý¡¢¿é×ÜÊý¡¢¿ÕÏпéÊýÄ¿¡¢¿ÕÏÐinodeÊýÄ¿µÈÐÅÏ¢¡£Í¨¹ý¶ÁÈ¡³¬µÈ¿é£¬¿ÉÒÔ»ñÈ¡ÎļþϵͳµÄÕûÌåÐÅÏ¢ÒÔ¼°×´Ì¬¡£
¶þ¡¢¿é×éÐÎò·û±í£¨Block Group Descriptor Table£©
ÔÚext2ÎļþϵͳÖУ¬´ÅÅ̱»»®·ÖΪÈô¸É¿é×飨Block Group£©¡£Ã¿¸ö¿é×é°üÀ¨Èô¸É¸öÊý¾Ý¿é¡¢inodeÒÔ¼°¿é×éÐÎò·û±í¡£¿é×éÐÎò·û±í´æ´¢ÁËÿ¸ö¿é×éµÄ»ù±¾ÐÅÏ¢£¬Èçinode±íµÄÆðʼ¿éºÅ¡¢¿ÕÏпéλͼµÄÆðʼ¿éºÅµÈ¡£ÏÂÃæÊÇÒ»¸ö¼ò»¯µÄ¿é×éÐÎò·û±í½á¹¹Ê¾Àý£º
struct ext2_group_desc { uint32_t bg_block_bitmap; // ¿ÕÏпéλͼµÄÆðʼ¿éºÅ uint32_t bg_inode_bitmap; // inodeλͼµÄÆðʼ¿éºÅ uint32_t bg_inode_table; // inode±íµÄÆðʼ¿éºÅ // ÆäËû×ֶΠ// ... };
µÇ¼ºó¸´ÖÆ
ͨ¹ý¿é×éÐÎò·û±í£¬¿ÉÒÔ²éÕÒµ½Ã¿¸ö¿é×éÖÐÒªº¦Êý¾Ý½á¹¹µÄλÖã¬Àû±ãÎļþϵͳµÄÖÎÀíºÍ²Ù×÷¡£
Èý¡¢inode±í£¨Inode Table£©
ÔÚext2ÎļþϵͳÖУ¬Ã¿¸öÎļþºÍĿ¼¶¼¶ÔÓ¦Ò»¸öinode½Úµã£¬ inode½Úµã¼Í¼ÁËÎļþµÄÊôÐÔÐÅÏ¢£¨ÈçÎļþ¾Þϸ¡¢È¨ÏÞ¡¢Ê±¼ä´ÁµÈ£©ÒÔ¼°ÎļþÊý¾Ý¿éµÄÖ¸Ïò¡£inode±í´æ´¢ÁËËùÓÐinode½ÚµãµÄÐÅÏ¢£¬Í¬Ê±Ò²°üÀ¨¿ÕÏÐinodeλͼÓÃÓÚÖÎÀíinodeµÄ·ÖÅɺÍÊÍ·Å¡£ÏÂÃæÊÇÒ»¸ö¼ò»¯µÄinode½á¹¹Ê¾Àý£º
struct ext2_inode { mode_t i_mode; // ÎļþÀàÐͺÍȨÏÞ uint32_t i_size; // Îļþ¾Þϸ uint32_t i_block[EXT2_N_BLOCKS]; // ÎļþÊý¾Ý¿éÖ¸Õë // ÆäËû×ֶΠ// ... };
µÇ¼ºó¸´ÖÆ
ͨ¹ýinode±í£¬¿ÉÒÔ²éÕÒµ½ÎļþµÄinode½Úµã£¬½ø¶ø»ñÈ¡ÎļþµÄÊôÐÔÐÅÏ¢ºÍÊý¾Ý¿éÖ¸Õë¡£
ËÄ¡¢Êý¾Ý¿é£¨Data Blocks£©
ÔÚext2ÎļþϵͳÖУ¬Êý¾Ý¿éÓÃÓÚ´æ´¢ÎļþµÄÏÖʵÊý¾ÝÄÚÈÝ¡£Êý¾Ý¿é±»·ÖÅɸøÎļþʹÓã¬ÎļþµÄÊý¾Ý»á±»ÊèÉ¢´æ´¢ÔÚ²î±ðµÄÊý¾Ý¿éÖС£¹ØÓÚСÎļþ£¬Êý¾Ý¿ÉÒÔÖ±½Ó´æ´¢ÔÚinode½ÚµãÖеÄÊý¾Ý¿éÖ¸ÕëÖУ»¹ØÓÚ´óÎļþ£¬Êý¾ÝÔò»á±»´æ´¢ÔÚ¼ä½Ó¡¢Ë«¼ä½Ó¡¢Èý¼ä½Ó¿éÖС£ÏÂÃæÊÇÒ»¸ö¼ò»¯µÄÊý¾Ý¿éÖ¸Õë½á¹¹Ê¾Àý£º
struct ext2_dir_block { uint32_t block_ptr[EXT2_PTRS_PER_BLOCK]; // Ö¸ÏòÊý¾Ý¿éµÄÖ¸Õë // ÆäËû×ֶΠ// ... };
µÇ¼ºó¸´ÖÆ
Êý¾Ý¿éͨ¹ýÖ¸ÕëµÄ·½·¨ÏàÁ¬£¬ÐγÉÎļþµÄÊý¾Ý´æ´¢Á´±í¡£Í¨¹ýÊý¾Ý¿é£¬¿ÉÒÔ»á¼ûÎļþµÄÏÖʵÊý¾ÝÄÚÈÝ¡£
ͨ¹ýÒÔÉ϶Ôext2ÎļþϵͳµÄ´ÅÅ̽ṹÏÈÈÝ£¬ÎÒÃÇ¿ÉÒÔ¸üºÃµØÃ÷È·ÎļþϵͳµÄ×éÖ¯½á¹¹ºÍÊý¾Ý´æ´¢·½·¨¡£ÔÚÏÖʵ±à³ÌÖУ¬¿ÉÒÔͨ¹ý¶ÁÈ¡³¬µÈ¿é¡¢¿é×éÐÎò·û±í¡¢inode±íºÍÊý¾Ý¿éÀ´²Ù×÷ºÍÖÎÀíÎļþϵͳ¡£Ï£Íû±¾ÎÄÄÜ×ÊÖú¶ÁÕ߸üÉîÈëµØÏàʶLinuxÖÐext2ÎļþϵͳµÄ´ÅÅ̽ṹ¡£
ÒÔÉϾÍÊÇÏàʶLinuxÖÐext2ÎļþϵͳµÄ´ÅÅ̽ṹµÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡