Data Structures | |
struct | dir_ff |
struct | group_descriptor |
struct | i_node |
struct | super_block |
Defines | |
#define | SIZE_SEC 512 |
#define | N_EXT2_NUMERO_MAGICO 0xEF53 |
#define | P_EXT2_NUMERO_MAGICO 0xEF51 |
#define | EXT2_ERRORS_CONTINUE 1 |
#define | EXT2_ERRORS_RO 2 |
#define | EXT3_ERRORS_PANIC 3 |
#define | EXT2_OS_LINUX 0 |
#define | EXT2_OS_HURD 1 |
#define | EXT2_MASIX 2 |
#define | EXT2_FREEBSD 3 |
#define | EXT2_OS_LITES4 4 |
#define | EXT2_GOOD_OLD_REV 0 |
#define | EXT2DYNAMIC_REV 1 |
#define | EXT2_BAD_INO 0x01 |
#define | EXT2_ROOT_INO 0x02 |
#define | EXT2_ACL_IDX_INO 0x03 |
#define | EXT2_ACL_DARA_INO 0x04 |
#define | EXT2_BOOTLOADER INO 0x05 |
#define | EXT2_UNDEL_DIR_INO 0x06 |
#define | MODE_MASK 0xF000 |
#define | MODE_SOCK 0xC000 |
#define | MODE_LINK 0xA000 |
#define | MODE_FILE 0x8000 |
#define | MODE_BDEV 0x6000 |
#define | MODE_DIR 0x4000 |
#define | MODE_CDEV 0x2000 |
#define | MODE_FIFO 0x1000 |
#define | EXT2_S_ISUID 0x0800 |
#define | EXT2_S_ISGID 0x0400 |
#define | EXT2_S_ISVTX 0x0200 |
#define | EXT2_S_IRWXU 0x01C0 |
#define | EXT2_S_IRUSR 0x0100 |
#define | EXT2_S_IWUSR 0x0080 |
#define | EXT2_S_IXUSR 0x0040 |
#define | EXT2_S_IRWXG 0x0038 |
#define | EXT2_S_IRGRP 0x0020 |
#define | EXT2_S_IWGRP 0x0010 |
#define | EXT2_S_IXGRP 0x0008 |
#define | EXT2_S_IRWXO 0x0007 |
#define | EXT2_S_IROTH 0x0004 |
#define | EXT2_S_IWOTH 0x0003 |
#define | EXT2_S_IXOTH 0x0001 |
#define | EXT2_FT_UNKNOWN 0 |
#define | EXT2_FT_REG_FILE 1 |
#define | EXT2_FT_DIR 2 |
#define | EXT2_FT_CHRDEV 3 |
#define | EXT2_FT_BLKDEV 4 |
#define | EXT2_FT_FIFO 5 |
#define | EXT2_FT_SOCK 6 |
#define | EXT2_FT_SYMLINK 7 |
#define | EXT2_FT_MAX 8 |
#define | DIM_SUPER_BLOCK 1024 |
#define | START_SUPER_BLOCK 1024 |
Functions | |
bool | init_ext2 () |
char * | pwd_ext2 () |
void | ls_ext2 () |
void | cd_ext2 (char *param) |
void | cat_ext2 (char *stringa) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Definition at line 1057 of file ext2.c.
01057 { 01058 struct i_node * ino; 01059 dword i; 01060 word block_file; 01061 char *c=NULL; 01062 int stop=0,ll=0; 01063 dword ino_file; 01064 01065 if (!mount_ext2) 01066 { 01067 kprintf("\n\rUnmounted File System Ext2\n\r"); 01068 return; 01069 } 01070 01071 if (!(ino_file = FindFile(param))) 01072 { 01073 kprintf("\n\rNo such file\n\r"); 01074 return; 01075 } 01076 else if (!(ino=get_inode(ino_file))) 01077 { 01078 // invalid inode number 01079 } 01080 else if (!(isFile(ino)||isFastSymbolicLink(ino))) 01081 { 01082 kprintf("\n\rNot a regular file\n\r"); 01083 return; 01084 } 01085 else if (Open_File(ino,ino->i_mode & MODE_MASK)) 01086 { 01087 // dimensione in blocchi del file 01088 block_file = 0; 01089 stop = 3; 01090 data_block = (byte *)kmalloc(dim_block); 01091 memset(data_block,0,dim_block); 01092 //clrscr(); 01093 set_color(LIGHT_BLUE); 01094 kprintf("filename: %s\n\n\r",param); 01095 set_color(DEFAULT_COLOR); 01096 for (i=0;i<ino->i_size;i++) 01097 { 01098 if (i % dim_block ==0) 01099 { 01100 if ( (err = ReadSectorsLba(0,(int64_t)blocco_to_LBA(ptr_dir[block_file]),spb,(word *)data_block,TRUE)) ) 01101 { 01102 kprintf ("\n\rError reading file data block"); 01103 ShowIdeErrorMessage(err,TRUE); 01104 kfree(ptr_dir); 01105 kfree(data_block); 01106 return; 01107 } 01108 block_file++; 01109 c = (char *)data_block; 01110 } 01111 01112 01113 if (*c==10) // carattere di fine linea 01114 { 01115 stop++; 01116 kprintf("\n\r"); 01117 ll=0; 01118 } 01119 else 01120 { 01121 kputchar(*c); 01122 if(ll++>70) 01123 { 01124 // se la linea eccede in lunghezza la dimensione 01125 //dello schermo si divide in due linee 01126 stop++; 01127 ll = 0; 01128 } 01129 } 01130 01131 c++; 01132 01133 if (((stop)%22)==0) 01134 { 01135 kprintf ("\n\r ------ Continue ------"); 01136 if ( kgetchar()==CTRL_C ) 01137 { 01138 // *** Andrea Righi 2003-10-04 *** // 01139 kfree(data_block); 01140 //********************************// 01141 kprintf("\n\r"); 01142 return; 01143 } 01144 clrscr(); 01145 stop = 3; 01146 set_color(LIGHT_BLUE); 01147 kprintf("filename: %s\n\n\r",param); 01148 set_color(DEFAULT_COLOR); 01149 } 01150 } 01151 kfree(data_block); 01152 } 01153 } |
|
Definition at line 905 of file ext2.c.
00905 { 00906 struct i_node* ino; 00907 int i,j_param,len_param,i_param; 00908 dword ino_dir; 00909 char elem_path[256]; // si usa per il parsing della path 00910 bool errore; 00911 00912 //kprintf("\n\rparam %s",param); 00913 if(!mount_ext2) 00914 { 00915 kprintf("\n\rUnmounted File System Ext2\n\n\r"); 00916 return; 00917 } 00918 00919 if (!strcmp(param,".")) 00920 { 00921 // si rimane nella directory corrente 00922 return; 00923 } 00924 00925 if (!strcmp(param,"/")) 00926 { 00927 // si ritorna alla directory radice 00928 if (!Open_Dir(get_inode(EXT2_ROOT_INO))) 00929 { 00930 // se non si può più aprire la root si smonta il file system 00931 mount_ext2 = FALSE; 00932 return; 00933 } 00934 level = 0; 00935 path_ext2[0]='\0'; 00936 return; 00937 } 00938 00939 00940 if ((level == 0)&&!strcmp(param,"..")) 00941 { 00942 kprintf("\n\rCannot go up from root\n\n\r"); 00943 } 00944 else if ((level ==1)&&!strcmp(param,"..")) 00945 { 00946 // si ritorna alla directory radice 00947 if (!Open_Dir(get_inode(EXT2_ROOT_INO))) 00948 { 00949 // se non si può più aprire la root si smonta il file system 00950 mount_ext2 = FALSE; 00951 return; 00952 } 00953 level = 0; 00954 path_ext2[0]='\0'; 00955 ino_current_dir = EXT2_ROOT_INO; 00956 } 00957 else 00958 { 00959 00960 errore = FALSE; 00961 // dobbiamo effettuare il salvataggio dei componenti 00962 memcpy(&path_ext2_backup,&path_ext2,1024); 00963 //kprintf ("\n\rpath_ext2_backup : %s\n\r",path_ext2_backup); 00964 level_backup = level; 00965 ino_dir_backup = ino_current_dir; 00966 00967 // dobbiamo fare il parsing della path 00968 i_param = 0; 00969 if (param[0]=='.'&¶m[1]=='/') 00970 { 00971 // ./ sta ad indicare restiamo nella dir corrente 00972 // non ha senso riaprirla 00973 i_param = 2; 00974 } 00975 if (param[strlen(param)-1]=='/') 00976 { 00977 len_param = strlen(param)-1; 00978 } 00979 else len_param = strlen(param); 00980 //kprintf ("\n\rlen_param : %u\n\r",len_param); 00981 00982 for (j_param=0;i_param<=len_param;i_param++) 00983 if ((param[i_param]=='/')||i_param==len_param) 00984 { 00985 elem_path[j_param]='\0'; 00986 j_param = 0; 00987 //kprintf ("\n\relem_path : %s\n\r",elem_path); 00988 if (!(ino_dir=FindFile(elem_path))) 00989 { 00990 // non esiste nella directory corrente la sottodirectory param 00991 kprintf("\n\rDirectory no match\n\n\r"); 00992 errore = TRUE; 00993 break; 00994 } 00995 else if (!(ino=get_inode(ino_dir))) 00996 { 00997 // invalid inode number 00998 errore = TRUE; 00999 break; 01000 } 01001 else if (!(isDir(ino)||isFastSymbolicLink(ino))) 01002 { 01003 kprintf("\n\rNot a directory\n\n\r"); 01004 errore = TRUE; 01005 break; 01006 } 01007 else if (!Open_Dir(ino)) 01008 { 01009 if (!isFastSymbolicLink(ino)) 01010 kprintf("\n\rOpen failed\n\n\r"); 01011 errore = TRUE; 01012 break; 01013 } 01014 else 01015 { 01016 // si aggiorna la path salendo nell'albero 01017 if (!strcmp(elem_path,"..")) 01018 { 01019 01020 if (level) 01021 { 01022 level--; 01023 for (i=strlen(path_ext2)-2;path_ext2[i]!='/';i--); 01024 path_ext2[i+1]='\0'; 01025 } 01026 if (!level) 01027 path_ext2[0]='\0'; 01028 } 01029 else 01030 { 01031 strcat(path_ext2,elem_path); 01032 strcat(path_ext2,"/"); 01033 level++; 01034 } 01035 ino_current_dir = ino_dir; 01036 01037 } 01038 } 01039 else elem_path[j_param++] = param[i_param]; 01040 01041 if (errore) 01042 { 01043 // si ripristina la vecchia directory 01044 kprintf("\n\rerrore\n\r"); 01045 level = level_backup; 01046 memcpy(&path_ext2,&path_ext2_backup,1024); 01047 ino_current_dir = ino_dir_backup; 01048 Open_Dir(get_inode(ino_current_dir)); 01049 01050 01051 } 01052 kprintf("\n\r level :%u\n\r",level); 01053 01054 } 01055 } |
|
Definition at line 1215 of file ext2.c.
01215 { 01216 path_ext2[0] = '\0'; //inizializzazione della path 01217 01218 if (!read_ext2()) 01219 { 01220 //kprintf("\n\rDisk I/O error. Unable to read the super block!!!\n\r"); 01221 return(FALSE); 01222 } 01223 // inizializzazione ext2 a buon fine 01224 01225 if (!check_ext2()) 01226 { 01227 return(FALSE); 01228 } 01229 // ext2 é valido 01230 01231 01232 // calcolo parametri della versione corrente file system 01233 01234 dim_block = 1024 << super->s_log_block_size; //dimensione dei blocchi 01235 01236 dim_frag = 1024 << super->s_log_frag_size; // dimensione dei frammenti 01237 01238 spb = dim_block / SIZE_SEC; //settori per blocco 01239 01240 sbpos = super->s_first_data_block + 1; // posizione del superblocco 01241 01242 bpg = super->s_blocks_per_group; //blocchi per gruppo 01243 01244 gdpb = dim_block / sizeof(struct group_descriptor); // desc di gruppo per blocco 01245 01246 ipb = dim_block / super->s_inode_size; // inodes per blocco dim inode 128 bit 01247 01248 number_of_groups = super->s_inodes_count / super->s_inodes_per_group; // numero gruppi 01249 01250 dir_entries_per_block = dim_block / sizeof(struct dir_ff); //directory per blocco 01251 01252 dim_ptr = dim_block >> 2; // dim del blocco in parole da 32 bit 01253 01254 // informazioni di carattere generale sulla ext2 corrente 01255 kprintf("\n\rExt2 parameters\n\r"); 01256 kprintf("\n\rTotal number of inodes: %u",super->s_inodes_count); 01257 kprintf("\n\rTotal number of block: %u",super->s_blocks_count); 01258 kprintf("\n\rNumber of blocks reserved for the super user: %u",super->s_r_blocks_count); 01259 kprintf("\n\rNumber of groups: %u",number_of_groups); 01260 kprintf("\n\rBlock per group: %u",bpg); 01261 kprintf("\n\rBlock dimension: %u",dim_block); 01262 kprintf("\n\rFragment dimension: %u",dim_frag); 01263 kprintf("\n\rSector per block: %u",spb); 01264 kprintf("\n\rDirectories per block: %u",dir_entries_per_block); 01265 kprintf("\n\rGroup descriptors per block: %u",gdpb); 01266 kprintf("\n\rInodes per group: %u",super->s_inodes_per_group); 01267 kprintf("\n\rFrags per group: %u",super->s_frags_per_group); 01268 kprintf("\n\rInodes per block: %u",ipb); 01269 kprintf("\n\r"); 01270 01271 // inizializzazione tabella dei descrittori di gruppo 01272 if (!init_group_desc_table()) 01273 { 01274 return(FALSE); 01275 } 01276 01277 // inizializzazione tabella degli inode 01278 if (!init_inode_table()) 01279 { 01280 return(FALSE); 01281 } 01282 01283 // dobbiamo leggere l'inode relativo alla directory radice "inode 2 sempre" 01284 01285 if (!Open_Dir(get_inode(EXT2_ROOT_INO))) 01286 { 01287 // kprintf("\n\rNot able to open the root directory\n\r"); 01288 return(FALSE); 01289 } 01290 01291 ino_current_dir = EXT2_ROOT_INO; 01292 01293 mount_ext2 = TRUE; //file system montato 01294 01295 level = 0; // livello nell'albero delle directory, root = 0 01296 01297 return(TRUE); 01298 } |
|
Definition at line 825 of file ext2.c.
00825 { 00826 int i; 00827 struct i_node* info_file; 00828 if (mount_ext2){ 00829 00830 clrscr(); 00831 //kprintf("\n\r Total: %u",count_dir); 00832 for (i=0; i<count_dir; i++) 00833 { 00834 00835 info_file = get_inode(inode_dir[i]); 00836 // data e ora di creazione del file 00837 tempo = det_time(info_file->i_ctime); 00838 data = det_date(info_file->i_ctime); 00839 00840 // TODO : fast symbolic link 00841 if ((info_file->i_mode&MODE_MASK)==MODE_LINK) 00842 continue; 00843 switch (info_file->i_mode & MODE_MASK) 00844 { 00845 00846 case MODE_FILE: 00847 set_color(WHITE); 00848 break; 00849 00850 case MODE_DIR: 00851 set_color(LIGHT_BLUE); 00852 break; 00853 00854 case MODE_CDEV: 00855 set_color(LIGHT_GREEN); 00856 break; 00857 00858 case MODE_BDEV: 00859 set_color(LIGHT_RED); 00860 break; 00861 00862 case MODE_FIFO: 00863 set_color(LIGHT_MAGENTA); 00864 break; 00865 00866 case MODE_SOCK: 00867 set_color(LIGHT_CYAN); 00868 break; 00869 00870 case MODE_LINK: 00871 set_color(RED); 00872 break; 00873 00874 } 00875 00876 kprintf("\n\r %s",ext2_file_name[i]); 00877 set_color(DEFAULT_COLOR); 00878 kprintf ("\r (%u)",inode_dir[i]); 00879 set_color(WHITE); 00880 kprintf("\r %u",info_file->i_size); 00881 kprintf("\r %u:%u",tempo.ora,tempo.minuti); 00882 kprintf("\r %u-%u-%u",data.anno,data.mese,data.giorno); 00883 kprintf("\r %u",info_file->i_blocks); 00884 set_color(DEFAULT_COLOR); 00885 if (((i+1)%22)==0) 00886 { 00887 kprintf ("\n\r ------ Continue ------"); 00888 if (kgetchar()==CTRL_C) 00889 { 00890 kprintf("\n\n\r"); 00891 return; 00892 } 00893 clrscr(); 00894 } 00895 } 00896 kprintf("\n\n"); 00897 } 00898 else kprintf("\n\rUnmounted File System Ext2\n\n\r"); 00899 return; 00900 } |
|
Definition at line 817 of file ext2.c.
00817 { 00818 if (mount_ext2) 00819 return(path_ext2); 00820 else return('\0'); 00821 } |