Ver a proveniência

Disk manager util: added option for install bootloader.

master
Jørn Guldberg há 5 anos
ascendente
cometimento
60ba6a34aa
7 ficheiros alterados com 28 adições e 7 eliminações
  1. BIN
      SingOS.img
  2. BIN
      a.out
  3. +11
    -2
      disk_manager_utility.c
  4. +17
    -5
      lsfs_disk_controller.h
  5. +0
    -0
      lsfs_folder/home/groot/bootloader/bootloader.nasm
  6. BIN
      lsfs_fuse
  7. BIN
      lsfs_fuse.o

BIN
SingOS.img Ver ficheiro


BIN
a.out Ver ficheiro


+ 11
- 2
disk_manager_utility.c Ver ficheiro

@ -140,6 +140,11 @@ int dmu_load_file_system(char* disk_name) {
return 1;
}
int dmu_install_bootloader(char* disk_name) {
lsfs_disk_install_bootloader(disk_name);
return 1;
}
int dmu_print_mtt(char *path) {
Directory_Table *directory_table;
if (strcmp(path, "/") != 0)
@ -196,7 +201,7 @@ int main (int argc, char *argv[])
printf("Tag File System Utility\nMenu:\nc: Create new lsfs disk\nl: load disk\nEnter:");
}
else {
printf("Tag File System Utility\nDisk loaded: %s\nMenu:\n1: Print Master Tag Table\n2: Print Tag Table\n3: Print File\n4: Create Tag\n5: Create New File\n", loaded_disk_name);
printf("Tag File System Utility\nDisk loaded: %s\nMenu:\n1: Print Master Tag Table\n2: Print Tag Table\n3: Print File\n4: Create Tag\n5: Create New File\ni: install Bootloader\n", loaded_disk_name);
}
scanf("%s", chose);
@ -211,6 +216,11 @@ int main (int argc, char *argv[])
scanf("%s", loaded_disk_name);
dmu_load_file_system(loaded_disk_name);
}
else if(strcmp(chose, "i") == 0) {
printf("\nLoad disk\nEnter filename:\n");
scanf("%s", input_buffer);
dmu_install_bootloader(input_buffer);
}
else if(strcmp(chose, "1") == 0) {
// Print Directory:
printf("Enter Directory:\n");
@ -226,7 +236,6 @@ int main (int argc, char *argv[])
}
#if 0
else if(strcmp(chose, "2") == 0) {
// Print Master Tag Table

+ 17
- 5
lsfs_disk_controller.h Ver ficheiro

@ -79,7 +79,7 @@ typedef struct Partition_Entry
typedef struct Master_Boot_record
{
uint8_t offset_on_disk[446]; // The code for the bootloader
uint8_t code[446]; // The code for the bootloader
Partition_Entry partitions[4];
uint16_t mbr_signature; // Signature
} __attribute__((packed)) Master_Boot_record;
@ -470,6 +470,22 @@ int create_file_system(char* disk_name, char* hdd_or_partition, uint64_t filesys
return 0;
}
int lsfs_disk_install_bootloader(char *bootloader_name)
{
FILE *bootloader = fopen ( bootloader_name , "r+b" );
Master_Boot_record *bootloader_mbr = calloc(1, sizeof(Master_Boot_record));
fseek(bootloader, 0 * SECTOR_SIZE, SEEK_SET);
fread(bootloader_mbr, 1, SECTOR_SIZE, bootloader);
Master_Boot_record *mbr = calloc(1, sizeof(Master_Boot_record));
fseek( disk , 0 * SECTOR_SIZE, SEEK_SET );
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.
return 0;
}
int lsfs_disk_load_disk() {
// Find the partition talbe:
// This makes is BIOS dependent.
@ -499,13 +515,9 @@ int lsfs_disk_load_disk() {
// TODO (Jørn) We maybe wnat to optimize, such that we can detect if we have more than one partition opn the system.
if (mbr.partitions[i].partition_type == 0x18)
{
printf("%d\n", mbr.partitions[i].LBA_abs_first_sector);
// First we find the File system control information.
fseek(disk , ((mbr.partitions[i].LBA_abs_first_sector + SPACE_VBR_RECORD) * SECTOR_SIZE), SEEK_SET );
fread(&p_control.fsci, 1, SECTOR_SIZE , disk);
printf("next free sector: %d\n", p_control.fsci.next_free_sector);
printf("next free ID: %d\n", p_control.fsci.next_uniqe_id);
// next we find the Mater Table.
fseek (disk, (p_control.fsci.master_table_index * SECTOR_SIZE), SEEK_SET );

+ 0
- 0
lsfs_folder/home/groot/bootloader/bootloader.nasm Ver ficheiro


BIN
lsfs_fuse Ver ficheiro


BIN
lsfs_fuse.o Ver ficheiro


Carregando…
Cancelar
Guardar