Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Task The goal of this assignment is to implement a simple storage manager - a module that is capable of reading blocks from a file
Task
The goal of this assignment is to implement a simple storage manager a module that is capable of reading blocks
from a file on disk into memory and writing blocks from memory to a file on disk. The storage manager deals with
pages blocks of fixed size PAGESIZE In addition to reading and writing pages from a file, it provides methods for
creating, opening, and closing files. The storage manager has to maintain several types of information for an open
file: The number of total pages in the file, the current page position for reading and writing the file name, and a
POSIX file descriptor or FILE pointer. In your implementation you should implement the interface described below.
Please commit a text file README. txt that shortly describes the ideas behind your solution and the code structure.
Comment your code!
INTERFACE
The interface your storage manager should implement is given as a header file storagemgrh The content of this
header is shown below. Two additional headers
and testhelpers.h define error codes and constants
and macros used in the test cases.
#ifndef STORAGEMGRH
#define STORAGEMGRH
#include "dberror.h
handle data structures
typedef struct SMFileHandle
char fileName;
int totalNumPages;
int curPagePos;
void mgmtInfo;
SMFileHandle;
typedef char SMPageHandle;
interface
manipulating page files
extern void initStorageManager void;
extern RC createPageFile char fileName;
extern RC openPageFile char fileName SMFileHandle fHandle;
extern RC closePageFile SMFileHandle fHandle;
extern RC destroyPageFile char fileName;
reading blocks from disc
extern RC readBlock int pageNum, SMFileHandle fHandle SMPageHandle memPage;
extern int getBlockPos SMFileHandle fHandle;
extern RC readFirstBlock SMFileHandle fHandle SMPageHandle memPage;
extern RC readPreviousBlock SMFileHandle fHandle SMPageHandle memPage;
extern RC readCurrentBlock SMFileHandle fHandle SMPageHandle memPage;
extern RC readNextBlock SMFileHandle fHandle SMPageHandle memPage;
extern RC readLastBlock SMFileHandle fHandle SMPageHandle memPage;
writing blocks to a page file
extern RC writeBlock int pageNum, SMFileHandle fHandle SMPageHandle memPage;
extern RC writeCurrentBlock SMFileHandle fHandle SMPageHandle memPage;
extern RC appendEmptyBlock SMFileHandle fHandle;
extern RC ensureCapacity int numberfPages, SMFileHandle fHandle;
#endif
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started