From 7292b538bcce8c678cc80bde890e56785b4eba15 Mon Sep 17 00:00:00 2001
From: dtrg <none@none>
Date: Mon, 27 Sep 2010 20:44:49 +0000
Subject: [PATCH] Added support for remove() and unlink().

---
 plat/linux386/include/unistd.h |  2 ++
 plat/linux386/libsys/pmfile    |  2 ++
 plat/linux386/libsys/remove.c  | 15 +++++++++++++++
 plat/linux386/libsys/unlink.c  | 15 +++++++++++++++
 4 files changed, 34 insertions(+)
 create mode 100644 plat/linux386/libsys/remove.c
 create mode 100644 plat/linux386/libsys/unlink.c

diff --git a/plat/linux386/include/unistd.h b/plat/linux386/include/unistd.h
index 1002da580..715e321d7 100644
--- a/plat/linux386/include/unistd.h
+++ b/plat/linux386/include/unistd.h
@@ -55,6 +55,8 @@ extern int read(int fd, void* buffer, size_t count);
 extern int write(int fd, void* buffer, size_t count);
 extern off_t lseek(int fildes, off_t offset, int whence);
 extern int fcntl(int fd, int op, ...);
+extern int unlink(const char* path);
+extern int remove(const char* path);
 
 /* Special variables */
 
diff --git a/plat/linux386/libsys/pmfile b/plat/linux386/libsys/pmfile
index 6ab47b504..45b3e284e 100644
--- a/plat/linux386/libsys/pmfile
+++ b/plat/linux386/libsys/pmfile
@@ -26,6 +26,8 @@ libsys_linux386 = acklibrary {
 	ackfile (d.."sbrk.c"),
 	ackfile (d.."signal.c"),
 	ackfile (d.."write.c"),
+	ackfile (d.."unlink.c"),
+	ackfile (d.."remove.c"),
 	
 	install = pm.install("%BINDIR%lib/%PLATFORM%/libsys.a"),
 }
diff --git a/plat/linux386/libsys/remove.c b/plat/linux386/libsys/remove.c
new file mode 100644
index 000000000..d1978d11b
--- /dev/null
+++ b/plat/linux386/libsys/remove.c
@@ -0,0 +1,15 @@
+/* $Source$
+ * $State$
+ * $Revision$
+ */
+
+#include <stdlib.h>
+#include <errno.h>
+#include <unistd.h>
+#include <stdarg.h>
+#include "libsys.h"
+
+int remove(const char* path)
+{
+	return unlink(path);
+}
diff --git a/plat/linux386/libsys/unlink.c b/plat/linux386/libsys/unlink.c
new file mode 100644
index 000000000..67c4dc11c
--- /dev/null
+++ b/plat/linux386/libsys/unlink.c
@@ -0,0 +1,15 @@
+/* $Source$
+ * $State$
+ * $Revision$
+ */
+
+#include <stdlib.h>
+#include <errno.h>
+#include <unistd.h>
+#include <stdarg.h>
+#include "libsys.h"
+
+int unlink(const char* path)
+{
+	return _syscall(__NR_unlink, (quad) path, 0, 0);
+}