Giter VIP home page Giter VIP logo

fatreader2021's Introduction

FatReader

The CSC 430 class' basic implementaion of a FAT File Reader System

Design Document

Team Lead: LukeFrisbee

Date: February 22, 2021

Team Members:

  • kevin81622
  • aamindehkordi
  • LukeFrisbee
  • Alex McCune
  • Yunhu Xiang

Stage 2 Slides:https://docs.google.com/presentation/d/1Jy8gLT9gnNBVQeR6xrf6DnacX1RCADLgA8syVbqInJo/edit?usp=sharing

Helper Functions

[x] Luke char*FileAttributes(uint8_t): 

Turns input parameter of "1 byte" into a more human friendly readable string

Example: 

11101011"ReadOnly|Hidden|System|X|Directory|X|Device|Reserved|"
[x] Yunhu char* AsHumanSize(int bytes):

Turns input parameter "int bytes" into a more human friendly readable string. For example:

1440"1.44 KB"

1243652"1.32 MB" 

111921029101"32.19 GB"
[x] Yunhu char* MediaType(uint8_t):

Read input parameter of 1 byte and returns the media type. Examples: HDD, Floppy, Disc, etc.

111011110xEF → "Floppy"
[x] Kevin char* PartitionTypeName(uint8_t):

Reads input parameter of 1 byte and responds with telling us the File System. For example, reading the byte will tell us if the file system is FAT16, FAT32, NTFS, etc.

Example:

000000010x01"FAT12"

000001000x04"FAT16"

000001100x06"FAT16B"
[x] Ali void HexDump(void*, int size):

Reads data at memory address (void*) till the end of given size, then dumps the hex values
[x] Alex void FixShortFile(void*):

Fixes up the name of data in our Fat Table. Note that this is only designed for short files. Short files can only contain a file name with a max size of 8, and an extension name with a max size of 3.


For Example:

0123456789ABC
File    .txt<jA...Lma)!M>Am1...

Would Need To Become:

012345678 9 A B C
File.txt\0\0\0\0\0jA...Lma)!M>Am1...

Reader Functions

[x] Kevin- MBR* ReadMsterBootRecord(FILE* fp, long int offset)

This function will read in the MBR. 

The MBR is the information in the first sector of any hard disk. It identifies where an operating system is located so it can be loaded into the computers main storage.
[x] Alex- FAT_BOOT* ReadFatBootSector(FILE* fp, long int offset)

This function will read in the Fat Boot Sector.

The Fat Boot Sector is responsible for identifying the location of the file, loading it into memory, and transferring control to it. 
[x] Ali- FAT_TABLE* ReadFatTable(FILE* fp, long int offset, int count, int fat_sectors, int sector_size)

This function will read in the FAT Table.

The FAT Table is a table that an operating system maintains on  a hard disk to keep track of the clusters that a file has been stored in
[x] Yunhu- ROOT_DIR* ReadFatRootDirectory(FILE* fp, long int offset, int count)

This function will read in the FAT Root Directory 

The purpose of the root directory is to find the main directory of a certain file. 
[x] Luke- int ReadDiskImage(char* filename)

This function will read in the disk file. 

FAT Reader Structures

The FAT Reader library requires 6 structures.

///PARTITION

typedef struct _PARTITION
{
	uint8_t bootable;
	uint8_t first_chs[3];
	uint8_t type;
	uint8_t last_chs[3];
	uint32_t lba_offset;
	uint32_t sector_count;

}__attribute__((packed)) PARTITION;
///MBR

typedef struct _MBR
{
	uint8_t bootloader[446]; 
	PARTITION list[4]; 
	uint16_t bootsignature; 

}__attribute__((packed)) MBR;
//FAT BOOT SECTOR

typedef struct FAT_BOOT
{
	uint8_t jump_instruction[3]; 
	uint8_t OEM_name_in_text[8]; 
	
	//BIOS parameter block
	uint16_t bytes_per_sector;   
	uint8_t sectors_per_cluster;
	uint16_t reserved_logical_sectors;
	uint8_t number_of_file_allocation_table;
	uint16_t fat_root_directory_entries;
	uint16_t logical_sectors;
	uint8_t media_descriptor;
	uint16_t logical_sectors_per_alloc_table;

	//DOS 3.1 BPB
	uint16_t phyiscal_sectors_per_track;
	uint16_t num_of_heads_for_disks;
	uint8_t count_of_hidden_sectors[4];
	uint8_t total_logical_sectors[4];

	//BIOS paramter block extended
	uint8_t physical_drive_num;
	uint8_t reserved;
	uint8_t extended_boot_signature;
	uint8_t volume_id[4];
	uint8_t partition_volume_label[11];
	uint8_t file_system_type[8];



	uint8_t bootstrap_code[448]; 
	uint16_t boot_sector_signature; 

}__attribute__((packed)) FAT_BOOT;
//FAT TABLE

typedef uint16_t FAT_TABLE_ENTRY;
typedef struct FAT_TABLE
{
	FAT_TABLE_ENTRY Table[0];

}__attribute__((packed)) FAT_TABLE;

```c

// Root Entry

typedef struct ROOT_ENTRY
{
	uint8_t filename[8];
	uint8_t file_exetension[3];
	uint8_t file_attribute;
	uint8_t reserved[10];
	uint16_t timeOfLastChange;
	uint16_t dateOfLastChange;
	uint8_t first_cluster[2];
	uint32_t file_size;

}__attribute__((packed)) ROOT_ENTRY;
//Root Directory

typedef struct ROOT_DIR
{
	ROOT_ENTRY data[0];

} __attribute__((packed)) ROOT_DIR;

fatreader2021's People

Contributors

aamindehkordi avatar kevin81622 avatar lukefrisbee avatar mccune1224 avatar prof-tallman avatar xyhlk520 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.