浏览代码

Disk manager updated

master
Jørn Guldberg 5 年前
父节点
当前提交
ea451cd47e
共有 6 个文件被更改,包括 63 次插入37 次删除
  1. 二进制
      SingOS.img
  2. 二进制
      a.out
  3. +48
    -37
      disk_manager_utility.c
  4. +15
    -0
      lsfs_disk_controller.h
  5. 二进制
      lsfs_fuse
  6. 二进制
      lsfs_fuse.o

二进制
SingOS.img 查看文件


二进制
a.out 查看文件


+ 48
- 37
disk_manager_utility.c 查看文件

@ -1,42 +1,35 @@
#include "lsfs_disk_controller.h";
#include <sys/stat.h>;
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <errno.h>
#include <stdlib.h>
#include "lsfs_disk_controller.h"
static int disk_is_loaded = 0;
static char loaded_disk_name[256];
static char input_buffer[256];
#if 0
typedef struct sector_data
{
char data[SECTOR_SIZE];
} sector_data;
int dmu_print_file(lsfs_file_id fileID) {
int dmu_print_file(char *path) {
printf("\n|-----------------Meta Information For File-----------------|\n");
mif* mif_data = calloc(1, SECTOR_SIZE);
read_data_from_disk(fileID, mif_data);
printf("File ID: %lu\n", fileID);
printf("Filename: %s\n", mif_data->filename);
printf("Owner id: %d\n", mif_data->owner_id);
printf("Tags (id):");
for (int i = 0; i < MAX_TAGS_IN_TAG_TABLE; ++i)
{
if(mif_data->tags[i] == 0) {
break;
}
printf("%lu\n", mif_data->tags[i]);
lsfs_file *file = calloc(1, sizeof(lsfs_file));
lsfs_disk_getattr(file, path);
}
printf("Control_bits: %d\n", mif_data->control_bits);
printf("Creation date: %lu\n", mif_data->creation_date);
printf("Last modified: %lu\n", mif_data->last_modification_data);
printf("Last accessed: %lu\n", mif_data->last_access_date);
printf("\nData pointers:\n");
printf("%lu\n", mif_data->one_level_pointer_data[0]);
printf("%lu\n", mif_data->one_level_pointer_data[1]);
printf("%lu\n", mif_data->one_level_pointer_data[2]);
printf("File ID: %lu\n", file->file_id);
printf("Filename: %s\n", file->filename);
printf("File size: %s\n", file->size);
printf("Entry kind: %d", file->entry_kind);
printf("Index in directory table: %d", file->table_entry_pointer);
printf("Sector index on disk: %lu\n", file->table_entry_sector_index);
printf("\nData pointers:\n");
for (int i = 0; i < NUM_DATA_POINTERS; ++i)
{
printf("%lu\n", file->data_pointer[i]);
}
/*
printf("\n|-------------------------File Data-------------------------|\n");
char* file_data = calloc(MAX_NUM_ONE_LEVEL_DATA, SECTOR_SIZE);
int size_of_data = 0;
@ -55,9 +48,17 @@ int dmu_print_file(lsfs_file_id fileID) {
size_of_data -= SECTOR_SIZE;
}
printf("\n|---------------------End File Data-------------------------|\n");
*/
return 1;
}
#if 0
typedef struct sector_data
{
char data[SECTOR_SIZE];
} sector_data;
int dmu_install_SingOS(char* disk_name) {
disk = fopen ( disk_name , "r+b" );
p_control.fsci = malloc(sizeof(FSCI));
@ -145,6 +146,11 @@ int dmu_install_bootloader(char* disk_name) {
return 1;
}
int dmu_install_vbr(char* disk_name) {
lsfs_disk_install_vbr(disk_name);
return 1;
}
int dmu_print_mtt(char *path) {
Directory_Table *directory_table;
if (strcmp(path, "/") != 0)
@ -217,16 +223,28 @@ int main (int argc, char *argv[])
dmu_load_file_system(loaded_disk_name);
}
else if(strcmp(chose, "i") == 0) {
printf("\nLoad disk\nEnter filename:\n");
printf("\nInstall Bootloader\nEnter filename:\n");
scanf("%s", input_buffer);
dmu_install_bootloader(input_buffer);
}
else if(strcmp(chose, "v") == 0) {
printf("\nInstall VBR\nEnter filename:\n");
scanf("%s", input_buffer);
dmu_install_vbr(input_buffer);
}
else if(strcmp(chose, "1") == 0) {
// Print Directory:
printf("Enter Directory:\n");
scanf("%s", input_buffer);
dmu_print_mtt(input_buffer);
}
else if(strcmp(chose, "3") == 0) {
// Print File
printf("Enter path:\n");
scanf("%s", input_buffer);
dmu_print_file( input_buffer );
}
else if(strcmp(chose, "5") == 0) {
printf("Enter Directory:\n");
scanf("%s", input_buffer);
@ -244,13 +262,6 @@ int main (int argc, char *argv[])
dmu_print_tag_table( (lsfs_tag_id) atoi(input_buffer) );
}
else if(strcmp(chose, "3") == 0) {
// Print Master Tag Table
printf("File ID:\n");
scanf("%s", input_buffer);
dmu_print_file( (lsfs_file_id) atoi(input_buffer) );
}
else if(strcmp(chose, "4") == 0) {
// Print Master Tag Table
printf("Enter Tag name:\n");

+ 15
- 0
lsfs_disk_controller.h 查看文件

@ -609,6 +609,21 @@ int lsfs_disk_install_bootloader(char *bootloader_name)
return 0;
}
int lsfs_disk_install_vbr(char *vbr_path)
{
struct stat st;
stat(vbr_path, &st);
FILE *vbr = fopen ( vbr_path , "r+b" );
void *vbr_buffer = calloc(1, (SPACE_VBR_RECORD * SECTOR_SIZE));
fseek(vbr, 0, SEEK_SET);
fread(vbr_buffer, 1, st.st_size, vbr);
write_data_to_disk((p_control.fsci.this_partition_offset_on_disk - SPACE_VBR_RECORD), SPACE_VBR_RECORD, vbr); // Write this to the first sector of the disk.
return 0;
}
int lsfs_disk_load_disk() {
// Find the partition talbe:

二进制
lsfs_fuse 查看文件


二进制
lsfs_fuse.o 查看文件


正在加载...
取消
保存