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

Re: [Lost] [Patch] Hardlinks für LostIO



Kevin Wolf wrote:
> Toni Kaufmann schrieb:
>   
>> Index: console/console.c
>> Index: fat/main.c
>> Index: floppy/floppy.c
>> Index: gui/src/main.c
>> Index: kbc/keyboard.c
>> Index: kbc/mouse.c
>> Index: keyboard/keyboard.c
>>     
>
> Wird Zeit, daß wir das mal endgültig rauswerfen...
>
>   
>> Index: tcpip/lostio_if.c
>> Index: textterm/main.c
>> Index: vesa/main.c
>> Index: vga/main.c
>> Index: videodriver/main.c
>> Index: vterm/lostio.c
>> Index: lib/lostio/types/ramfile.c
>> Index: lib/lostio/types/directory.c
>> Index: lib/lostio/lostio.c
>>     
>
> cmos und ide fehlen, wie ich das sehen.
>
>   
cmos muss da nicht rein weil es nur Ramfiles benuzt. Und das mit ide hat
sich ja wohl erledigt.


Hier die 3. Version, mit den besprochenen änderungen ;-)
Index: src/modules/console/console.c
===================================================================
--- src/modules/console/console.c	(Revision 622)
+++ src/modules/console/console.c	(Arbeitskopie)
@@ -65,7 +65,9 @@
     .read = &stdin_read,
     .write = NULL,
     .seek = NULL,
-    .close = NULL
+    .close = NULL,
+    .link = NULL,
+    .unlink = NULL
 };
 
 
Index: src/modules/fat/main.c
===================================================================
--- src/modules/fat/main.c	(Revision 622)
+++ src/modules/fat/main.c	(Arbeitskopie)
@@ -66,6 +66,8 @@
     typehandle->write           = NULL;
     typehandle->seek            = NULL;
     typehandle->close           = NULL;
+    typehandle->link            = NULL;
+    typehandle->unlink          = NULL;
     lostio_register_typehandle(typehandle);
 
     //Den seek-handler aus Ramfile benutzen
Index: src/modules/floppy/floppy.c
===================================================================
--- src/modules/floppy/floppy.c	(Revision 622)
+++ src/modules/floppy/floppy.c	(Arbeitskopie)
@@ -183,6 +183,8 @@
     typehandle->write       = &floppy_write_handler;
     typehandle->seek        = &floppy_seek_handler;
     typehandle->close       = NULL;
+    typehandle->link        = NULL;
+    typehandle->unlink      = NULL;
     lostio_register_typehandle(typehandle);
     
     // In diesem Verzeichnis liegen die Geraetedateien fuer die Einzelnen
Index: src/modules/gui/src/main.c
===================================================================
--- src/modules/gui/src/main.c	(Revision 622)
+++ src/modules/gui/src/main.c	(Arbeitskopie)
@@ -220,6 +220,8 @@
     typehandle_control->write       = &control_write;
     typehandle_control->seek        = NULL;
     typehandle_control->close       = NULL;
+    typehandle_control->link        = NULL;
+    typehandle_control->unlink      = NULL;
     lostio_register_typehandle(typehandle_control);
     
     //Maus-Callback
@@ -232,6 +234,8 @@
     typehandle_control->write       = &mouse_write;
     typehandle_control->seek        = NULL;
     typehandle_control->close       = NULL;
+    typehandle_control->link        = NULL;
+    typehandle_control->unlink      = NULL;
     lostio_register_typehandle(typehandle_mouse);
     // vfstree bauen
     vfstree_create_node("/control" , 255, 0, NULL, 0);
Index: src/modules/kbc/keyboard.c
===================================================================
--- src/modules/kbc/keyboard.c	(Revision 622)
+++ src/modules/kbc/keyboard.c	(Arbeitskopie)
@@ -192,6 +192,8 @@
     typehandle->write       = NULL;
     typehandle->seek        = NULL;
     typehandle->close       = NULL;
+    typehandle->link        = NULL;
+    typehandle->unlink      = NULL;
     lostio_register_typehandle(typehandle);
 
     vfstree_create_node("/keyboard", LOSTIO_TYPES_DIRECTORY, 0, 0, 0);
Index: src/modules/kbc/mouse.c
===================================================================
--- src/modules/kbc/mouse.c	(Revision 622)
+++ src/modules/kbc/mouse.c	(Arbeitskopie)
@@ -41,6 +41,8 @@
     typehandle->write       = NULL;
     typehandle->seek        = NULL;
     typehandle->close       = NULL;
+    typehandle->link        = NULL;
+    typehandle->unlink      = NULL;
     lostio_register_typehandle(typehandle);
 
     //Registrierung von Callback-Dateien
@@ -53,6 +55,8 @@
     typehandle->write       = &mouse_callback_handler;
     typehandle->seek        = NULL;
     typehandle->close       = NULL;
+    typehandle->link        = NULL;
+    typehandle->unlink      = NULL;
     lostio_register_typehandle(typehandle);
 
     vfstree_create_node("/mouse", LOSTIO_TYPES_DIRECTORY, 0, 0, 0);
Index: src/modules/tcpip/lostio_if.c
===================================================================
--- src/modules/tcpip/lostio_if.c	(Revision 622)
+++ src/modules/tcpip/lostio_if.c	(Arbeitskopie)
@@ -89,7 +89,10 @@
     typehandle.write       = &lostio_tcp_write;
     typehandle.seek        = NULL;
     typehandle.close       = &lostio_tcp_close;;
+    typehandle.link        = NULL;
+    typehandle.unlink      = NULL;
 
+
     lostio_register_typehandle(&typehandle);
 
     get_typehandle(LOSTIO_TYPES_DIRECTORY)->not_found = lostio_tcp_not_found;
Index: src/modules/textterm/main.c
===================================================================
--- src/modules/textterm/main.c	(Revision 622)
+++ src/modules/textterm/main.c	(Arbeitskopie)
@@ -37,6 +37,8 @@
     typehandle->write       = &terminal_write;
     typehandle->seek        = NULL;
     typehandle->close       = NULL;
+    typehandle->link        = NULL;
+    typehandle->unlink      = NULL;
     lostio_register_typehandle(typehandle);
     vfstree_create_node("/echo" , LOSTIO_TYPES_OUT, 0, NULL, 0);
     
Index: src/modules/vesa/main.c
===================================================================
--- src/modules/vesa/main.c	(Revision 622)
+++ src/modules/vesa/main.c	(Arbeitskopie)
@@ -75,6 +75,8 @@
     typehandle_information->write       = NULL;
     typehandle_information->seek        = NULL;
     typehandle_information->close       = NULL;
+    typehandle_information->link        = NULL;
+    typehandle_information->unlink      = NULL;
     lostio_register_typehandle(typehandle_information);
     
     vfstree_create_node("/information" , 255, 0, NULL, 0);
Index: src/modules/vga/main.c
===================================================================
--- src/modules/vga/main.c	(Revision 622)
+++ src/modules/vga/main.c	(Arbeitskopie)
@@ -75,6 +75,8 @@
     typehandle_information->write       = NULL;
     typehandle_information->seek        = NULL;
     typehandle_information->close       = NULL;
+    typehandle_information->link        = NULL;
+    typehandle_information->unlink      = NULL;
     lostio_register_typehandle(typehandle_information);
     
     vfstree_create_node("/information" , 255, 0, NULL, 0);
Index: src/modules/videodriver/main.c
===================================================================
--- src/modules/videodriver/main.c	(Revision 622)
+++ src/modules/videodriver/main.c	(Arbeitskopie)
@@ -75,6 +75,8 @@
     typehandle_information->write       = NULL;
     typehandle_information->seek        = NULL;
     typehandle_information->close       = NULL;
+    typehandle_information->link        = NULL;
+    typehandle_information->unlink      = NULL;
     lostio_register_typehandle(typehandle_information);
     
     vfstree_create_node("/information" , 255, 0, NULL, 0);
Index: src/modules/vterm/lostio.c
===================================================================
--- src/modules/vterm/lostio.c	(Revision 622)
+++ src/modules/vterm/lostio.c	(Arbeitskopie)
@@ -75,6 +75,8 @@
     typehandle->write       = NULL;
     typehandle->seek        = NULL;
     typehandle->close       = NULL;
+    typehandle->link        = NULL;
+    typehandle->unlink      = NULL;
     lostio_register_typehandle(typehandle);
 }
 
Index: src/modules/lib/lostio/types/ramfile.c
===================================================================
--- src/modules/lib/lostio/types/ramfile.c	(Revision 622)
+++ src/modules/lib/lostio/types/ramfile.c	(Arbeitskopie)
@@ -68,6 +68,8 @@
     ramfile_typehandle->write        = &ramfile_write;
     ramfile_typehandle->seek         = &ramfile_seek;
     ramfile_typehandle->close        = NULL;
+    ramfile_typehandle->link         = NULL;
+    ramfile_typehandle->unlink       = NULL;
 
     lostio_register_typehandle(ramfile_typehandle);
 }
Index: src/modules/lib/lostio/types/directory.c
===================================================================
--- src/modules/lib/lostio/types/directory.c	(Revision 622)
+++ src/modules/lib/lostio/types/directory.c	(Arbeitskopie)
@@ -61,6 +61,8 @@
     dir_typehandle->write        = NULL;
     dir_typehandle->seek         = &dir_seek;
     dir_typehandle->close        = NULL;
+    dir_typehandle->link         = NULL;
+    dir_typehandle->unlink       = NULL;
 
     lostio_register_typehandle(dir_typehandle);
 }
Index: src/modules/lib/lostio/lostio.c
===================================================================
--- src/modules/lib/lostio/lostio.c	(Revision 622)
+++ src/modules/lib/lostio/lostio.c	(Arbeitskopie)
@@ -74,6 +74,8 @@
     register_message_handler("IO_SEEK ", &rpc_io_seek);
     register_message_handler("IO_EOF  ", &rpc_io_eof);
     register_message_handler("IO_TELL ", &rpc_io_tell);
+    register_message_handler("IO_LINK ", &rpc_io_link);
+    register_message_handler("IO_ULINK", &rpc_io_unlink);
 }
 
 /**
Index: src/modules/lib/lostio/include/lostio_internal.h
===================================================================
--- src/modules/lib/lostio/include/lostio_internal.h	(Revision 622)
+++ src/modules/lib/lostio/include/lostio_internal.h	(Arbeitskopie)
@@ -72,6 +72,13 @@
 ///RPC-Handler fuer ein tell
 void    rpc_io_tell(pid_t pid, dword correlation_id, size_t data_size, void* data);
 
+/// RPC-Handler zum erstellen eines Links
+void    rpc_io_link(pid_t pid, dword correlation_id, size_t data_size, void* data);
+
+/// RPC-Handler zum loeschen eines Links
+void    rpc_io_unlink(pid_t pid, dword correlation_id, size_t data_size, void* data);
+
+
 ///Knoten loeschen
 //bool vfstree_delete_node(char* path);
 
Index: src/modules/include/io.h
===================================================================
--- src/modules/include/io.h	(Revision 622)
+++ src/modules/include/io.h	(Arbeitskopie)
@@ -121,9 +121,29 @@
     {
         io_resource_id_t id;
     } __attribute__ ((packed)) io_tell_request_t;
+    
+    typedef struct
+    {
+        io_resource_id_t target_id;
+        io_resource_id_t dir_id;
 
+        size_t name_len;
+        char name[];
+    } __attribute__ ((packed)) io_link_request_t;
+    
+    typedef struct
+    {
+        io_resource_id_t dir_id;
+
+        size_t name_len;
+        char name[];
+    } __attribute__ ((packed)) io_unlink_request_t;
 #endif
 
+int io_create_link(const char* target_path, const char* link_path,
+    bool hardlink);
+int io_remove_link(const char* link_path);
+
 char* io_get_absolute_path(const char* path);
 char* io_split_filename(const char* path);
 char* io_split_dirname(const char* path);
Index: src/modules/include/lostio.h
===================================================================
--- src/modules/include/lostio.h	(Revision 625)
+++ src/modules/include/lostio.h	(Arbeitskopie)
@@ -115,6 +115,9 @@
     size_t          (*write)(lostio_filehandle_t*,size_t,size_t,void*);
     int             (*seek)(lostio_filehandle_t*,int,int);
     int             (*close)(lostio_filehandle_t*);
+    int             (*link)(lostio_filehandle_t*,lostio_filehandle_t*,
+                        const char*);
+    int             (*unlink)(lostio_filehandle_t*,const char*);
 } typehandle_t;
 
 
Index: src/modules/lib/lost_link.c
===================================================================
--- src/modules/lib/lost_link.c	(Revision 0)
+++ src/modules/lib/lost_link.c	(Revision 0)
@@ -0,0 +1,246 @@
+/*  
+ * Copyright (c) 2007 The LOST Project. All rights reserved.
+ *
+ * This code is derived from software contributed to the LOST Project
+ * by Antoine Kaufmann.
+ *
+ * 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>
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <stdint.h>
+#include <collections.h>
+#include <io.h>
+#include <rpc.h>
+#include <errno.h>
+
+
+/**
+ * Link erstellen
+ *
+ * @param target_path Pfad auf den der Link zeigen soll
+ * @param link_path Pfad an dem der Link erstellt werden soll
+ * @param hardlink TRUE, falls ein Hardlink erstellt werden soll, FALSE sonst
+ *
+ * @return 0 bei Erfolg, im Fehlerfall -1 und errno wird entsprechend gesetzt
+ */
+int io_create_link(const char* target_path, const char* link_path,
+    bool hardlink)
+{
+    int result;
+    FILE* target_file;
+    FILE* link_dir;
+
+    // Jetzt werden Datei- und Verzeichnisname geholt
+    char* link_filename = io_split_filename(link_path);
+    char* link_dirname = io_split_dirname(link_path);
+    if ((link_filename == NULL) || (link_dirname == NULL)) {
+        errno = ENOMEM;
+        result = -1;
+        goto end_free_path;
+    }
+
+    // Link-Ziel oeffnen
+    target_file = fopen(target_path, "r");
+    if (target_file == NULL) {
+        // Wenn das Oeffnen nicht klappt ist die Datei nicht vorhanden,
+        // folglich kann auch kein Link darauf erstellt werden ;-)
+        errno = ENOENT;
+        result = -1;
+        goto end_free_path;
+    }
+    
+    // Verzeichnis oeffnen, in dem der Link angelegt werden soll
+    link_dir = fopen(link_dirname, "rd");
+    if (link_dir == NULL) {
+        errno = ENOENT;
+        result = -1;
+        goto end_close_file;
+    }
+    
+    // Wenn die Beiden nicht im Selben Treiber liegen, ist der Fall eh
+    // erledigt.
+    if (link_dir->pid != target_file->pid) {
+        errno = EXDEV;
+        result = -1;
+        goto end_close_dir;
+    }
+
+    // Hier muss ein Block hin, weil gcc sonst mit dem buffer-Array und den
+    // gotos durcheinander kommt
+    {
+        // Groesse der RPC-Daten errechnen
+        size_t link_len = strlen(link_filename) + 1;
+        size_t size = sizeof(io_link_request_t) + link_len + 1;
+        char buffer[size];
+
+        // Netten Pointer auf den Buffer eirichten
+        io_link_request_t* request = (io_link_request_t*) buffer;
+    
+        // Pfad kopieren
+        request->name_len = link_len - 1;
+        memcpy(request->name, link_filename, link_len);
+    
+        // Ziel eintragen
+        request->target_id = target_file->id;
+        request->dir_id = link_dir->id;
+
+        // RPC durchfuehren und auf Ergebnis warten
+        result = rpc_get_int(target_file->pid, "IO_LINK ", size, buffer);
+        switch (result) {
+            // Ziel oder Verzeichnis nicht in Ordnung
+            case -1:
+                errno = ENOENT;
+                result = -1;
+                break;
+        
+            // Kein Link-Handler eingetragen
+            case -2:
+                errno = EPERM;
+                result = -1;
+                break;
+
+            // RPC-Daten ungueltig
+            case -3:
+                errno = EFAULT;
+                result = -1;
+                break;
+            
+            // Fehler im Handler
+            case -4:
+                // Nicht korrekt, aber irgendwas muss hier genommen werden
+                errno = EPERM;
+                result = -1;
+                break;
+        }
+    }
+
+
+    // Geoeffnetes Link-Ziel und Link-Verzeichnis schliessen
+end_close_dir:
+    fclose(link_dir);
+end_close_file:
+    fclose(target_file);
+
+end_free_path:
+    // Durch Pfade belegten Speicher freigeben
+    free(link_filename);
+    free(link_dirname);
+    return result;
+}
+
+/**
+ * Link loeschen
+ *
+ * @param link_path Pfad der geloescht werden soll
+ *
+ * @return 0 bei Erfolg, im Fehlerfall -1 und errno wird entsprechend gesetzt
+ */
+int io_remove_link(const char* link_path)
+{
+    int result;
+    
+    // Jetzt werden Datei- und Verzeichnisname geholt
+    char* link_dirname = io_split_dirname(link_path);
+    char* link_filename = io_split_filename(link_path);
+    if ((link_dirname == NULL) || (link_filename == NULL)) {
+        errno = ENOMEM;
+        result = -1;
+        goto end_free_path;
+    }
+
+    // Verzeichnis oeffnen, aus dem der Link geloeschen werden soll
+    FILE* link_dir = fopen(link_dirname, "rd");
+    if (link_dir == NULL) {
+        errno = ENOENT;
+        result = -1;
+        goto end_free_path;
+    }
+    
+    // Auch hier wieder ein Block, damit gcc keine Probleme macht
+    {
+        // Groesse der RPC-Daten errechnen
+        size_t link_len = strlen(link_filename) + 1;
+        size_t size = sizeof(io_unlink_request_t) + link_len + 1;
+        char buffer[size];
+
+        // Netten Pointer auf den Buffer eirichten
+        io_unlink_request_t* request = (io_unlink_request_t*) buffer;
+    
+        // Pfad kopieren
+        request->name_len = link_len - 1;
+        memcpy(request->name, link_filename, link_len);
+    
+        // Verzeichnis eintragen
+        request->dir_id = link_dir->id;
+
+        // RPC durchfuehren und auf Ergebnis warten
+        result = rpc_get_int(link_dir->pid, "IO_ULINK", size, buffer);
+        switch (result) {
+            // Ziel oder Verzeichnis nicht in Ordnung
+            case -1:
+                errno = ENOENT;
+                result = -1;
+                break;
+        
+            // Kein Unlink-Handler eingetragen
+            case -2:
+                errno = EPERM;
+                result = -1;
+                break;
+
+            // RPC-Daten ungueltig
+            case -3:
+                errno = EFAULT;
+                result = -1;
+                break;
+            
+            // Fehler im Handler
+            case -4:
+                // Nicht korrekt, aber irgendwas muss hier genommen werden
+                errno = EPERM;
+                result = -1;
+                break;
+        }
+
+    }
+
+    // Geoeffnetes Link-Verzeichnis schliessen
+    fclose(link_dir);
+
+    // Durch Pfade belegten Speicher freigeben
+end_free_path:
+    free(link_filename);
+    free(link_dirname);
+    return result;
+}
+
Index: src/modules/lib/lostio/handler.c
===================================================================
--- src/modules/lib/lostio/handler.c	(Revision 622)
+++ src/modules/lib/lostio/handler.c	(Arbeitskopie)
@@ -341,10 +341,120 @@
 }
 
 
+/**
+ * Ein Prozess hat ein io_link auf einem File-Handle dieses Treibers ausgefuehrt
+ * 
+ * RPC-Rueckgabewerte:
+ *   0: Erfolg
+ *
+ *  -1: Ziel oder Verzeichnis existiert nicht
+ *  -2: Fuer das Verzeichnis ist kein Link-Handler eingetragen
+ *  -3: Das Format der erhaltenen RPC-Daten stimmt nicht
+ *  -4: Beim erstellen des Links ist ein Fehler im Handler aufgetreten
+ */
+void rpc_io_link(pid_t pid, dword correlation_id, size_t data_size, void* data)
+{
+    io_link_request_t* link_request = (io_link_request_t*) data;
+    
+    // Pruefen, ob das Format stimmt, also ob soviele Daten da sind, wie wir
+    // erwarten
+    if ((sizeof(io_link_request_t) > data_size) || ((link_request->name_len +
+        sizeof(io_link_request_t)) > data_size) || (strnlen(link_request->name,
+        link_request->name_len + 1) != link_request->name_len))
+    {
+        rpc_send_int_response(pid, correlation_id, -3);
+        return;
+    }
+   
 
+    // Filehandles fuer Link-Ziel und Verzeichnis holen
+    lostio_filehandle_t* target_filehandle = get_filehandle(pid, link_request->
+        target_id);
+    lostio_filehandle_t* dir_filehandle = get_filehandle(pid, link_request->
+        dir_id);
 
+    // Wenn eines der Filehandles nicht exisitiert muss abgebrochen werden
+    if((target_filehandle == NULL) || (dir_filehandle == NULL))
+    {
+        rpc_send_int_response(pid, correlation_id, -1);
+        return;
+    }
 
+    // Typ-Handle fuer Verzeichnis holen
+    typehandle_t* typehandle = get_typehandle(dir_filehandle->node->type);
+    if((typehandle != NULL) && (typehandle->link != NULL))
+    {
+        int result = typehandle->link(target_filehandle, dir_filehandle,
+            link_request->name);
+        if (result != 0) {
+            result = -4;
+        }
+        rpc_send_int_response(pid, correlation_id, result);
+    }
+    else
+    {
+        rpc_send_int_response(pid, correlation_id, -2);
+    }
+}
+
 /**
+ * Ein Prozess hat ein io_remove auf einem File-Handle dieses Treibers ausgefuehrt
+ *
+ * RPC-Rueckgabewerte:
+ *   0: Erfolg
+ *
+ *  -1: Verzeichnis existiert nicht
+ *  -2: Fuer das Verzeichnis ist kein Unlink-Handler eingetragen
+ *  -3: Das Format der erhaltenen RPC-Daten stimmt nicht
+ *  -4: Beim eigentlichen Loeschen des Links ist ein Fehler aufgetreten
+ */
+void rpc_io_unlink(pid_t pid, dword correlation_id, size_t data_size, void* data)
+{
+    io_unlink_request_t* unlink_request = (io_unlink_request_t*) data;
+
+    // Pruefen, ob das Format stimmt, also ob soviele Daten da sind, wie wir
+    // erwarten
+    if ((sizeof(io_unlink_request_t) > data_size) || ((unlink_request->name_len
+        + sizeof(io_unlink_request_t)) > data_size) || (strnlen(
+        unlink_request->name, unlink_request->name_len + 1) != unlink_request->
+        name_len))
+    {
+        rpc_send_int_response(pid, correlation_id, -3);
+        return;
+    }
+
+    // Filehandles fuer Verzeichnis holen
+    lostio_filehandle_t* dir_filehandle = get_filehandle(pid, unlink_request->
+        dir_id);
+
+    // Wenn eines der Filehandles nicht exisitiert muss abgebrochen werden
+    if (dir_filehandle == NULL)
+    {
+        rpc_send_int_response(pid, correlation_id, -1);
+        return;
+    }
+
+    // Typ-Handle fuer Verzeichnis holen
+    typehandle_t* typehandle = get_typehandle(dir_filehandle->node->type);
+    if((typehandle != NULL) && (typehandle->link != NULL))
+    {
+        int result = typehandle->unlink(dir_filehandle, unlink_request->name);
+        if (result != 0) {
+            result = -4;
+        }
+        rpc_send_int_response(pid, correlation_id, result);
+    }
+    else
+    {
+        rpc_send_int_response(pid, correlation_id, -2);
+    }
+}
+
+
+
+
+
+/**
  * Wird vom RPC-Handler bei einem fopen aufgerufen.
  *
  * @param path Pfad