| 
						
						
							
								
							
						
						
					 | 
					 | 
					@ -37,11 +37,12 @@ int get_free_sectors(int num_sectors_needed, lsfs_sector_offset* output_array); | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					int lsfs_disk_read_data_from_file(lsfs_file* file, int buffer_size, void* buffer_for_data); | 
					 | 
					 | 
					 | 
					int lsfs_disk_read_data_from_file(lsfs_file* file, int buffer_size, void* buffer_for_data); | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					int lsfs_disk_write_data_to_file(lsfs_file* file, int data_length, char *data); | 
					 | 
					 | 
					 | 
					int lsfs_disk_write_data_to_file(lsfs_file* file, int data_length, char *data); | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					//int lsfs_disk_rename_tag(lsfs_file_id file_id, char* new_filename);
 | 
					 | 
					 | 
					 | 
					//int lsfs_disk_rename_tag(lsfs_file_id file_id, char* new_filename);
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					int lsfs_disk_rename_file(lsfs_file_id file_id, const char* new_filename); | 
					 | 
					 | 
					 | 
					int lsfs_disk_rename_file(lsfs_file* file, const char* new_filename); | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					int lsfs_disk_load_disk(); | 
					 | 
					 | 
					 | 
					int lsfs_disk_load_disk(); | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					int write_data_to_disk(lsfs_sector_offset at_sector, uint32_t file_block_size, void* data_to_write); | 
					 | 
					 | 
					 | 
					int write_data_to_disk(lsfs_sector_offset at_sector, uint32_t file_block_size, void* data_to_write); | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					int read_data_from_disk(lsfs_sector_offset index, void* data_buffer); | 
					 | 
					 | 
					 | 
					int read_data_from_disk(lsfs_sector_offset index, uint32_t file_block_size, void* data_buffer); | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					int write_data_to_disk_off(lsfs_sector_offset index, void* data_to_write, int offset); | 
					 | 
					 | 
					 | 
					int write_data_to_disk_off(lsfs_sector_offset index, void* data_to_write, int offset); | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					int save_modified_file_information(lsfs_file* file); | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					#define SECTOR_SIZE 512 | 
					 | 
					 | 
					 | 
					#define SECTOR_SIZE 512 | 
				
			
			
		
	
	
		
		
			
				
					| 
						
							
								
							
						
						
							
								
							
						
						
					 | 
					 | 
					@ -118,12 +119,14 @@ typedef struct tag_record { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					typedef struct lsfs_file { | 
					 | 
					 | 
					 | 
					typedef struct lsfs_file { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    lsfs_file_id file_id; | 
					 | 
					 | 
					 | 
					    lsfs_file_id file_id; | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					    lsfs_sector_offset table_entry_pointer; | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    char* filename; | 
					 | 
					 | 
					 | 
					    char* filename; | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    uint32_t owner_id; | 
					 | 
					 | 
					 | 
					    uint32_t owner_id; | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    uint64_t size; | 
					 | 
					 | 
					 | 
					    uint64_t size; | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    uint64_t creation_date; 
 | 
					 | 
					 | 
					 | 
					    uint64_t creation_date; 
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    uint64_t access_time; | 
					 | 
					 | 
					 | 
					    uint64_t access_time; | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    uint64_t modification_time; | 
					 | 
					 | 
					 | 
					    uint64_t modification_time; | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					    uint32_t file_block_size; | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    lsfs_sector_offset *data; | 
					 | 
					 | 
					 | 
					    lsfs_sector_offset *data; | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					} lsfs_file; | 
					 | 
					 | 
					 | 
					} lsfs_file; | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
	
		
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
					 | 
					@ -136,8 +139,8 @@ int lsfs_disk_getattr(lsfs_file* find_file, const char* path) { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            time_t current_time; | 
					 | 
					 | 
					 | 
					            time_t current_time; | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            time ( ¤t_time ); | 
					 | 
					 | 
					 | 
					            time ( ¤t_time ); | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            //find_file = calloc(1, sizeof(lsfs_file));
 | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            find_file->file_id = p_control.master_table[i].file_id; | 
					 | 
					 | 
					 | 
					            find_file->file_id = p_control.master_table[i].file_id; | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					            find_file->table_entry_pointer = i; | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            find_file->filename = p_control.master_table[i].filename; | 
					 | 
					 | 
					 | 
					            find_file->filename = p_control.master_table[i].filename; | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            find_file->owner_id = getuid(); | 
					 | 
					 | 
					 | 
					            find_file->owner_id = getuid(); | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            find_file->size = p_control.master_table[i].file_size; // p_control.master_table[i].data_pointer[0]; //;
 | 
					 | 
					 | 
					 | 
					            find_file->size = p_control.master_table[i].file_size; // p_control.master_table[i].data_pointer[0]; //;
 | 
				
			
			
		
	
	
		
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
					 | 
					@ -145,6 +148,7 @@ int lsfs_disk_getattr(lsfs_file* find_file, const char* path) { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            find_file->access_time = (uint64_t) current_time; | 
					 | 
					 | 
					 | 
					            find_file->access_time = (uint64_t) current_time; | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            find_file->modification_time = (uint64_t) current_time; | 
					 | 
					 | 
					 | 
					            find_file->modification_time = (uint64_t) current_time; | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            find_file->data = p_control.master_table[i].data_pointer; | 
					 | 
					 | 
					 | 
					            find_file->data = p_control.master_table[i].data_pointer; | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					            find_file->file_block_size = 1; // TODO: should be loaded from disk.
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            found = 1; | 
					 | 
					 | 
					 | 
					            found = 1; | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        } | 
					 | 
					 | 
					 | 
					        } | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        i++; | 
					 | 
					 | 
					 | 
					        i++; | 
				
			
			
		
	
	
		
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
					 | 
					@ -163,7 +167,7 @@ int lsfs_disk_read_data_from_file(lsfs_file *file, int buffer_size, void* buffer | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        if(file->data[i] == 0) { | 
					 | 
					 | 
					 | 
					        if(file->data[i] == 0) { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            break; | 
					 | 
					 | 
					 | 
					            break; | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        } | 
					 | 
					 | 
					 | 
					        } | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        return_val += read_data_from_disk(file->data[i], buffer_for_data + (SECTOR_SIZE * i)); | 
					 | 
					 | 
					 | 
					        return_val += read_data_from_disk(file->data[i], file->file_block_size, buffer_for_data + (SECTOR_SIZE * i)); | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    } | 
					 | 
					 | 
					 | 
					    } | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    //time_t current_time;
 | 
					 | 
					 | 
					 | 
					    //time_t current_time;
 | 
				
			
			
		
	
	
		
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
					 | 
					@ -182,15 +186,16 @@ 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)) | 
					 | 
					 | 
					 | 
					#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) { | 
					 | 
					 | 
					 | 
					int lsfs_disk_write_data_to_file(lsfs_file *file, int data_length, char *data) { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					    int written; | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    int amount_written = data_length; | 
					 | 
					 | 
					 | 
					    int amount_written = data_length; | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    lsfs_sector_offset current_sector = file->size / SECTOR_SIZE; | 
					 | 
					 | 
					 | 
					    lsfs_sector_offset current_sector = file->size / SECTOR_SIZE; | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    unsigned int offset_in_sector = file->size % SECTOR_SIZE; | 
					 | 
					 | 
					 | 
					    unsigned int offset_in_sector = file->size % SECTOR_SIZE; | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    char *tmp_buffer = malloc(SECTOR_SIZE); | 
					 | 
					 | 
					 | 
					    char *tmp_buffer = calloc(file->file_block_size, SECTOR_SIZE); | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    assert(tmp_buffer); | 
					 | 
					 | 
					 | 
					    assert(tmp_buffer); | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    read_data_from_disk(file->data[current_sector], tmp_buffer); | 
					 | 
					 | 
					 | 
					    read_data_from_disk(file->data[current_sector], file->file_block_size, tmp_buffer); 
 | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    memcpy(tmp_buffer + offset_in_sector, data, SECTOR_SIZE-offset_in_sector); | 
					 | 
					 | 
					 | 
					    memcpy(tmp_buffer + offset_in_sector, data, SECTOR_SIZE-offset_in_sector); | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    data_length -= SECTOR_SIZE-offset_in_sector; | 
					 | 
					 | 
					 | 
					    data_length -= SECTOR_SIZE-offset_in_sector; | 
				
			
			
		
	
	
		
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
					 | 
					@ -201,7 +206,7 @@ int lsfs_disk_write_data_to_file(lsfs_file *file, int data_length, char *data) { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    for (;;) { | 
					 | 
					 | 
					 | 
					    for (;;) { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        assert(current_sector <= NUM_DATA_POINTERS); | 
					 | 
					 | 
					 | 
					        assert(current_sector <= NUM_DATA_POINTERS); | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        write_data_to_disk(p_control.master_table[file->file_id].data_pointer[current_sector], 4, tmp_buffer); | 
					 | 
					 | 
					 | 
					        written = written + write_data_to_disk(p_control.master_table[file->file_id].data_pointer[current_sector], 4, tmp_buffer); | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        if (data_length <= 0) break; | 
					 | 
					 | 
					 | 
					        if (data_length <= 0) break; | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        data += SECTOR_SIZE; | 
					 | 
					 | 
					 | 
					        data += SECTOR_SIZE; | 
				
			
			
		
	
	
		
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
					 | 
					@ -221,9 +226,9 @@ int lsfs_disk_write_data_to_file(lsfs_file *file, int data_length, char *data) { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    free(tmp_buffer); | 
					 | 
					 | 
					 | 
					    free(tmp_buffer); | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    
 | 
					 | 
					 | 
					 | 
					    
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    //lsfs_disk_update_timestamps(&mif_record);
 | 
					 | 
					 | 
					 | 
					    //lsfs_disk_update_timestamps(&mif_record);
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    p_control.master_table[file->file_id].file_size += amount_written; // update file size
 | 
					 | 
					 | 
					 | 
					    file->size += amount_written; // update file size
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					    save_modified_file_information(file); | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    write_data_to_disk(file->file_id, 4, &p_control.master_table[file->file_id]); | 
					 | 
					 | 
					 | 
					    //write_data_to_disk(file->file_id, 4, &p_control.master_table[file->file_id]);
 | 
				
			
			
				
				
			
		
	
		
		
	
		
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    return amount_written; | 
					 | 
					 | 
					 | 
					    return amount_written; | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					} | 
					 | 
					 | 
					 | 
					} | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
	
		
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
					 | 
					@ -235,7 +240,8 @@ time_t lsfs_disk_truncate_file(lsfs_file *file, off_t offset) { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    file->size = (int) offset; // p_control.master_table[i].data_pointer[0]; //;
 | 
					 | 
					 | 
					 | 
					    file->size = (int) offset; // p_control.master_table[i].data_pointer[0]; //;
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    write_data_to_disk(file->file_id, 4, NULL); | 
					 | 
					 | 
					 | 
					    save_modified_file_information(file); | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					    //write_data_to_disk(file->file_id, 4, NULL);
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    return result; | 
					 | 
					 | 
					 | 
					    return result; | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					} | 
					 | 
					 | 
					 | 
					} | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
	
		
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
					 | 
					@ -256,27 +262,25 @@ time_t lsfs_disk_truncate_file(lsfs_file *file, off_t offset) { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					//     return 1;
 | 
					 | 
					 | 
					 | 
					//     return 1;
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					// }
 | 
					 | 
					 | 
					 | 
					// }
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					int lsfs_disk_rename_file(lsfs_file_id file_id, const char* new_filename) { | 
					 | 
					 | 
					 | 
					int lsfs_disk_rename_file(lsfs_file* file, const char* new_filename) { | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    mif* mif_record = calloc(1, SECTOR_SIZE); | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    read_data_from_disk(file_id, mif_record); | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    memset(mif_record->filename, 0, sizeof(mif_record->filename)); | 
					 | 
					 | 
					 | 
					    memset(file->filename, 0, 256); | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    sprintf(mif_record->filename, "%s", new_filename); 
 | 
					 | 
					 | 
					 | 
					    sprintf(file->filename, "%s", new_filename); 
 | 
				
			
			
				
				
			
		
	
		
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    time_t current_time; | 
					 | 
					 | 
					 | 
					    time_t current_time; | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    time ( ¤t_time ); | 
					 | 
					 | 
					 | 
					    time ( ¤t_time ); | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    mif_record->last_modification_data = (uint64_t) current_time; | 
					 | 
					 | 
					 | 
					    file->access_time = (uint64_t) current_time; | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    mif_record->last_access_date = (uint64_t) current_time; | 
					 | 
					 | 
					 | 
					    file->modification_time = (uint64_t) current_time; | 
				
			
			
				
				
			
		
	
		
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					    save_modified_file_information(file); | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    write_data_to_disk(file_id, 4, mif_record); | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    free(mif_record); | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    return 1; | 
					 | 
					 | 
					 | 
					    return 1; | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					} | 
					 | 
					 | 
					 | 
					} | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					int lsfs_disk_delete_file(lsfs_file_id file_id) { | 
					 | 
					 | 
					 | 
					int lsfs_disk_delete_file(lsfs_file_id file_id) { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    mif* mif_record = calloc(1, SECTOR_SIZE); | 
					 | 
					 | 
					 | 
					    mif* mif_record = calloc(1, SECTOR_SIZE); | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    read_data_from_disk(file_id, mif_record); | 
					 | 
					 | 
					 | 
					    read_data_from_disk(file_id, 1, mif_record); | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    for (int i = 0; i < MAX_TAGS_FOR_A_FILE; ++i) | 
					 | 
					 | 
					 | 
					    for (int i = 0; i < MAX_TAGS_FOR_A_FILE; ++i) | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    { | 
					 | 
					 | 
					 | 
					    { | 
				
			
			
		
	
	
		
		
			
				
					| 
						
							
								
							
						
						
							
								
							
						
						
					 | 
					 | 
					@ -582,6 +586,19 @@ lsfs_file_id lsfs_disk_create_file(char* filename, lsfs_file_id* tags, void* fil | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    return return_id; | 
					 | 
					 | 
					 | 
					    return return_id; | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					} | 
					 | 
					 | 
					 | 
					} | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					int save_modified_file_information(lsfs_file* file) { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					    // Write the file struct into the table_entry, such that we can save the data correct. 
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					    
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					    p_control.master_table[file->table_entry_pointer].file_id = file->file_id; | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					    memcpy(p_control.master_table[file->table_entry_pointer].filename, file->filename, 256); | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					    p_control.master_table[file->table_entry_pointer].file_size = file->size; // p_control.master_table[i].data_pointer[0]; //;
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					    //p_control.master_table[i].data_pointer = find_file->data;
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					    write_data_to_disk(file->table_entry_pointer, file->file_block_size, &p_control.master_table[file->table_entry_pointer]); | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					    return 0; | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					} | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					int write_data_to_disk(lsfs_sector_offset index, uint32_t file_block_size, void* data_to_write) { | 
					 | 
					 | 
					 | 
					int write_data_to_disk(lsfs_sector_offset index, uint32_t file_block_size, void* data_to_write) { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    fseek ( disk, (index * SECTOR_SIZE), SEEK_SET ); // SEEK_SET start offset at index 0 and move 1 * SECTOR_SIZE, and write here.
 | 
					 | 
					 | 
					 | 
					    fseek ( disk, (index * SECTOR_SIZE), SEEK_SET ); // SEEK_SET start offset at index 0 and move 1 * SECTOR_SIZE, and write here.
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    int written = fwrite(data_to_write, 1, (4 * SECTOR_SIZE), disk); | 
					 | 
					 | 
					 | 
					    int written = fwrite(data_to_write, 1, (4 * SECTOR_SIZE), disk); | 
				
			
			
		
	
	
		
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
					 | 
					@ -594,9 +611,9 @@ int write_data_to_disk_off(lsfs_sector_offset index, void* data_to_write, int of | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    return written; | 
					 | 
					 | 
					 | 
					    return written; | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					} | 
					 | 
					 | 
					 | 
					} | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					int read_data_from_disk(lsfs_sector_offset index, void* data_buffer) { | 
					 | 
					 | 
					 | 
					int read_data_from_disk(lsfs_sector_offset index, uint32_t file_block_size, void* data_buffer) { | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    fseek ( disk, (index * SECTOR_SIZE ), SEEK_SET ); // SEEK_SET start offset at index 0 and move 1 * SECTOR_SIZE, and write here.
 | 
					 | 
					 | 
					 | 
					    fseek ( disk, (index * SECTOR_SIZE ), SEEK_SET ); // SEEK_SET start offset at index 0 and move 1 * SECTOR_SIZE, and write here.
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    int read = fread(data_buffer, 1, (4 * SECTOR_SIZE), disk); | 
					 | 
					 | 
					 | 
					    int read = fread(data_buffer, 1, (file_block_size * SECTOR_SIZE), disk); | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    return read; | 
					 | 
					 | 
					 | 
					    return read; | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					} | 
					 | 
					 | 
					 | 
					} | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
	
		
		
			
				
					| 
						
							
								
							
						
						
						
					 | 
					 | 
					
  |