-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmfs.h
More file actions
103 lines (88 loc) · 3.4 KB
/
mfs.h
File metadata and controls
103 lines (88 loc) · 3.4 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
97
98
99
100
101
102
/**************************************************************
* Class:: CSC-415-02 Summer 2025
* Name::Phillip Davis, Igor Tello, Jared Aung, Preet Vithani
* Student IDs:: 923980431, 923043807, 922772159, 923575806
* GitHub-Name::R3plug
* Group-Name::Team Kentucky Kernels
* Project:: Basic File System
*
* File:: mfs.h
*
* Description::
* This is the file system interface.
* This is the interface needed by the driver to interact with
* your filesystem.
*
**************************************************************/
#ifndef _MFS_H
#define _MFS_H
#include <sys/types.h>
#include <unistd.h>
#include <time.h>
#include "b_io.h"
#include "dirLow.h"
#include <dirent.h>
#define FT_REGFILE DT_REG
#define FT_DIRECTORY DT_DIR
#define FT_LINK DT_LNK
#ifndef uint64_t
typedef u_int64_t uint64_t;
#endif
#ifndef uint32_t
typedef u_int32_t uint32_t;
#endif
// This structure is returned by fs_readdir to provide the caller with information
// about each file as it iterates through a directory
struct fs_diriteminfo
{
unsigned short d_reclen; /* length of this record */
unsigned char fileType;
char d_name[256]; /* filename max filename is 255 characters */
};
// This is a private structure used only by fs_opendir, fs_readdir, and fs_closedir
// Think of this like a file descriptor but for a directory - one can only read
// from a directory. This structure helps you (the file system) keep track of
// which directory entry you are currently processing so that everytime the caller
// calls the function readdir, you give the next entry in the directory
typedef struct
{
/*****TO DO: Fill in this structure with what your open/read directory needs *****/
unsigned short d_reclen; /* length of this record */
unsigned short dirEntryPosition; /* which directory entry position, like file pos */
//DE * directory; /* Pointer to the loaded directory you want to iterate */
struct fs_diriteminfo * di; /* Pointer to the structure you return from read */
struct DirHandle *handle; // Pointer to loaded directory
} fdDir;
typedef struct DirHandle
{
DE * entries; // pointer to the array of directory entries loaded from disk
int totalEntries; // total number of entries loaded into memory
int currentIndex; // current index for iterating through the entries
} DirHandle;
// Key directory functions
int fs_mkdir(const char *pathname, mode_t mode);
int fs_rmdir(const char *pathname);
// Directory iteration functions
fdDir * fs_opendir(const char *pathname);
struct fs_diriteminfo *fs_readdir(fdDir *dirp);
int fs_closedir(fdDir *dirp);
// Misc directory functions
char * fs_getcwd(char *pathname, size_t size);
int fs_setcwd(char *pathname); //linux chdir
int fs_isFile(char * filename); //return 1 if file, 0 otherwise
int fs_isDir(char * pathname); //return 1 if directory, 0 otherwise
int fs_delete(char* filename); //removes a file
// This is the strucutre that is filled in from a call to fs_stat
struct fs_stat
{
off_t st_size; /* total size, in bytes */
blksize_t st_blksize; /* blocksize for file system I/O */
blkcnt_t st_blocks; /* number of 512B blocks allocated */
time_t st_accesstime; /* time of last access */
time_t st_modtime; /* time of last modification */
time_t st_createtime; /* time of last status change */
/* add additional attributes here for your file system */
};
int fs_stat(const char *path, struct fs_stat *buf);
char* mc(int size);
#endif