-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdisk.h
More file actions
56 lines (41 loc) · 1.13 KB
/
disk.h
File metadata and controls
56 lines (41 loc) · 1.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#pragma once
#include "../constants.h"
/*
DISK buffer struct.
char* disk,
char persistentFlag,
int sessionFd
*/
typedef struct DISK_STRUCT {
char disk[DISK_SIZE];
char persistentFlag;
char sessionFileName[64];
} DISK_STRUCT;
/*
Initializes the DISK struct from scratch, or mmaps it if a session file is passed
*/
int _DISK_init(DISK_STRUCT* DISK, char* session_filename);
/*
Deallocates DISK from memory
*/
int _DISK_destroy(DISK_STRUCT* DISK);
/*
Allocates a block on DISK at index block_index.
Returns 0 if successful, -1 otherwise
*/
int _DISK_allocateBlock(DISK_STRUCT* DISK, int block_index);
/*
Deallocates a block on DISK at index block_index.
Returns 0 if successful, -1 otherwise
*/
// DEAD FUNCTION?
int _DISK_deallocateBlock(DISK_STRUCT* DISK, int block_index);
/*
Writes n_bytes of buffer to DISK starting from block_index.
Returns number of blocks written if successful, -1 otherwise
*/
int _DISK_writeBytes(DISK_STRUCT* DISK, int block_index, char* buffer, int n_bytes);
/*
Reads n_bytes from DISK starting from block_index and returns a buffer
*/
char* _DISK_readBytes(DISK_STRUCT* DISK, int block_index, int n_bytes);