[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Lost] Ramdisk
Hi,
Jetzt kompiliert es auch mit -Wall -Werror. Wenn man halt so hohe
Ansprüche hat ;)
diff --git a/apps/ramdisk/init.c b/apps/ramdisk/init.c
index 82e3821..260653e 100755
--- a/apps/ramdisk/init.c
+++ b/apps/ramdisk/init.c
@@ -36,8 +36,6 @@
#include "ramdisk_cdi.h"
#include "cdi/lists.h"
#include <stdio.h>
-// FIXME CDI kennt eigentlich keine POSIX-Funktionen
-#include <time.h>
int ramdisk_fs_init(struct cdi_fs_filesystem* cdi_fs)
{
@@ -50,13 +48,24 @@ int ramdisk_fs_init(struct cdi_fs_filesystem* cdi_fs)
root_res->res.dir = &ramdisk_fs_dir;
root_res->res.loaded = 1;
root_res->res.children = cdi_list_create();
- root_res->creation_time = time(NULL);
+ root_res->creation_time = 0;
cdi_fs->root_res = (struct cdi_fs_res*) root_res;
return 1;
}
+static void destroy_res(struct ramdisk_fs_res *res)
+{
+ struct ramdisk_fs_res *child;
+
+ while ((child = cdi_list_pop(res->res.children))) {
+ destroy_res(child);
+ }
+ ramdisk_fs_res_destroy(res);
+}
+
int ramdisk_fs_destroy(struct cdi_fs_filesystem* fs)
{
- return ramdisk_fs_res_destroy((struct ramdisk_fs_res*)fs->root_res);
+ destroy_res((struct ramdisk_fs_res*)fs->root_res);
+ return 0;
}
diff --git a/apps/ramdisk/res.c b/apps/ramdisk/res.c
index ef02c7a..47afa00 100755
--- a/apps/ramdisk/res.c
+++ b/apps/ramdisk/res.c
@@ -158,7 +158,6 @@ int ramdisk_fs_res_remove_class(struct cdi_fs_stream* stream,
switch (class) {
case CDI_FS_CLASS_FILE:
- free(res->buffer);
res->size = 0;
res->res.file = NULL;
break;
@@ -168,7 +167,6 @@ int ramdisk_fs_res_remove_class(struct cdi_fs_stream* stream,
break;
case CDI_FS_CLASS_LINK:
- free(res->buffer); // In res->buffer steht der Pfad zum Ziel.
res->res.link = NULL;
break;
@@ -207,17 +205,16 @@ int ramdisk_fs_res_remove(struct cdi_fs_stream* stream)
}
}
- ramdisk_fs_res_destroy(res);
-
- return 1;
+ return ramdisk_fs_res_destroy(res);
}
int ramdisk_fs_res_destroy(struct ramdisk_fs_res* res)
{
- struct ramdisk_fs_res *child;
- free(res->res.name);
+ if (cdi_list_size(res->res.children)>0) return 0;
+
free(res->buffer);
- while ((child = cdi_list_pop(res->res.children))) ramdisk_fs_res_destroy(child);
+ free(res->res.name);
+ free(res->res.link_path);
cdi_list_destroy(res->res.children);
free(res);