Fix read problem

This commit is contained in:
Jørn Guldberg committed 2019-06-22 16:44:35 +02:00
1 parent 29f11fb06c
commit 5cf271cb28
5 files changed
+10 -11

No files matched your search

BIN
View File
Binary file not shown.
Executable
BIN
View File
Binary file not shown.
+10 -11
View File
@@ -16,7 +16,6 @@
typedef struct Directory_Table Directory_Table; typedef struct Directory_Table Directory_Table;
typedef struct struct_table_entry struct_table_entry; typedef struct struct_table_entry struct_table_entry;
typedef struct struct_partition_control partition_control; typedef struct struct_partition_control partition_control;
typedef struct struct_partition_control partition_control;
typedef struct File_System_Control_Information FSCI; typedef struct File_System_Control_Information FSCI;
typedef struct meta_information_format mif; typedef struct meta_information_format mif;
typedef struct tag_record tag_record; typedef struct tag_record tag_record;
@@ -242,9 +241,9 @@ int lsfs_disk_read_data_from_file(lsfs_file *file, int buffer_size, char *data,
int amount_read = 0; int amount_read = 0;
int amount_to_read = 0; int amount_to_read = 0;
int remaining_offset = offset_to_next_entry; int remaining_offset = offset_to_next_entry;
printf("READ: buffer_size: %d\n", buffer_size); //printf("READ: buffer_size: %d\n", buffer_size);
printf("READ: Data length: %d\n", data_length); //printf("READ: Data length: %d\n", data_length);
printf("READ: Offset length: %d\n", offset_to_next_entry); //printf("READ: Offset length: %d\n", offset_to_next_entry);
int data_pointer_index = 0; // start at first data pointer. int data_pointer_index = 0; // start at first data pointer.
@@ -264,6 +263,10 @@ int lsfs_disk_read_data_from_file(lsfs_file *file, int buffer_size, char *data,
amount_to_read = (DEFAULT_DATA_POINTER_SIZE * SECTOR_SIZE); amount_to_read = (DEFAULT_DATA_POINTER_SIZE * SECTOR_SIZE);
} }
//read_data_from_disk(lsfs_sector_offset index, uint32_t file_block_size, void* data_buffer) //read_data_from_disk(lsfs_sector_offset index, uint32_t file_block_size, void* data_buffer)
if (file->data_pointer[data_pointer_index] == 0)
{
break;
}
read_data_from_disk(file->data_pointer[data_pointer_index], DEFAULT_DATA_POINTER_SIZE, tmp_buffer); read_data_from_disk(file->data_pointer[data_pointer_index], DEFAULT_DATA_POINTER_SIZE, tmp_buffer);
memcpy((data + amount_read), tmp_buffer, amount_to_read); memcpy((data + amount_read), tmp_buffer, amount_to_read);
data_length -= amount_to_read; data_length -= amount_to_read;
@@ -323,22 +326,18 @@ int lsfs_disk_write_data_to_file(lsfs_file *file, int data_length, char *data, s
int new_filesize = data_length + offset_to_next_entry; int new_filesize = data_length + offset_to_next_entry;
int amount_written = 0; int amount_written = 0;
int amount_to_write = 0; int amount_to_write = 0;
printf("Data length: %d\n", data_length); //printf("Data length: %d\n", data_length);
printf("Offset length: %d\n", offset_to_next_entry); //printf("Offset length: %d\n", offset_to_next_entry);
int data_pointer_index = 0; // start at first data pointer. int data_pointer_index = 0; // start at first data pointer.
while(data_length > 0) // We have more to write while(data_length > 0) // We have more to write
{ {
printf("Outside: Data pointers: %d\n", file->data_pointer[data_pointer_index]);
while (file->data_pointer[data_pointer_index] == 0) while (file->data_pointer[data_pointer_index] == 0)
{ {
printf("inside: Data pointers: %d\n", file->data_pointer[data_pointer_index]);
// we have to assign a free sector // we have to assign a free sector
if (get_free_sectors(1, file->data_pointer)) if (get_free_sectors(1, file->data_pointer))
{ {
// This is a fail case, we cannot assign a new sector: // This is a fail case, we cannot assign a new sector:
printf("SHIT");
return amount_written; return amount_written;
} }
} }
@@ -394,7 +393,7 @@ int lsfs_disk_write_data_to_file(lsfs_file *file, int data_length, char *data, s
{ {
// We have to skip a whole data pointer: // We have to skip a whole data pointer:
offset_to_next_entry -= (DEFAULT_DATA_POINTER_SIZE * SECTOR_SIZE); offset_to_next_entry -= (DEFAULT_DATA_POINTER_SIZE * SECTOR_SIZE);
printf("Skip, offset is now: %d\n", offset_to_next_entry); //printf("Skip, offset is now: %d\n", offset_to_next_entry);
data_pointer_index++; data_pointer_index++;
} }
Executable
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.