Distributed File System 1
Distributed file system in C
Loading...
Searching...
No Matches
block.c File Reference
#include "block.h"
#include <stdbool.h>

Functions

 ImplList (Block)
Block Block_deserialize (Buffer buf)
 Deserialize a Buffer into a block.
Buffer ListBlock_serialize (ListBlock list)
 Serialize a List of Block's into a Buffer.
ListBlock ListBlock_deserialize (Buffer buf)
 Deserialize a Buffer into a List of Block's.
void insert_into_block (UUID *fid, UUID *nid, UUID *cid, size_t *seq)
 INSERT into the Block table.
ListBlock select_from_block (UUID *bid, UUID *fid, UUID *nid, UUID *cid, size_t *seq)
 SELECT from the Block table.
ListBlock Block_get_db (void)
 Get the Block table from the database.
void Block_set_db (ListBlock blocks)
 Write the database with the List of Block's.
void print_block (Block block)
 Print a Block's data as a tuple.

Function Documentation

◆ Block_deserialize()

Block Block_deserialize ( Buffer buffer)

Deserialize a Buffer into a block.

Caller must free memory in Block.cid.

Parameters
bufferThe Buffer you want to deserialize
Returns
The Block that the Buffer represents

◆ Block_get_db()

ListBlock Block_get_db ( void )

Get the Block table from the database.

Returns
a List of Block's

◆ Block_set_db()

void Block_set_db ( ListBlock blocks)

Write the database with the List of Block's.

Parameters
blocksthe List of Block's that you want to overwrite the database with

◆ ImplList()

ImplList ( Block )

◆ insert_into_block()

void insert_into_block ( UUID * fid,
UUID * nid,
UUID * cid,
size_t * seq )

INSERT into the Block table.

Parameters
fidUUID of file's INode or NULL
nidUUID of DNode or NULL
cidstring representing Block's chunk ID or NULL

◆ ListBlock_deserialize()

ListBlock ListBlock_deserialize ( Buffer buf)

Deserialize a Buffer into a List of Block's.

Caller must free memory in Block.cid.

Parameters
bufferThe Buffer you want to deserialize
Returns
The List of Block's that the Buffer represents

◆ ListBlock_serialize()

Buffer ListBlock_serialize ( ListBlock list)

Serialize a List of Block's into a Buffer.

Caller must free memory in Buffer.buf.

Parameters
listthe List of Block's that you want to serialize
Returns
the Buffer that the ListBlock represents

◆ print_block()

void print_block ( Block block)

Print a Block's data as a tuple.

Parameters
blockthe Block to be printed

◆ select_from_block()

ListBlock select_from_block ( UUID * bid,
UUID * fid,
UUID * nid,
UUID * cid,
size_t * seq )

SELECT from the Block table.

Parameters
bidthe Block's UUID or NULL
fidthe Block's INode's file's UUID or NULL
nidthe Block's DNode's UUID or NULL
cidthe Block's chunk ID or NULL
Returns
a ListBlock of the possible matches