-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstate.h
executable file
·63 lines (51 loc) · 1.4 KB
/
state.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
#ifndef INODES_H
#define INODES_H
#include <stdio.h>
#include <stdlib.h>
#include <threads.h>
#include "../tecnicofs-api-constants.h"
/* FS root inode number */
#define FS_ROOT 0
#define FREE_INODE -1
#define INODE_TABLE_SIZE 50
#define MAX_DIR_ENTRIES 20
#define SUCCESS 0
#define FAIL -1
#define DELAY 5000
/*
* Contains the name of the entry and respective i-number
*/
typedef struct dirEntry {
char name[MAX_FILE_NAME];
int inumber;
} DirEntry;
/*
* Data is either text (file) or entries (DirEntry)
*/
union Data {
char *fileContents; /* for files */
DirEntry *dirEntries; /* for directories */
};
/*
* I-node definition
*/
typedef struct inode_t {
type nodeType;
union Data data;
pthread_rwlock_t lockP;
} inode_t;
void insert_delay(int cycles);
void inode_table_init();
void inode_table_destroy();
int inode_create(type nType);
int inode_delete(int inumber);
int inode_get(int inumber, type *nType, union Data *data);
int inode_set_file(int inumber, char *fileContents, int len);
int dir_reset_entry(int inumber, int sub_inumber);
int dir_add_entry(int inumber, int sub_inumber, char *sub_name);
void inode_print_tree(FILE *fp, int inumber, char *name);
void lockInumberRead(int inumber);
void lockInumberWrite(int inumber);
void unlockInumberRW(int inumber);
pthread_rwlock_t* getLockInumber(int inumber);
#endif /* INODES_H */