ScholarMatic | 24/7 Homework Help

ScholarMatic Will Help You Write Your Essays and Term Papers

Answered » You can buy a ready-made answer or pick a professional tutor to order an original one.

Programming assignment to be done in C

by | Nov 29, 2023 | questions

Programming assignment due Tuesday, has to pass all the tests given in the file test.c

Document Preview:

pa2/ext.c #include “ext.h”
#include

static FILE *fh;

int sfs_read_block(void *buf, blkid bid)
{
fseek(fh, bid * BLOCK_SIZE, SEEK_SET);
fread(buf, 1, BLOCK_SIZE, fh);
return 0;
}

int sfs_write_block(void *buf, blkid bid)
{
fseek(fh, bid * BLOCK_SIZE, SEEK_SET);
fwrite(buf, 1, BLOCK_SIZE, fh);
return 0;
}

void sfs_init_storage()
{
fh = fopen(“storage”, “w+b”);
}

void sfs_close_storage()
{
fclose(fh);
}

pa2/ext.h #ifndef EXT_H_
#define EXT_H_

#include “fs.h”

void sfs_init_storage();
void sfs_close_storage();
int sfs_read_block(void *buf, blkid bid);
int sfs_write_block(void *buf, blkid bid);

#endif

pa2/exta1.c #include “ext.h”
#undef BLOCK_SIZE
#include “a1/mydisk.h”

void report_latency(int latency) {}

int sfs_read_block(void *buf, blkid bid)
{
mydisk_read_block(bid, buf);
return 0;
}

int sfs_write_block(void *buf, blkid bid)
{
mydisk_write_block(bid, buf);
return 0;
}

void sfs_init_storage()
{
mydisk_init(“storage”, 1024, 0);
}

void sfs_close_storage()
{
mydisk_close();
}

pa2/fs.c #include “fs.h”
#include “ext.h”

#include
#include
#include

/* constant of how many bits in one freemap entry */
#define SFS_NBITS_IN_FREEMAP_ENTRY (sizeof(u32)*8)

/* in-memory superblock (in consistent with the disk copy) */
static sfs_superblock_t sb;
/* freemap, u32 array (in consistent with the disk copy) */
static u32 *freemap;
/* file descriptor table */
static fd_struct_t fdtable[SFS_MAX_OPENED_FILES];

/*
* Flush the in-memory freemap to disk
*/
static void sfs_flush_freemap()
{
size_t i;
blkid bid = 1;
char *p = (char *)freemap;
/* TODO: write freemap block one by one */
}

/*
* Allocate a free block, mark it in the freemap and flush the freemap to disk
*/
static blkid sfs_alloc_block()
{
u32 size = sb.nfreemap_blocks * BLOCK_SIZE / sizeof(u32);
u32 i, j;
/* TODO: find a freemap entry that…

Attachments:


ScholarMatic: Explanation & Answer

Your ready answer from a verified tutor is just a click away for as little as $14.99


  

Click Order Now to get 100% Original Answer Customized to your instructions!

HOME TO CERTIFIED WRITERS

Why Place An Order With Us?

  • Certified Editors
  • 24/7 Customer Support
  • Profesional Research
  • Easy to Use System Interface
  • Student Friendly Pricing

Have a similar question?

PLAGIRAISM FREE PAPERS

All papers we provide are well-researched, properly formatted and cited.

TOP QUALITY

All papers we provide are well-researched, properly formatted and cited.

HIGHLY SECURED

All papers we provide are well-researched, properly formatted and cited.

ScholarMatic: Get Started

Assignment Writing Service

Feel safe and secure when placing an order on our portal!
Fruitful cooperation begins with solid guarantees, and we are professional enough to promise perfect results. Let’s get it started!