-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdisk.h
More file actions
29 lines (19 loc) · 705 Bytes
/
disk.h
File metadata and controls
29 lines (19 loc) · 705 Bytes
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
#ifndef SFS_DISK_H
#define SFS_DISK_H
#include <stdint.h>
#include <stdio.h>
const static int BLOCKSIZE = 4 * 1024;
#define MAX_FILENAME_LENGTH 20
typedef struct disk {
uint32_t size; // size of the disk
uint32_t blocks; // number of usable blocks (except stat block)
uint32_t reads; // number of block reads performed
uint32_t writes; // number of block writes performed
FILE *data; // File pointer to persistant data
} disk;
disk *create_disk(char *filename, int nbytes);
int read_block(disk *diskptr, int blocknr, void *block_data);
int write_block(disk *diskptr, int blocknr, void *block_data);
int free_disk(disk *diskptr);
int update_disk_stats(disk *d);
#endif