-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathdisk-array.h
70 lines (48 loc) · 1.52 KB
/
disk-array.h
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
/*
Do not modify this file.
Make all of your changes to main.c instead.
*/
#ifndef DISK_ARRAY_H
#define DISK_ARRAY_H
#include "disk.h"
typedef struct disk_array * disk_array_t;
#define MAX_DISKS (100)
#define MAX_BLOCKS (1000000)
disk_array_t disk_array_create( const char *filename, int disks, int blocks );
/*
Write exactly BLOCK_SIZE bytes to a given block on the virtual disk array.
"d" must be a pointer to a virtual disk, "block" is the block number,
and "data" is a pointer to the data to write.
*/
int disk_array_write( disk_array_t da, int disk, int block, const char *data );
/*
Read exactly BLOCK_SIZE bytes from a given block on the virtual disk.
"d" must be a pointer to a virtual disk, "block" is the block number,
and "data" is a pointer to where the data will be placed.
*/
int disk_array_read( disk_array_t da, int disk, int block, char *data );
/*
Mark a disk as failed; subsequent calls to read or write data will fail
*/
int disk_array_fail_disk( disk_array_t da, int disk);
/*
Mark a disk as recovered; it will zero-out the contents of the disk
*/
int disk_array_recover_disk( disk_array_t da, int disk);
/*
Return the total number of blocks on each virtual disk in the array.
*/
int disk_array_nblocks( disk_array_t da );
/*
Return the number of disks in the virtual disk array
*/
int disk_array_ndisks( disk_array_t da );
/*
Close the virtual disk array.
*/
void disk_array_close( disk_array_t da );
/*
print number of reads and writes
*/
void disk_array_print_stats( disk_array_t da);
#endif // DISK_ARRAY_H