summaryrefslogtreecommitdiff
path: root/Userland/rm.cpp
diff options
context:
space:
mode:
authorAndreas Kling <awesomekling@gmail.com>2019-01-22 07:03:44 +0100
committerAndreas Kling <awesomekling@gmail.com>2019-01-22 07:03:44 +0100
commitbda0c935c26867f3a613723fd3bc7a84aef110ba (patch)
treed6525c8b1eb967fda047930f9afff1ed01158455 /Userland/rm.cpp
parent2f2f28f2127b83ff3454b8b7c42cada550fdbf10 (diff)
downloadserenity-bda0c935c26867f3a613723fd3bc7a84aef110ba.zip
Add unlink() syscall and /bin/rm.
This patch adds most of the plumbing for working file deletion in Ext2FS. Directory entries are removed and inode link counts updated. We don't yet update the inode or block bitmaps, I will do that separately.
Diffstat (limited to 'Userland/rm.cpp')
-rw-r--r--Userland/rm.cpp18
1 files changed, 18 insertions, 0 deletions
diff --git a/Userland/rm.cpp b/Userland/rm.cpp
new file mode 100644
index 0000000000..606d92d7d9
--- /dev/null
+++ b/Userland/rm.cpp
@@ -0,0 +1,18 @@
+#include <stdio.h>
+#include <errno.h>
+#include <unistd.h>
+
+int main(int argc, char** argv)
+{
+ if (argc != 2) {
+ fprintf(stderr, "usage: rm <path>\n");
+ return 1;
+ }
+ int rc = unlink(argv[1]);
+ if (rc < 0) {
+ perror("unlink");
+ return 1;
+ }
+ return 0;
+}
+