-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathutilities.h
More file actions
70 lines (44 loc) · 1.58 KB
/
utilities.h
File metadata and controls
70 lines (44 loc) · 1.58 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
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <sys/mman.h>
#include <string.h>
#include <errno.h>
#include "ext2.h"
#define TRUE 1
#define FALSE 0
#define INODE_BITMAP 1
#define BLOCK_BITMAP 0
extern char unsigned *disk;
// sb, gp
struct ext2_super_block *getSuperblock(void);
struct ext2_group_desc *getGroupDesc(void);
// bitmap
char unsigned *getBitmap(int bitmapNum);
int getBit(char unsigned * bitmap, int index);
int getFirstEmptyBitIndex(int bitmap);
void changeBitmap(char unsigned *bitmap, int idx, char mode);
// inode
struct ext2_inode *getInodeTable(void);
struct ext2_inode *getInode(int inodeNum);
int initInode(unsigned short mode);
void deleteInode(int inodeNum);
// block
char unsigned *getBlock(int blockNum);
int allocateNewBlock(void);
// dir_entry
struct ext2_dir_entry_2 *getPreDirent(struct ext2_inode *parentInode, char *childFileName);
int searchFileInDir(struct ext2_inode *inode, char *fileName);
int calculateActuralSize(struct ext2_dir_entry_2 *dirent);
struct ext2_dir_entry_2 *allocateNewDirent(struct ext2_inode *parent_inode, int size);
struct ext2_dir_entry_2 *allocateDirentHelper(int blockNum, int size);
struct ext2_dir_entry_2 *initNewDirent(struct ext2_inode *parentInode, int childInodeNum, int type, char *fileName);
unsigned int *initSingleIndirect(int blockNum);
// path handling
int getInodeFromPath(char *path);
void getFileNameFromPath(char *fileName, char *path);
void getParentDirPath(char *path);
void rm(struct ext2_inode *parentInode, char *childFileName);