From 7c84b7bcee8c667d13cf886cda6c2a3e867626c3 Mon Sep 17 00:00:00 2001 From: Emma Nora Theuer Date: Sat, 19 Oct 2024 22:20:47 +0200 Subject: [PATCH] Implemented several functions that operate on inodes. --- inode.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/inode.c b/inode.c index 2999bae..3f5ecca 100644 --- a/inode.c +++ b/inode.c @@ -1 +1,25 @@ #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; +}