-
Notifications
You must be signed in to change notification settings - Fork 0
/
directory.h
37 lines (28 loc) · 1023 Bytes
/
directory.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
// Directory manipulation functions.
//
// Feel free to use as inspiration.
// based on cs3650 starter code
#ifndef DIRECTORY_H
#define DIRECTORY_H
#define DIR_NAME_LENGTH 20
#include "blocks.h"
#include "inode.h"
#include "slist.h"
#include <sys/stat.h>
// used to keep track of name and inumber of files
// directories do not get entries in this implementation (they hold the
// entries of their files)
typedef struct dirent {
char name[DIR_NAME_LENGTH];
int inum;
} dirent_t;
// Initalize the root directory data block (the only directory supported
// by this implementation).
void directory_init();
// Determine if the given inode's directory has an try with the given name. Return the
// inumber of the file if true, return -1 if false.
int directory_lookup(inode_t *dd, const char *name);
// Create a new directory entry with the given name and inum. Place its dirent_t struct
// in the given inode's directory data block.
int directory_put(inode_t *dd, const char *name, mode_t mode, int inum);
#endif