-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathstructs.h
More file actions
96 lines (73 loc) · 2.55 KB
/
structs.h
File metadata and controls
96 lines (73 loc) · 2.55 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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
/**************************************************************
Class: CSC-415-03 Spring 2020
Group Name: Orphaned Zombies
Name: Stanley Brooks
Student ID: 918764527
Name: Cameron Harte
Student ID: 918245645
Name: Robert Clarkson
Student ID: 915433914
Name: Michael Zheng
Student ID: 917581488
Project: Assignment 3 – File System
File: structs.h
Description: This is the header for the structs. And these are the function
declaration.
**************************************************************/
#ifndef stucts_h
#define stucts_h
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdint.h>
#define MAX_ARGS 8
#define ARG_LENGTH 32 // CHAR
struct filesystem_volume {
char* filename;
uint64_t volumeSize;
uint64_t blockSize;
uint64_t blockCount;
uint64_t map_start;
uint64_t file_start;
int retVal;
};
struct arguments {
char args[MAX_ARGS][ARG_LENGTH];
char* opt;
int argc;
};
/* initialize all bytes in 'buffer' with 'ch' where n is the size of buffer */
void initializeLBA(char* buffer, char ch, int n);
/* return the index of the LBA */
int getIndex(char* key, struct filesystem_volume volume);
/* line 1 of LBA */
/* Name can only be 16 characters long */
int addName(char* name, char* buffer);
/* line 2 of LBA */
/* Type can only be 16 characters long */
int addType(char* type, char* buffer);
/* line 3 of LBA */
int connectMetaData(int index, char* buffer);
/* line 4 to 32 of LBA */
int addChild(int child, int parent, struct filesystem_volume volume);
/* return 0 if line empty, 1 if line not empty */
int getLine(char* buffer, char* line, int startIndex);
/* return 0 if line empty, 1 if line not empty */
int getName(char* buffer, char* name);
/* return 0 if line empty, 1 if line not empty */
int getType(char* buffer, char* type);
/* returns 1 if it is the LBA, 0 if it isnt */
int LBAis(struct filesystem_volume volume, int index, char* name, char* type);
/* delete line(x16 char) at 'linestart' from 'buffer' and replace with 'initChar' */
void deleteLine(char* buffer, int lineStart, char initChar);
/* returns the next empty index in volume.map[index] */
int getNextEmptyLBA(struct filesystem_volume volume);
/* volume.map[i] = 0 */
void setMap(int at, char ch, struct filesystem_volume volume); // char
/* volume.map[i] */
char getMap(int at, struct filesystem_volume volume); // char
int LBAfreeCount(struct filesystem_volume volume);
long getFileSize(char *filename);
void readNBytes(char* buffer, char* name, int startIndex, int readAmount);
long getNumberOfBytes(const char *name);
#endif /* stucts_h */