[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Lost] [LOST] [Patch] Ramdisk



Am Montag, 15. September 2008 20:50:03 schrieb Janosch Gräf:
> So Ramdisk baut jetzt richtig ab und kann auch symbolische Links.

Und hier nochmal so, daß es auch mit LOST kompiliert.
Index: trunk/src/modules/cdi/ramdisk/dir.c
===================================================================
--- /dev/null
+++ trunk/src/modules/cdi/ramdisk/dir.c
@@ -0,0 +1,67 @@
+/*
+ * Copyright (c) 2008 The LOST Project. All rights reserved.
+ *
+ * This code is derived from software contributed to the LOST Project
+ * by Alexander Siol.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *     This product includes software developed by the LOST Project
+ *     and its contributors.
+ * 4. Neither the name of the LOST Project nor the names of its
+ *    contributors may be used to endorse or promote products derived
+ *    from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#include <string.h>
+// FIXME CDI kennt eigentlich keine POSIX-Funktionen
+#include <time.h>
+#include "cdi/lists.h"
+
+#include "ramdisk_cdi.h"
+
+
+cdi_list_t ramdisk_fs_dir_list(struct cdi_fs_stream* stream)
+{
+    return stream->res->children;
+}
+
+int ramdisk_fs_dir_create_child(struct cdi_fs_stream* stream, const char* name,
+                             struct cdi_fs_res* parent)
+{
+    struct ramdisk_fs_res* res = malloc(sizeof(*res));
+    struct ramdisk_fs_res* parent_res = (struct ramdisk_fs_res*) parent;
+
+    memset(res, 0, sizeof(*res));
+
+    res->res.loaded = 1;
+    res->res.name = strdup(name);
+    res->res.res = &ramdisk_fs_res;
+    res->res.children = cdi_list_create();
+    res->creation_time = time(NULL);
+
+    cdi_list_push(parent_res->res.children, res);
+    res->res.parent = parent;
+
+    stream->res = (struct cdi_fs_res*) res;
+    return 1;
+}
Index: trunk/src/modules/cdi/ramdisk/ramdisk_cdi.h
===================================================================
--- /dev/null
+++ trunk/src/modules/cdi/ramdisk/ramdisk_cdi.h
@@ -0,0 +1,105 @@
+/*
+ * Copyright (c) 2008 The LOST Project. All rights reserved.
+ *
+ * This code is derived from software contributed to the LOST Project
+ * by Alexander Siol.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *     This product includes software developed by the LOST Project
+ *     and its contributors.
+ * 4. Neither the name of the LOST Project nor the names of its
+ *    contributors may be used to endorse or promote products derived
+ *    from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef _RAMDISK_CDI_H_
+#define _RAMDISK_CDI_H_
+
+#include <stdint.h>
+#include <stdlib.h>
+
+#include "cdi/fs.h"
+
+
+/**
+ * Dateisystemressource fuer ramdisk
+ */
+struct ramdisk_fs_res {
+    struct cdi_fs_res res;
+
+    // Buffer fuer die Daten, und dessen Groesse
+    void* buffer;
+    size_t size;
+
+    // Zugriffszeiten (Meta-Informationen)
+    int64_t creation_time;
+    int64_t access_time;
+    int64_t modification_time;
+};
+
+
+// CDI-IF
+int ramdisk_fs_init(struct cdi_fs_filesystem* fs);
+int ramdisk_fs_destroy(struct cdi_fs_filesystem* fs);
+
+// CDI Res
+int     ramdisk_fs_res_load(struct cdi_fs_stream* stream);
+int     ramdisk_fs_res_unload(struct cdi_fs_stream* stream);
+int     ramdisk_fs_res_remove(struct cdi_fs_stream* stream);
+int     ramdisk_fs_res_rename(struct cdi_fs_stream* stream, const char* name);
+//int     ramdisk_fs_res_move(struct cdi_fs_stream* stream, struct cdi_fs_res* dest);
+int     ramdisk_fs_res_assign_class(struct cdi_fs_stream* stream,
+            cdi_fs_res_class_t class);
+int     ramdisk_fs_res_remove_class(struct cdi_fs_stream* stream,
+            cdi_fs_res_class_t class);
+int64_t ramdisk_fs_res_meta_read(struct cdi_fs_stream* stream, cdi_fs_meta_t meta);
+int     ramdisk_fs_res_meta_write(struct cdi_fs_stream* stream, cdi_fs_meta_t meta,
+    int64_t value);
+int ramdisk_fs_res_destroy(struct ramdisk_fs_res* res);
+
+// CDI File
+size_t  ramdisk_fs_file_read(struct cdi_fs_stream* stream, uint64_t start,
+            size_t size, void* data);
+size_t  ramdisk_fs_file_write(struct cdi_fs_stream* stream, uint64_t start,
+            size_t size, const void* data);
+int     ramdisk_fs_file_truncate(struct cdi_fs_stream* stream, uint64_t size);
+
+// CDI Dir
+cdi_list_t  ramdisk_fs_dir_list(struct cdi_fs_stream* stream);
+int         ramdisk_fs_dir_create_child(struct cdi_fs_stream* stream,
+                const char* name, struct cdi_fs_res* parent);
+
+// CDI Link
+const char* ramdisk_fs_link_read(struct cdi_fs_stream* stream);
+int         ramdisk_fs_link_write(struct cdi_fs_stream* stream, const char* path);
+
+
+// ramdisk-Ressourcen(-Typen)
+extern struct cdi_fs_res_res    ramdisk_fs_res;
+extern struct cdi_fs_res_file   ramdisk_fs_file;
+extern struct cdi_fs_res_dir    ramdisk_fs_dir;
+extern struct cdi_fs_res_link   ramdisk_fs_link;
+
+#endif
+
Index: trunk/src/modules/cdi/ramdisk/file.c
===================================================================
--- /dev/null
+++ trunk/src/modules/cdi/ramdisk/file.c
@@ -0,0 +1,95 @@
+/*
+ * Copyright (c) 2008 The LOST Project. All rights reserved.
+ *
+ * This code is derived from software contributed to the LOST Project
+ * by Alexander Siol.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *     This product includes software developed by the LOST Project
+ *     and its contributors.
+ * 4. Neither the name of the LOST Project nor the names of its
+ *    contributors may be used to endorse or promote products derived
+ *    from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "ramdisk_cdi.h"
+
+size_t ramdisk_fs_file_read(struct cdi_fs_stream* stream, uint64_t start,
+    size_t size, void* data)
+{
+    struct ramdisk_fs_res* res = (struct ramdisk_fs_res*) stream->res;
+
+    // maximal bis Ende lesen.
+    if ((res->size - start) < size) {
+        size = res->size - start;
+    }
+
+    memcpy(data, res->buffer + start, size);
+    return size;
+}
+
+size_t ramdisk_fs_file_write(struct cdi_fs_stream* stream, uint64_t start,
+    size_t size, const void* data)
+{
+    struct ramdisk_fs_res* res = (struct ramdisk_fs_res*) stream->res;
+
+    // Es soll mehr geschrieben werden als Platz ist. Buffer vergroessern!.
+    if ((res->size - start) < size) {
+        void* new_buffer;
+        size_t new_size;
+        new_size = start + size;
+        if (!(new_buffer = realloc(res->buffer,new_size))) {
+            stream->error = CDI_FS_ERROR_INTERNAL;
+            return 0;
+        }
+        memset(new_buffer + res->size, 0, new_size - res->size);
+        res->buffer = new_buffer;
+        res->size = new_size;
+    }
+
+    memcpy(res->buffer + start, data, size);
+    return size;
+}
+
+int ramdisk_fs_file_truncate(struct cdi_fs_stream* stream, uint64_t size)
+{
+    struct ramdisk_fs_res* res = (struct ramdisk_fs_res*) stream->res;
+
+    // Nichts zu tun
+    if (size == res->size) {
+        return 1;
+    }
+
+    void* new_buffer;
+    if (!(new_buffer = realloc(res->buffer,size))) {
+        stream->error = CDI_FS_ERROR_INTERNAL;
+    }
+    if (res->size < size) {
+        memset(new_buffer + res->size,0,size - res->size);
+    }
+
+    res->buffer = new_buffer;
+    res->size = size;
+    return 1;
+}
Index: trunk/src/modules/cdi/ramdisk/init.c
===================================================================
--- /dev/null
+++ trunk/src/modules/cdi/ramdisk/init.c
@@ -0,0 +1,62 @@
+/*
+ * Copyright (c) 2008 The LOST Project. All rights reserved.
+ *
+ * This code is derived from software contributed to the LOST Project
+ * by Alexander Siol.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *     This product includes software developed by the LOST Project
+ *     and its contributors.
+ * 4. Neither the name of the LOST Project nor the names of its
+ *    contributors may be used to endorse or promote products derived
+ *    from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#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)
+{
+    struct ramdisk_fs_res* root_res;
+
+    root_res = malloc(sizeof(*root_res));
+    memset(root_res, 0, sizeof(*root_res));
+    root_res->res.name = strdup("/");
+    root_res->res.res = &ramdisk_fs_res;
+    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);
+
+    cdi_fs->root_res = (struct cdi_fs_res*) root_res;
+    return 1;
+}
+
+int ramdisk_fs_destroy(struct cdi_fs_filesystem* fs)
+{
+    return ramdisk_fs_res_destroy((struct ramdisk_fs_res*)fs->root_res);
+}
Index: trunk/src/modules/cdi/ramdisk/main.c
===================================================================
--- /dev/null
+++ trunk/src/modules/cdi/ramdisk/main.c
@@ -0,0 +1,98 @@
+/*
+ * Copyright (c) 2008 The LOST Project. All rights reserved.
+ *
+ * This code is derived from software contributed to the LOST Project
+ * by Alexander Siol.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *     This product includes software developed by the LOST Project
+ *     and its contributors.
+ * 4. Neither the name of the LOST Project nor the names of its
+ *    contributors may be used to endorse or promote products derived
+ *    from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <stdint.h>
+#include <stdlib.h>
+#include <stdio.h>
+
+#include "cdi/fs.h"
+#include "cdi/misc.h"
+
+#include "ramdisk_cdi.h"
+
+struct ramdisk_driver {
+    struct cdi_fs_driver fs;
+};
+
+static struct ramdisk_driver ramdisk_driver;
+static const char* driver_name = "ramdisk";
+
+static int ramdisk_driver_init(struct ramdisk_driver* driver);
+static void ramdisk_driver_destroy(struct cdi_driver* driver);
+
+#ifdef CDI_STANDALONE
+int main()
+#else
+int init_ramdisk()
+#endif
+{
+    cdi_init();
+
+    if (ramdisk_driver_init(&ramdisk_driver) != 0) {
+        return -1;
+    }
+    cdi_fs_driver_register((struct cdi_fs_driver*) &ramdisk_driver);
+
+#ifdef CDI_STANDALONE
+    cdi_run_drivers();
+#endif
+
+    return 0;
+}
+
+/**
+ * Initialisiert die Datenstrukturen fuer den ramdisk-Treiber
+ */
+static int ramdisk_driver_init(struct ramdisk_driver* driver)
+{
+    // Konstruktor der Vaterklasse
+    cdi_fs_driver_init((struct cdi_fs_driver*) driver);
+
+    // Namen setzen
+    driver->fs.drv.name = driver_name;
+    driver->fs.fs_init = ramdisk_fs_init;
+    driver->fs.fs_destroy = ramdisk_fs_destroy;
+
+    driver->fs.drv.destroy = ramdisk_driver_destroy;
+    return 0;
+}
+
+/**
+ * Deinitialisiert die Datenstrukturen fuer den ramdisk-Treiber
+ */
+static void ramdisk_driver_destroy(struct cdi_driver* driver)
+{
+    cdi_fs_driver_destroy((struct cdi_fs_driver*) driver);
+}
Index: trunk/src/modules/cdi/ramdisk/res.c
===================================================================
--- /dev/null
+++ trunk/src/modules/cdi/ramdisk/res.c
@@ -0,0 +1,225 @@
+/*
+ * Copyright (c) 2008 The LOST Project. All rights reserved.
+ *
+ * This code is derived from software contributed to the LOST Project
+ * by Alexander Siol.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *     This product includes software developed by the LOST Project
+ *     and its contributors.
+ * 4. Neither the name of the LOST Project nor the names of its
+ *    contributors may be used to endorse or promote products derived
+ *    from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "ramdisk_cdi.h"
+
+int ramdisk_fs_res_load(struct cdi_fs_stream* stream)
+{
+    struct ramdisk_fs_res* res = (struct ramdisk_fs_res*) stream->res;
+
+    if (res->res.loaded) {
+        return 0;
+    }
+
+    res->res.loaded = 1;
+    return 1;
+}
+
+int ramdisk_fs_res_unload(struct cdi_fs_stream* stream)
+{
+    struct ramdisk_fs_res* res = (struct ramdisk_fs_res*) stream->res;
+
+    if (!res->res.loaded) {
+        return 0;
+    }
+
+    res->res.loaded = 0;
+    return 1;
+}
+
+int64_t ramdisk_fs_res_meta_read(struct cdi_fs_stream* stream, cdi_fs_meta_t meta)
+{
+    struct ramdisk_fs_res* res = (struct ramdisk_fs_res*) stream->res;
+
+    switch (meta) {
+        case CDI_FS_META_SIZE:
+            return res->size;
+
+        case CDI_FS_META_USEDBLOCKS:
+            return 1;
+
+        case CDI_FS_META_BLOCKSZ:
+            return res->size;
+
+        case CDI_FS_META_BESTBLOCKSZ:
+            return res->size;
+
+        case CDI_FS_META_CREATETIME:
+            return res->creation_time;
+
+        case CDI_FS_META_ACCESSTIME:
+            return res->access_time;
+
+        case CDI_FS_META_CHANGETIME:
+            return res->modification_time;
+    }
+
+    return 0;
+}
+
+int ramdisk_fs_res_meta_write(struct cdi_fs_stream* stream, cdi_fs_meta_t meta,
+                           int64_t value)
+{
+    struct ramdisk_fs_res* res = (struct ramdisk_fs_res*) stream->res;
+
+    switch (meta) {
+        case CDI_FS_META_ACCESSTIME:
+            res->access_time = value;
+            return 1;
+
+        case CDI_FS_META_CHANGETIME:
+            res->modification_time = value;
+            return 1;
+
+        // RO:
+        case CDI_FS_META_SIZE:
+        case CDI_FS_META_USEDBLOCKS:
+        case CDI_FS_META_BESTBLOCKSZ:
+        case CDI_FS_META_BLOCKSZ:
+        case CDI_FS_META_CREATETIME:
+            return 0;
+    }
+
+    return 0;
+}
+
+int ramdisk_fs_res_assign_class(struct cdi_fs_stream* stream,
+                             cdi_fs_res_class_t class)
+{
+    struct ramdisk_fs_res* res = (struct ramdisk_fs_res*) stream->res;
+
+    // In ramdisk koennen die Ressource nur zu maximal einer Klasse gleichzeitig
+    // gehoeren
+    if (res->res.file || res->res.dir || res->res.link || res->res.special)
+    {
+        stream->error = CDI_FS_ERROR_ONS;
+        return 0;
+    }
+
+    switch (class) {
+        case CDI_FS_CLASS_FILE:
+            res->res.file = &ramdisk_fs_file;
+            break;
+
+        case CDI_FS_CLASS_DIR:
+            res->res.dir = &ramdisk_fs_dir;
+            break;
+
+        case CDI_FS_CLASS_LINK:
+            res->res.link = &ramdisk_fs_link;
+            break;
+
+        case CDI_FS_CLASS_SPECIAL:
+            stream->error = CDI_FS_ERROR_NOT_IMPLEMENTED;
+            goto error_out;
+            break;
+
+    };
+
+    return 1;
+
+error_out:
+    return 0;
+}
+
+int ramdisk_fs_res_remove_class(struct cdi_fs_stream* stream,
+            cdi_fs_res_class_t class)
+{
+    struct ramdisk_fs_res* res = (struct ramdisk_fs_res*) stream->res;
+
+    switch (class) {
+        case CDI_FS_CLASS_FILE:
+            res->res.file = NULL;
+            break;
+
+        case CDI_FS_CLASS_DIR:
+            res->res.dir = NULL;
+            break;
+
+        case CDI_FS_CLASS_LINK:
+            res->res.link = NULL;
+            break;
+
+        case CDI_FS_CLASS_SPECIAL:
+            res->res.special = NULL;
+            break;
+    };
+
+    return 1;
+}
+
+int ramdisk_fs_res_rename(struct cdi_fs_stream* stream, const char* name)
+{
+    struct ramdisk_fs_res* res = (struct ramdisk_fs_res*) stream->res;
+    free(res->res.name);
+    res->res.name = strdup(name);
+    return 1;
+}
+
+int ramdisk_fs_res_remove(struct cdi_fs_stream* stream)
+{
+    struct ramdisk_fs_res* res = (struct ramdisk_fs_res*) stream->res;
+
+    if (res->res.file!=NULL || res->res.dir!=NULL || res->res.link!=NULL || res->res.special!=NULL) {
+        stream->error = CDI_FS_ERROR_ONS;
+        return 0;
+    }
+
+    // Link aus der Liste der Vater-Resource entfernen
+    size_t i;
+    struct ramdisk_fs_res* child;
+    for (i=0;(child = cdi_list_get(res->res.parent->children,i));i++) {
+        if (child==res) {
+            cdi_list_remove(res->res.parent->children,i);
+            break;
+        }
+    }
+
+    ramdisk_fs_res_destroy(res);
+
+    return 1;
+}
+
+int ramdisk_fs_res_destroy(struct ramdisk_fs_res* res)
+{
+    struct ramdisk_fs_res *child;
+    free(res->res.name);
+    free(res->buffer);
+    while ((child = cdi_list_pop(res->res.children))) ramdisk_fs_res_destroy(child);
+    cdi_list_destroy(res->res.children);
+    free(res);
+
+    return 1;
+}
Index: trunk/src/modules/cdi/ramdisk/resources.c
===================================================================
--- /dev/null
+++ trunk/src/modules/cdi/ramdisk/resources.c
@@ -0,0 +1,71 @@
+/*
+ * Copyright (c) 2008 The LOST Project. All rights reserved.
+ *
+ * This code is derived from software contributed to the LOST Project
+ * by Alexander Siol.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *     This product includes software developed by the LOST Project
+ *     and its contributors.
+ * 4. Neither the name of the LOST Project nor the names of its
+ *    contributors may be used to endorse or promote products derived
+ *    from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "ramdisk_cdi.h"
+
+struct cdi_fs_res_res   ramdisk_fs_res = {
+    .load = ramdisk_fs_res_load,
+    .unload = ramdisk_fs_res_unload,
+
+    .meta_read = ramdisk_fs_res_meta_read,
+    .meta_write = ramdisk_fs_res_meta_write,
+
+    .assign_class = ramdisk_fs_res_assign_class,
+    .remove_class = ramdisk_fs_res_remove_class,
+
+    .rename = ramdisk_fs_res_rename,
+    .remove = ramdisk_fs_res_remove
+};
+
+struct cdi_fs_res_file  ramdisk_fs_file = {
+    // Prinzipiell haben wir nur ausfuehrbare Dateien, der Rest wird mit den
+    // Berechtigungen geregelt
+    .executable = 1,
+
+    .read = ramdisk_fs_file_read,
+    .write = ramdisk_fs_file_write,
+    .truncate = ramdisk_fs_file_truncate
+};
+
+struct cdi_fs_res_dir   ramdisk_fs_dir = {
+    .list = ramdisk_fs_dir_list,
+    .create_child = ramdisk_fs_dir_create_child
+};
+
+struct cdi_fs_res_link  ramdisk_fs_link = {
+    .read_link = ramdisk_fs_link_read,
+    .write_link = ramdisk_fs_link_write
+};
+
Index: trunk/src/modules/cdi/ramdisk/link.c
===================================================================
--- /dev/null
+++ trunk/src/modules/cdi/ramdisk/link.c
@@ -0,0 +1,52 @@
+/*
+ * Copyright (c) 2008 The LOST Project. All rights reserved.
+ *
+ * This code is derived from software contributed to the LOST Project
+ * by Alexander Siol.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *     This product includes software developed by the LOST Project
+ *     and its contributors.
+ * 4. Neither the name of the LOST Project nor the names of its
+ *    contributors may be used to endorse or promote products derived
+ *    from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "ramdisk_cdi.h"
+
+const char *ramdisk_fs_link_read(struct cdi_fs_stream *stream)
+{
+    struct ramdisk_fs_res* res = (struct ramdisk_fs_res*) stream->res;
+
+    return res->buffer;
+}
+
+int ramdisk_fs_link_write(struct cdi_fs_stream *stream, const char *path) {
+    struct ramdisk_fs_res* res = (struct ramdisk_fs_res*) stream->res;
+
+    free(res->buffer);
+    res->buffer = strdup(path);
+
+    return 1;
+}