Nucleus
Barry New list iteration in VFS f97b909 (3 years, 3 months ago)
diff --git a/vfs/superblock.c b/vfs/superblock.c
index 4d90e3d..41f35b3 100644
--- a/vfs/superblock.c
+++ b/vfs/superblock.c
@@ -9,31 +9,12 @@
#include <sys/types.h>
#include <nucleus/vfs.h>
-/* Data for find callback */
-struct FindData {
- ino_t ino;
- Inode *result;
-};
-
/* Super Block object type */
ObjectType superBlockType = {
.name = "SUPER BLOCK",
.size = sizeof(SuperBlock),
};
-/* Find an Inode by ino value */
-static int
-compare_inode_ino(void *addr, void *data)
-{
- Inode *inode = addr;
- struct FindData *find = data;
- if (find->ino == inode->ino){
- find->result = get(inode);
- return 1;
- }
- return 0;
-}
-
/* Allocate an Inode */
Inode *
super_alloc_inode(SuperBlock *sb)
@@ -48,10 +29,9 @@ Inode *
super_find_inode(SuperBlock *sb, ino_t ino)
{
Inode *inode;
- struct FindData find = {
- .ino = ino,
- .result = NULL,
- };
- iterate(sb->inodes, compare_inode_ino, &find);
- return find.result;
+ foreach (sb->inodes, inode) {
+ if (inode->ino == ino)
+ break;
+ }
+ return inode;
}