diff options
| author | Ron Yorston <rmy@pobox.com> | 2022-05-16 13:56:05 +0100 |
|---|---|---|
| committer | Ron Yorston <rmy@pobox.com> | 2022-05-16 14:03:51 +0100 |
| commit | 7eff2ff404f2a4961be927de6bd23b7fb702080e (patch) | |
| tree | 04d0e0252e904733a723bb536e9aef3504f0325f /miscutils | |
| parent | 7fb95a2a569ca6d68dad4cef5b7b299e9fe68e2b (diff) | |
| download | busybox-w32-7eff2ff404f2a4961be927de6bd23b7fb702080e.tar.gz busybox-w32-7eff2ff404f2a4961be927de6bd23b7fb702080e.tar.bz2 busybox-w32-7eff2ff404f2a4961be927de6bd23b7fb702080e.zip | |
jn: new applet
Add a Windows-specific applet to create a directory junction.
Usage: jn DIR JUNC
where DIR must be an existing directory on a local drive and JUNC
must not currently exist.
There isn't a simple WIN32 API to create directory junctions.
The implementation of mklink in ReactOS provided useful inspiration.
Diffstat (limited to 'miscutils')
| -rw-r--r-- | miscutils/jn.c | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/miscutils/jn.c b/miscutils/jn.c new file mode 100644 index 000000000..db6a3e6d9 --- /dev/null +++ b/miscutils/jn.c | |||
| @@ -0,0 +1,37 @@ | |||
| 1 | /* | ||
| 2 | * directory junction creation for busybox | ||
| 3 | * | ||
| 4 | * Copyright (C) 2017 Denys Vlasenko <vda.linux@googlemail.com> | ||
| 5 | * Copyright (C) 2022 Ron Yorston <rmy@pobox.com> | ||
| 6 | * | ||
| 7 | * Licensed under GPLv2, see file LICENSE in this source tree. | ||
| 8 | */ | ||
| 9 | //config:config JN | ||
| 10 | //config: bool "jn (3.2 kb)" | ||
| 11 | //config: default y | ||
| 12 | //config: depends on PLATFORM_MINGW32 | ||
| 13 | //config: help | ||
| 14 | //config: Creates a directory junction. | ||
| 15 | |||
| 16 | //applet:IF_JN(APPLET_NOEXEC(jn, jn, BB_DIR_USR_BIN, BB_SUID_DROP, jn)) | ||
| 17 | |||
| 18 | //kbuild:lib-$(CONFIG_JN) += jn.o | ||
| 19 | |||
| 20 | //usage:#define jn_trivial_usage | ||
| 21 | //usage: "DIR JUNC" | ||
| 22 | //usage:#define jn_full_usage "\n\n" | ||
| 23 | //usage: "Create directory junction JUNC to DIR" | ||
| 24 | |||
| 25 | #include "libbb.h" | ||
| 26 | |||
| 27 | int jn_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; | ||
| 28 | int jn_main(int argc UNUSED_PARAM, char **argv) | ||
| 29 | { | ||
| 30 | getopt32(argv, "^" "" "\0" "=2"); | ||
| 31 | argv += optind; | ||
| 32 | if (create_junction(argv[0], argv[1]) != 0) { | ||
| 33 | bb_perror_msg_and_die("can't create junction '%s' to '%s'", | ||
| 34 | argv[1], argv[0]); | ||
| 35 | } | ||
| 36 | return EXIT_SUCCESS; | ||
| 37 | } | ||
