@ -20,13 +20,20 @@ typedef struct File_System_Control_Information FSCI;
					 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					typedef  struct  meta_information_format  mif ;  
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					typedef  struct  tag_record  tag_record ;  
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					typedef  struct  lsfs_file  lsfs_file ;  
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					typedef  enum  Table_Entry_Kind  Table_Entry_Kind ;  
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					typedef  uint64_t  lsfs_sector_offset ;  
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					typedef  lsfs_sector_offset  lsfs_file_id ;  
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					typedef  enum  
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					{  
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					    // These are specific values since, is has to corrospond to the implementation in assembly
   
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					    ENTRY_EMPTY  =  0 ,   
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					    ENTRY_FILE  =  1 ,   
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					    ENTRY_DIRECTORY  =  2 ,   
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					}  Table_Entry_Kind ;  
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					//typedef uint64_t sector_index;
  
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					static  FILE *  disk ;  
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					static  FILE *  disk  =  NULL  ;  
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					static  partition_control  p_control ;  
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					static  time_t  timestamp_loading ;  
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					
 
				
			 
			
		
	
	
		
			
				
					
						
						
						
							
								 
							 
						
					 
				
				 
				 
				
					@ -36,11 +43,11 @@ Directory_Table* lsfs_find_directory(const char* path, bool drop_filename);
					 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					int  lsfs_disk_getattr ( lsfs_file *  find_file ,  const  char  * path ) ;  
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					int  lsfs_disk_delete_entry ( lsfs_file  * file ) ;  
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					int  get_free_sectors_table ( ) ;  
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					int  get_free_sectors ( int  num_sectors_needed ,  lsfs_sector_offset *  output_arra y) ;  
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					int  lsfs_disk_read_data_from_file ( lsfs_file  * file ,  int  data_length ,  char  * data ,  size _t  offset_to_next_entry ) ;  
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					int  lsfs_disk_write_data_to_file ( lsfs_file *  file ,  int  data_length ,  char  * data ,  size _t  offset_to_next_entry ) ;  
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					int  get_free_sectors ( int  num_sectors_needed ,  struct_table_entry *  table_entr y) ;  
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					int  lsfs_disk_read_data_from_file ( lsfs_file  * file ,  int  data_length ,  char  * data ,  int64 _t  offset_to_next_entry ) ;  
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					int  lsfs_disk_write_data_to_file ( lsfs_file *  file ,  int  data_length ,  char  * data ,  int64 _t  offset_to_next_entry ) ;  
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					int  lsfs_disk_rename_file ( const  char *  old_filename_ ,  const  char *  new_filename ) ;  
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					int  lsfs_disk_load_disk ( ) ;  
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					int  lsfs_disk_load_disk ( char *  diskname ) ;  
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					int  write_data_to_disk ( lsfs_sector_offset  at_sector ,  uint32_t  number_sectors ,  void *  data_to_write ) ;  
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					int  write_data_to_disk_off ( lsfs_sector_offset  index ,  uint32_t  number_sectors ,  void *  data_to_write ,  int  offset ) ;  
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					int  read_data_from_disk ( lsfs_sector_offset  index ,  uint32_t  number_sectors ,  void *  data_buffer ) ;  
				
			 
			
		
	
	
		
			
				
					
						
						
						
							
								 
							 
						
					 
				
				 
				 
				
					@ -57,14 +64,6 @@ int save_modified_file_information(lsfs_file* file);
					 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					# define DEFAULT_TABLE_SIZE 8  // 16 
  
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					# define NUM_DATA_POINTERS 27   
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					typedef  enum  Table_Entry_Kind  
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					{  
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					    // These are specific values since, is has to corrospond to the implementation in assembly
   
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					    ENTRY_EMPTY  =  0 ,   
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					    ENTRY_FILE  =  1 ,   
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					    ENTRY_DIRECTORY  =  2 ,   
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					}  Table_Entry_Kind ;  
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					typedef  struct  Partition_Entry  
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					{  
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					    uint8_t   active_falg ;  // This has value 0x80 if it is a bootable partition / it is an active partition. 
   
				
			 
			
		
	
	
		
			
				
					
						
							
								 
							 
						
						
							
								 
							 
						
						
					 
				
				 
				 
				
					@ -171,6 +170,7 @@ typedef struct tag_record {
					 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					typedef  struct  lsfs_file  {  
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					    lsfs_file_id  file_id ;   
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					    lsfs_sector_offset  table_entry_pointer ;   
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					    struct_table_entry *  table_backpointer ;   
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					    Table_Entry_Kind  entry_kind ;   
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					    char *  filename ;   
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					    uint32_t  owner_id ;   
				
			 
			
		
	
	
		
			
				
					
						
						
						
							
								 
							 
						
					 
				
				 
				 
				
					@ -188,7 +188,7 @@ Directory_Table* lsfs_find_directory(const char *path, bool drop_filename)
					 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					{  
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					    Directory_Table  * dir_table  =  calloc ( 1 ,  sizeof ( Directory_Table ) ) ;   
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					    printf ( " Table index: %lu  \n " , p_control . fsci . master_table_index  ) ;   
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					    // printf("Table index: %lu \n",p_control.fsci.master_table_index );
   
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					    read_data_from_disk ( p_control . fsci . master_table_index ,  DEFAULT_TABLE_SIZE ,  dir_table ) ;   
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					    lsfs_string_array  split_path  =  lsfs_string_split_c ( path ,  ' / ' ,  false ) ;   
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					
 
				
			 
			
		
	
	
		
			
				
					
						
						
						
							
								 
							 
						
					 
				
				 
				 
				
					@ -207,7 +207,7 @@ Directory_Table* lsfs_find_directory(const char *path, bool drop_filename)
					 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					            if  ( strcmp ( dir_table - > entries [ j ] . filename ,  split_path . strings [ i ] . chars )  = =  0 )   
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					            {   
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					                int  index_sector  =  dir_table - > entries [ j ] . data_pointer [ 0 ] ;   
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					                printf ( " Table index: %lu  \n " , index_sector  ) ;   
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					                // printf("Table index: %lu \n",index_sector );
   
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					                read_data_from_disk ( index_sector ,  DEFAULT_TABLE_SIZE ,  dir_table ) ;   
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					                break ;   
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					            }   
				
			 
			
		
	
	
		
			
				
					
						
						
						
							
								 
							 
						
					 
				
				 
				 
				
					@ -225,7 +225,9 @@ int lsfs_disk_getattr(lsfs_file* find_file, const char* path) {
					 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					    for  ( int  i  =  0 ;  i  <  DEFAULT_TABLE_SIZE ;  + + i )   
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					    {   
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					        if ( strcmp (  filename . chars ,  dir_table - > entries [ i ] . filename  )  = =  0 )  {   
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					        if ( strcmp (  filename . chars ,  dir_table - > entries [ i ] . filename  )  = =  0 )  
  
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					        {   
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					            find_file - > table_backpointer  =  & ( dir_table - > entries [ i ] ) ;   
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					            find_file - > file_id  =  dir_table - > entries [ i ] . file_id ;   
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					            find_file - > entry_kind  =  dir_table - > entries [ i ] . entry_kind ;   
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					            find_file - > table_entry_pointer  =  i ;   
				
			 
			
		
	
	
		
			
				
					
						
						
						
							
								 
							 
						
					 
				
				 
				 
				
					@ -246,7 +248,7 @@ int lsfs_disk_getattr(lsfs_file* find_file, const char* path) {
					 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					int  lsfs_disk_read_data_from_file ( lsfs_file  * file ,  int  buffer_size ,  char  * data ,  size _t  offset_to_next_entry )  
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					int  lsfs_disk_read_data_from_file ( lsfs_file  * file ,  int  buffer_size ,  char  * data ,  int64 _t  offset_to_next_entry )  
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					{  
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					    int  data_length  =  file - > size  -  offset_to_next_entry ;   
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					    int  amount_read  =  0 ;   
				
			 
			
		
	
	
		
			
				
					
						
							
								 
							 
						
						
							
								 
							 
						
						
					 
				
				 
				 
				
					@ -339,7 +341,7 @@ static inline time_t lsfs_disk_update_timestamps(lsfs_file *file) {
					 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					# define lsfs_num_sectors_for_size(x) (((x)+SECTOR_SIZE-1)&~(SECTOR_SIZE-1))  
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					int  lsfs_disk_write_data_to_file ( lsfs_file  * file ,  int  data_length ,  char  * data ,  size _t  offset_to_next_entry )  
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					int  lsfs_disk_write_data_to_file ( lsfs_file  * file ,  int  data_length ,  char  * data ,  int64 _t  offset_to_next_entry )  
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					{  
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					    int  new_filesize  =  data_length  +  offset_to_next_entry ;   
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					    int  amount_written  =  0 ;   
				
			 
			
		
	
	
		
			
				
					
						
						
						
							
								 
							 
						
					 
				
				 
				 
				
					@ -353,7 +355,7 @@ int lsfs_disk_write_data_to_file(lsfs_file *file, int data_length, char *data, s
					 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					        while  ( file - > data_pointer [ data_pointer_index ]  = =  0 )  
  
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					        {   
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					            // we have to assign a free sector 
   
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					            if  ( get_free_sectors ( 1 ,  file - > da ta_pointer) )   
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					            if  ( get_free_sectors ( 1 ,  file - > table _back pointer ) )   
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					            {   
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					                // This is a fail case, we cannot assign a new sector: 
   
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					                return  amount_written ;   
				
			 
			
		
	
	
		
			
				
					
						
							
								 
							 
						
						
							
								 
							 
						
						
					 
				
				 
				 
				
					@ -535,7 +537,7 @@ int get_free_sectors_table() {
					 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					    return  return_index ;   
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					}  
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					int  get_free_sectors ( int  num_sectors_needed ,  lsfs_sector_offset *  output_arra y)  {  
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					int  get_free_sectors ( int  num_sectors_needed ,  struct_table_entry *  table_entr y)  {  
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					    if  ( ( p_control . fsci . next_free_sector  +  num_sectors_needed )  >  p_control . fsci . last_sector_index_on_partition  )  
  
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					    {   
				
			 
			
		
	
	
		
			
				
					
						
						
						
							
								 
							 
						
					 
				
				 
				 
				
					@ -551,10 +553,10 @@ int get_free_sectors(int num_sectors_needed, lsfs_sector_offset* output_array) {
					 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					            return  - EINVAL ;  // We don't have any more data pointers. 
   
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					        }   
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					        if  ( output_array [ i ]  = =  0 )  
  
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					        if  ( table_entry - > data_pointer [ i ]  = =  0 )  
  
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					        {   
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					            // If free we can assign: 
   
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					            output_array [ i ]  =  p_control . fsci . next_free_sector ;   
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					            table_entry - > data_pointer [ i ]  =  p_control . fsci . next_free_sector ;   
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					            p_control . fsci . next_free_sector  + =  DEFAULT_DATA_POINTER_SIZE ;   
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					            num_sectors_needed - - ;   
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					        }   
				
			 
			
		
	
	
		
			
				
					
						
							
								 
							 
						
						
							
								 
							 
						
						
					 
				
				 
				 
				
					@ -597,7 +599,7 @@ int create_file_system(char* disk_name, char hdd_or_partition, uint64_t filesyst
					 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					    {   
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					        // This is just a single partition
   
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					        // And then the file system is the only thing in the system. 
   
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					        sprintf ( fsci - > filesystem_information ,  " LSFS v1.0.0-a1  \r \n (LessSimpelFileSystem)(Generated by the disk_manager_utility.c) \r \n Developed to SingOS \r \n by Jorn Guldberg \r \n " ) ;   
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					        sprintf ( fsci - > filesystem_information ,  " LSFS v1.0.0-a4  \r \n (LessSimpelFileSystem)(Generated by the disk_manager_utility.c) \r \n Developed to SingOS and Quasi OS \r \n by Jorn Guldberg \r \n " ) ;   
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					        
  
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					        if  ( hdd_or_partition  = =  ' 1 ' )   
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					        {   
				
			 
			
		
	
	
		
			
				
					
						
							
								 
							 
						
						
							
								 
							 
						
						
					 
				
				 
				 
				
					@ -624,6 +626,7 @@ int create_file_system(char* disk_name, char hdd_or_partition, uint64_t filesyst
					 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					    write_data_to_disk ( fsci - > this_partition_offset_on_disk ,  1 ,  fsci ) ;   
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					    lsfs_disk_load_disk ( NULL ) ;  // Reload disk
   
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					    return  0 ;   
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					}  
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					
 
				
			 
			
		
	
	
		
			
				
					
						
						
						
							
								 
							 
						
					 
				
				 
				 
				
					@ -639,6 +642,9 @@ int lsfs_disk_install_bootloader(char *bootloader_name)
					 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					    fread ( mbr ,  1 ,  SECTOR_SIZE ,  disk ) ;   
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					    memcpy ( mbr - > code ,  bootloader_mbr - > code ,  446 ) ;         
  
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					    write_data_to_disk ( 0 ,  1 ,  mbr ) ;  // Write this to the first sector of the disk. 
   
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					    lsfs_disk_load_disk ( NULL ) ;  // Reload disk
   
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					    return  0 ;   
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					}  
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					
 
				
			 
			
		
	
	
		
			
				
					
						
						
						
							
								 
							 
						
					 
				
				 
				 
				
					@ -662,9 +668,9 @@ int lsfs_disk_install_vbr(char *vbr_path)
					 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					    vbr_first_sector - > vbr_LBA_FSCI_position  =  p_control . fsci . this_partition_offset_on_disk ;   
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					    vbr_first_sector - > vbr_signature  =  0x1818 ;   
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					    printf ( " VBR size: %d  \n " ,  vbr_first_sector - > vbr_size_in_bytes ) ;   
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					    printf ( " VBR lba address: %d  \n " ,  vbr_first_sector - > vbr_LBA_address ) ;   
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					    printf ( " VBR FSCI: %d  \n " ,  vbr_first_sector - > vbr_LBA_FSCI_position ) ;   
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					    printf ( " VBR size: %lu  \n " ,  vbr_first_sector - > vbr_size_in_bytes ) ;   
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					    printf ( " VBR lba address: %lu  \n " ,  vbr_first_sector - > vbr_LBA_address ) ;   
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					    printf ( " VBR FSCI: %lu  \n " ,  vbr_first_sector - > vbr_LBA_FSCI_position ) ;   
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					    
  
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					    write_data_to_disk ( ( p_control . fsci . this_partition_offset_on_disk  -  SPACE_VBR_RECORD ) ,  1 ,  vbr_first_sector ) ;  // Write this to the first sector of the disk. 
   
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					    write_data_to_disk ( ( p_control . fsci . this_partition_offset_on_disk  -  SPACE_VBR_RECORD  +  1 ) ,  ( SPACE_VBR_RECORD  -  1 ) ,  vbr_buffer_rest ) ;  // Write this to the first sector of the disk. 
   
				
			 
			
		
	
	
		
			
				
					
						
						
						
							
								 
							 
						
					 
				
				 
				 
				
					@ -688,10 +694,21 @@ int lsfs_disk_install_vbr(char *vbr_path)
					 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					}  
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					int  lsfs_disk_load_disk ( )  {  
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					int  lsfs_disk_load_disk ( char *  diskname )  
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					{  
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					    // Find the partition talbe: 
   
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					    // This makes is BIOS dependent. 
   
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					    // UEFI is not supported. 
   
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					    if  ( diskname  ! =  NULL )  
  
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					    {   
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					        disk  =  fopen  (  diskname  ,  " r+b "  ) ;   
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					    }   
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					    else  if  ( disk  = =  NULL  )   
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					    {   
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					        return  - 1 ;   
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					    }   
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					    time ( & timestamp_loading ) ;   
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					    Master_Boot_record  mbr ;   
				
			 
			
		
	
	
		
			
				
					
						
							
								 
							 
						
						
							
								 
							 
						
						
					 
				
				 
				 
				
					@ -811,7 +828,7 @@ int lsfs_disk_create_entry(const char* path, Table_Entry_Kind entry_kind)
					 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					    {   
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					        // We assign one data pointer consiting of DEFAULT_DATA_POINTER_SIZE sectors
   
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					        dir_table - > entries [ free_index ] . file_size  =  0 ;   
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					        get_free_sectors ( 1 ,  dir_table - > entries [ free_index ] . data_pointer ) ;   
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					        get_free_sectors ( 1 ,  & ( dir_table - > entries [ free_index ] ) ) ;   
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					    }   
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					    else   
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					    {