Isaac Dunham | ea23c25 | 2014-06-22 20:44:25 +0200 | [diff] [blame] | 1 | /* vi: set sw=4 ts=4: */ |
Denys Vlasenko | a02a4e9 | 2017-10-05 15:19:25 +0200 | [diff] [blame^] | 2 | /* |
| 3 | * unlink for busybox |
Isaac Dunham | ea23c25 | 2014-06-22 20:44:25 +0200 | [diff] [blame] | 4 | * |
| 5 | * Copyright (C) 2014 Isaac Dunham <ibid.ag@gmail.com> |
| 6 | * |
| 7 | * Licensed under GPLv2, see LICENSE in this source tree |
| 8 | */ |
Isaac Dunham | ea23c25 | 2014-06-22 20:44:25 +0200 | [diff] [blame] | 9 | //config:config UNLINK |
Denys Vlasenko | 4eed2c6 | 2017-07-18 22:01:24 +0200 | [diff] [blame] | 10 | //config: bool "unlink (3.5 kb)" |
Isaac Dunham | ea23c25 | 2014-06-22 20:44:25 +0200 | [diff] [blame] | 11 | //config: default y |
| 12 | //config: help |
Denys Vlasenko | 72089cf | 2017-07-21 09:50:55 +0200 | [diff] [blame] | 13 | //config: unlink deletes a file by calling unlink() |
Isaac Dunham | ea23c25 | 2014-06-22 20:44:25 +0200 | [diff] [blame] | 14 | |
Denys Vlasenko | 819b47a | 2017-08-03 03:29:32 +0200 | [diff] [blame] | 15 | //applet:IF_UNLINK(APPLET_NOFORK(unlink, unlink, BB_DIR_USR_BIN, BB_SUID_DROP, unlink)) |
Isaac Dunham | ea23c25 | 2014-06-22 20:44:25 +0200 | [diff] [blame] | 16 | |
Denys Vlasenko | af3f420 | 2016-11-23 14:46:56 +0100 | [diff] [blame] | 17 | //kbuild:lib-$(CONFIG_UNLINK) += unlink.o |
| 18 | |
Isaac Dunham | ea23c25 | 2014-06-22 20:44:25 +0200 | [diff] [blame] | 19 | //usage:#define unlink_trivial_usage |
| 20 | //usage: "FILE" |
| 21 | //usage:#define unlink_full_usage "\n\n" |
| 22 | //usage: "Delete FILE by calling unlink()" |
| 23 | |
| 24 | #include "libbb.h" |
| 25 | |
| 26 | int unlink_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; |
| 27 | int unlink_main(int argc UNUSED_PARAM, char **argv) |
| 28 | { |
Denys Vlasenko | 22542ec | 2017-08-08 21:55:02 +0200 | [diff] [blame] | 29 | getopt32(argv, "^" "" "\0" "=1"); |
Isaac Dunham | ea23c25 | 2014-06-22 20:44:25 +0200 | [diff] [blame] | 30 | argv += optind; |
| 31 | xunlink(argv[0]); |
| 32 | return 0; |
| 33 | } |