@ -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 ( " \n Data 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 ( " \n Data 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 ( " \n Load disk \n Enter filename: \n " ) ;
printf ( " \n Install Bootloader \n Enter filename: \n " ) ;
scanf ( " %s " , input_buffer ) ;
dmu_install_bootloader ( input_buffer ) ;
}
else if ( strcmp ( chose , " v " ) = = 0 ) {
printf ( " \n Install VBR \n Enter 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 " ) ;