Compare commits
No commits in common. "7c84b7bcee8c667d13cf886cda6c2a3e867626c3" and "782d8db162b69ff1e07608edea32d6e1484b5932" have entirely different histories.
7c84b7bcee
...
782d8db162
3 changed files with 21 additions and 51 deletions
24
inode.c
24
inode.c
|
@ -1,25 +1 @@
|
||||||
#include "inode.h"
|
#include "inode.h"
|
||||||
|
|
||||||
Inode* find_inode(char filename[], struct inode_table* itable) {
|
|
||||||
for (uint32_t i = 0; i < itable->size; i++) {
|
|
||||||
if (strcmp(filename, itable->inodes[i]->name)) {
|
|
||||||
return itable->inodes[i];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool inode_exists(struct inode_table* itable, char filename[]) {
|
|
||||||
for (uint32_t i = 0; i < itable->size; i++) {
|
|
||||||
if (strcmp(filename, itable->inodes[i]->name)) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
void delete_inode(struct inode_table* itable, char filename[]) {
|
|
||||||
Inode* wanted_inode = find_inode(filename, itable);
|
|
||||||
free(wanted_inode);
|
|
||||||
wanted_inode = NULL;
|
|
||||||
}
|
|
||||||
|
|
31
inode.h
31
inode.h
|
@ -3,54 +3,31 @@
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdbool.h>
|
|
||||||
#include <string.h>
|
|
||||||
|
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
|
|
||||||
typedef struct Inode Inode;
|
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 {
|
struct Inode {
|
||||||
// file information
|
// file information
|
||||||
char name[64];
|
char name[64];
|
||||||
uint32_t filesize;
|
uint32_t filesize;
|
||||||
|
|
||||||
// ownership and permissions
|
// ownership and permissions
|
||||||
uint8_t user_permissions;
|
uint16_t permissions;
|
||||||
uint8_t group_permissions;
|
|
||||||
|
|
||||||
// UID
|
|
||||||
uint16_t owner;
|
uint16_t owner;
|
||||||
// GID
|
|
||||||
uint16_t group;
|
uint16_t group;
|
||||||
|
|
||||||
// timestamps
|
// timestamps
|
||||||
tm created;
|
tm created;
|
||||||
tm last_modified;
|
tm last_modified;
|
||||||
|
|
||||||
|
// fs attributes
|
||||||
|
uint32_t index;
|
||||||
uint16_t block_count;
|
uint16_t block_count;
|
||||||
block* data_block;
|
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* create_inode(char name[64], 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_
|
#endif // INODE_H_
|
||||||
|
|
17
super.c
17
super.c
|
@ -9,6 +9,14 @@
|
||||||
#define VERSION 0.0.0.1
|
#define VERSION 0.0.0.1
|
||||||
#define BLOCKSIZE 4096
|
#define BLOCKSIZE 4096
|
||||||
|
|
||||||
|
uint32_t free_blocks;
|
||||||
|
uint32_t inode_count;
|
||||||
|
|
||||||
|
struct inode_table {
|
||||||
|
// TODO: Change currently hardcoded value to actually accurately describe the size of the filesystem, only for temporary purposes.
|
||||||
|
Inode* inodes[640000];
|
||||||
|
};
|
||||||
|
|
||||||
struct super_block {
|
struct super_block {
|
||||||
// fs info
|
// fs info
|
||||||
char version[8];
|
char version[8];
|
||||||
|
@ -27,4 +35,13 @@ struct super_block {
|
||||||
struct inode_table* inode_table;
|
struct inode_table* inode_table;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// TODO: Do research on how the fuck to actually do this kind of Array operation
|
||||||
|
Inode* find_inode(char filename[], struct super_block sblock) {
|
||||||
|
struct inode_table* itable = sblock.inode_table;
|
||||||
|
// while (itable[inode] != NULL; inode++) {
|
||||||
|
// if (strcmp(filename, itable[inode]->filesize))
|
||||||
|
// }
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
#endif // SUPER_H_
|
#endif // SUPER_H_
|
||||||
|
|
Loading…
Reference in a new issue