1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
/* vi: set sw=4 ts=4: */
/*
* Licensed under GPLv2 or later, see file LICENSE in this source tree.
*/
#include "libbb.h"
#include "bb_archive.h"
void FAST_FUNC create_or_remember_link(llist_t **link_placeholders
IF_PLATFORM_MINGW32(UNUSED_PARAM),
const char *target,
const char *linkname,
int hard_link IF_PLATFORM_MINGW32(UNUSED_PARAM))
{
#if !ENABLE_PLATFORM_MINGW32
if (hard_link || target[0] == '/' || strstr(target, "..")) {
llist_add_to_end(link_placeholders,
xasprintf("%c%s%c%s", hard_link, linkname, '\0', target)
);
return;
}
if (symlink(target, linkname) != 0) {
/* shared message */
bb_perror_msg_and_die("can't create %slink '%s' to '%s'",
"sym", linkname, target
);
}
#else
/* symlink isn't implemented for WIN32, just issue a warning */
bb_perror_msg("can't create %slink '%s' to '%s'", "sym", linkname, target);
#endif
}
#if !ENABLE_PLATFORM_MINGW32
void FAST_FUNC create_links_from_list(llist_t *list)
{
while (list) {
char *target;
target = list->data + 1 + strlen(list->data + 1) + 1;
if ((*list->data ? link : symlink) (target, list->data + 1)) {
/* shared message */
bb_error_msg_and_die("can't create %slink '%s' to '%s'",
*list->data ? "hard" : "sym",
list->data + 1, target
);
}
list = list->link;
}
}
#endif
|