summaryrefslogtreecommitdiff
path: root/coreutils/ln.c
diff options
context:
space:
mode:
authorGlenn L McGrath2003-12-31 23:10:44 +0000
committerGlenn L McGrath2003-12-31 23:10:44 +0000
commitcfc0ad4260149f5cdad59c79051c3779d42b2ff5 (patch)
tree417552339486b47bfdb4bca24b526d24078060fb /coreutils/ln.c
parent7f48a959f53f72fdffb354bebaee1925618f53e6 (diff)
downloadbusybox-cfc0ad4260149f5cdad59c79051c3779d42b2ff5.zip
busybox-cfc0ad4260149f5cdad59c79051c3779d42b2ff5.tar.gz
Batch from Bastian Blank to fix debian bug #216435;
When linking a non existing file busybox ln will report the target missind and not the source:
Diffstat (limited to 'coreutils/ln.c')
-rw-r--r--coreutils/ln.c16
1 files changed, 12 insertions, 4 deletions
diff --git a/coreutils/ln.c b/coreutils/ln.c
index 5217634..0640c66 100644
--- a/coreutils/ln.c
+++ b/coreutils/ln.c
@@ -43,7 +43,8 @@ extern int ln_main(int argc, char **argv)
int flag;
char *last;
char *src_name;
- const char *src;
+ char *src;
+ struct stat statbuf;
int (*link_func)(const char *, const char *);
flag = bb_getopt_ulflags(argc, argv, "sfn");
@@ -61,7 +62,7 @@ extern int ln_main(int argc, char **argv)
}
do {
- src_name = 0;
+ src_name = NULL;
src = last;
if (is_directory(src,
@@ -70,7 +71,14 @@ extern int ln_main(int argc, char **argv)
src_name = bb_xstrdup(*argv);
src = concat_path_file(src, bb_get_last_path_component(src_name));
free(src_name);
- src_name = (char *)src;
+ src_name = src;
+ }
+
+ if (stat(*argv, &statbuf)) {
+ bb_perror_msg(*argv);
+ status = EXIT_FAILURE;
+ free(src_name);
+ continue;
}
if (flag & LN_FORCE) {
@@ -84,7 +92,7 @@ extern int ln_main(int argc, char **argv)
if (link_func(*argv, src) != 0) {
bb_perror_msg(src);
- status = EXIT_FAILURE;;
+ status = EXIT_FAILURE;
}
free(src_name);