Hi,

I'm attaching the `link` and `unlink` applets (SUSv4).

Regards,
-- 
Pere
From 42e700a6c3aebad10f6c1f4c4c20f45950c18339 Mon Sep 17 00:00:00 2001
From: Pere Orga <[email protected]>
Date: Mon, 13 Feb 2012 02:44:05 +0100
Subject: [PATCH 2/2] link, unlink: new applets


Signed-off-by: Pere Orga <[email protected]>
---
 coreutils/link.c   |   36 ++++++++++++++++++++++++++++++++++++
 coreutils/unlink.c |   36 ++++++++++++++++++++++++++++++++++++
 2 files changed, 72 insertions(+), 0 deletions(-)
 create mode 100644 coreutils/link.c
 create mode 100644 coreutils/unlink.c

diff --git a/coreutils/link.c b/coreutils/link.c
new file mode 100644
index 0000000..fe3b5c0
--- /dev/null
+++ b/coreutils/link.c
@@ -0,0 +1,36 @@
+/* vi: set sw=4 ts=4: */
+/*
+ * link implementation for busybox
+ *
+ * Copyright (c) 2012 Pere Orga <[email protected]>
+ * Licensed under GPLv2 or later, see file LICENSE in this source tree.
+ */
+
+//config:config LINK
+//config:	bool "link"
+//config:	default y
+//config:	help
+//config:	  Call the link system function to create a link to a file
+
+//applet:IF_LINK(APPLET(link, BB_DIR_USR_BIN, BB_SUID_DROP))
+
+//kbuild:lib-$(CONFIG_LINK) += link.o
+
+//usage:#define link_trivial_usage
+//usage:       "TARGET LINK_NAME"
+//usage:#define link_full_usage "\n\n"
+//usage:       "Create a link named LINK_NAME to TARGET\n"
+
+#include "libbb.h"
+
+int link_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
+int link_main(int argc UNUSED_PARAM, char **argv)
+{
+	opt_complementary = "=2";
+	getopt32(argv, "");
+
+	if (link(argv[1], argv[2]))
+		bb_error_msg_and_die("cannot create link %s to %s", argv[2], argv[1]);
+
+	return EXIT_SUCCESS;
+}
diff --git a/coreutils/unlink.c b/coreutils/unlink.c
new file mode 100644
index 0000000..be7715c
--- /dev/null
+++ b/coreutils/unlink.c
@@ -0,0 +1,36 @@
+/* vi: set sw=4 ts=4: */
+/*
+ * unlink implementation for busybox
+ *
+ * Copyright (c) 2012 Pere Orga <[email protected]>
+ * Licensed under GPLv2 or later, see file LICENSE in this source tree.
+ */
+
+//config:config UNLINK
+//config:	bool "unlink"
+//config:	default y
+//config:	help
+//config:	  Call the unlink system function to remove one file
+
+//applet:IF_UNLINK(APPLET(unlink, BB_DIR_USR_BIN, BB_SUID_DROP))
+
+//kbuild:lib-$(CONFIG_UNLINK) += unlink.o
+
+//usage:#define unlink_trivial_usage
+//usage:       "FILE"
+//usage:#define unlink_full_usage "\n\n"
+//usage:       "Remove FILE\n"
+
+#include "libbb.h"
+
+int unlink_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
+int unlink_main(int argc UNUSED_PARAM, char **argv)
+{
+	opt_complementary = "=1";
+	getopt32(argv, "");
+
+	if (unlink(argv[1]))
+		bb_error_msg_and_die("cannot unlink %s", argv[1]);
+
+	return EXIT_SUCCESS;
+}
-- 
1.7.9

_______________________________________________
busybox mailing list
[email protected]
http://lists.busybox.net/mailman/listinfo/busybox

Reply via email to