BarryServer : Git

All the code for all my projects
// BarryServer : Git / Nucleus / commit / f97b909e66a1314d3bb9da413cd515cf47672180 / vfs / fstype.c

// Related

Nucleus

Barry New list iteration in VFS f97b909 (3 years, 3 months ago)
diff --git a/vfs/fstype.c b/vfs/fstype.c
index 9043ba4..f157a71 100644
--- a/vfs/fstype.c
+++ b/vfs/fstype.c
@@ -16,31 +16,12 @@ struct FSType {
 	Inode *(*mount)(FSType *, int, const char *, void *);
 };
 
-/* Find callback data */
-struct FindData {
-	const char *name;
-	FSType *result;
-};
-
 /* File System Type object type */
 ObjectType fstypeType = {
 	.name = "FILE SYSTEM TYPE",
 	.size = sizeof(FSType),
 };
 
-/* Callback for finding a file system type */
-static int
-compare_fstype_name(void *object, void *data)
-{
-	FSType *type = object;
-	struct FindData *find = data;
-	if (!strcmp(type->name, find->name)) {
-		find->result = type;
-		return 1;
-	}
-	return 0;
-}
-
 /* Create a new file system type */
 void
 register_fstype(const char *name, mount_callback_t mount)
@@ -55,13 +36,13 @@ int
 mount_fstype(const char *name, int flags, const char *src, void *data,
              Inode **root)
 {
-	struct FindData find = {
-		.name = name,
-		.result = NULL,
-	};
-	iterate(fstypeType.objects, compare_fstype_name, &find);
-	if (!find.result)
+	FSType *type;
+	foreach (fstypeType.objects, type) {
+		if (!strcmp(type->name, name))
+			break;
+	}
+	if (!type)
 		return -ENODEV;
-	*root = find.result->mount(find.result, flags, src, data);
+	*root = type->mount(type, flags, src, data);
 	return 0;
 }