Added permissions enum and inode table struct, add several function that operate on inodes
This commit is contained in:
parent
ca02fd7338
commit
890c08c2ee
1 changed files with 27 additions and 4 deletions
31
inode.h
31
inode.h
|
@ -3,31 +3,54 @@
|
|||
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdbool.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "util.h"
|
||||
|
||||
typedef struct Inode Inode;
|
||||
|
||||
enum permissions {
|
||||
R = 1,
|
||||
W = 2,
|
||||
X = 4
|
||||
};
|
||||
|
||||
struct inode_table {
|
||||
// the following keyword spam purely exist so I definitely see it with highlighting.
|
||||
// NOTE, TODO, FIXME, DEPRECATED, HACK, IMPORTANT: always initialize all values to be null when the inode table is created!!!!
|
||||
// TODO: Change currently hardcoded value to actually accurately describe the size of the filesystem, only for temporary purposes.
|
||||
Inode* inodes[640000];
|
||||
uint32_t size;
|
||||
uint32_t used_inodes;
|
||||
uint32_t free_inodes;
|
||||
};
|
||||
|
||||
struct Inode {
|
||||
// file information
|
||||
char name[64];
|
||||
uint32_t filesize;
|
||||
|
||||
// ownership and permissions
|
||||
uint16_t permissions;
|
||||
uint8_t user_permissions;
|
||||
uint8_t group_permissions;
|
||||
|
||||
// UID
|
||||
uint16_t owner;
|
||||
// GID
|
||||
uint16_t group;
|
||||
|
||||
// timestamps
|
||||
tm created;
|
||||
tm last_modified;
|
||||
|
||||
// fs attributes
|
||||
uint32_t index;
|
||||
uint16_t block_count;
|
||||
block* data_block;
|
||||
};
|
||||
|
||||
Inode* create_inode(char name[64], uint16_t owner, uint16_t group, block* data_block);
|
||||
Inode* create_inode(char name[64], uint8_t user_permissions, uint8_t group_permissions, uint16_t owner, uint16_t group, block* data_block);
|
||||
Inode* find_inode(char filename[], struct inode_table* itable);
|
||||
bool inode_exists(struct inode_table* itable, char filename[]);
|
||||
void delete_inode(struct inode_table* itable, char filename[]);
|
||||
|
||||
#endif // INODE_H_
|
||||
|
|
Loading…
Reference in a new issue