Distributed File System 1
Distributed file system in C
Loading...
Searching...
No Matches
block.h
Go to the documentation of this file.
1/* lib/block.h
2 *
3 * These are the data blocks that the DFS uses.
4 *
5 */
6#ifndef BLOCK_H_
7#define BLOCK_H_
8
9#ifdef __cplusplus
10extern "C" {
11#endif
12
13/* ----- Includes ----- */
14
15#include "uuid.h"
16
17/* ----- Macros ----- */
18
19#define BLOCK_TABLE "data/block.bin"
20
21/* ----- Types ----- */
22
24typedef struct {
29 size_t seq;
30} Block;
31
33
34/* ----- Functions ----- */
35
36
41Buffer Block_serialize(Block block);
42
49
56
62ListBlock ListBlock_deserialize(Buffer buf);
63
69void insert_into_block(UUID* fid, UUID* nid, UUID* cid, size_t* seq);
70
78ListBlock select_from_block(UUID* bid, UUID* fid, UUID* nid, UUID* cid, size_t* seq);
79
83ListBlock Block_get_db(void);
84
88void Block_set_db(ListBlock blocks);
89
93void print_block(Block block);
94
95#ifdef __cplusplus
96}
97#endif
98
99#endif // BLOCK_H_
ListBlock select_from_block(UUID *bid, UUID *fid, UUID *nid, UUID *cid, size_t *seq)
SELECT from the Block table.
Definition block.c:115
Block Block_deserialize(Buffer buffer)
Deserialize a Buffer into a block.
Definition block.c:19
void print_block(Block block)
Print a Block's data as a tuple.
Definition block.c:159
Buffer ListBlock_serialize(ListBlock list)
Serialize a List of Block's into a Buffer.
Definition block.c:61
void insert_into_block(UUID *fid, UUID *nid, UUID *cid, size_t *seq)
INSERT into the Block table.
Definition block.c:82
ListBlock ListBlock_deserialize(Buffer buf)
Deserialize a Buffer into a List of Block's.
Definition block.c:66
void Block_set_db(ListBlock blocks)
Write the database with the List of Block's.
Definition block.c:146
ListBlock Block_get_db(void)
Get the Block table from the database.
Definition block.c:132
#define DefList(type)
Definition list.h:93
void list(Enchufe cliente)
Definition meta-data.c:14
Associates a DNode's connection data with an INode's data and the data on disk at cid.
Definition block.h:24
UUID nid
Node ID (foreign from DNode) default 0.
Definition block.h:27
UUID fid
File ID (foreign from INode) default 0.
Definition block.h:26
size_t seq
The order of this chunk.
Definition block.h:29
UUID bid
Block ID (primary key)
Definition block.h:25
UUID cid
Chunk ID default "".
Definition block.h:28
Byte buffer.
Definition lib.h:92
UUID type Layout taken from: https://en.wikipedia.org/wiki/Universally_unique_identifier#Binary_repre...
Definition uuid.h:24