changeset: 92:60c036a99b20
tag: tip
user: Connor Lane Smith <cls_AT_lubutu.com>
date: Wed Jun 22 23:45:03 2011 +0100
files: ln.c util/enmasse.c
description:
ln: try link first
diff -r 0cc176955187 -r 60c036a99b20 ln.c
--- a/ln.c Wed Jun 22 23:04:56 2011 +0100
+++ b/ln.c Wed Jun 22 23:45:03 2011 +0100
@@ -34,7 +34,14 @@
int
ln(const char *s1, const char *s2)
{
- if(fflag && remove(s2) == -1 && errno != ENOENT)
- eprintf("remove %s:", s2);
- return (sflag ? symlink : link)(s1, s2);
+ int (*flink)(const char *, const char *) = sflag ? symlink : link;
+
+ if(flink(s1, s2) == 0)
+ return 0;
+ if(fflag && errno == EEXIST) {
+ if(remove(s2) == -1)
+ eprintf("remove %s:", s2);
+ return flink(s1, s2);
+ }
+ return -1;
}
diff -r 0cc176955187 -r 60c036a99b20 util/enmasse.c
--- a/util/enmasse.c Wed Jun 22 23:04:56 2011 +0100
+++ b/util/enmasse.c Wed Jun 22 23:45:03 2011 +0100
@@ -44,7 +44,7 @@
if(stat(a, &sta) == 0 && stat(b, &stb) == 0
&& sta.st_dev == stb.st_dev && sta.st_ino == stb.st_ino)
- eprintf("%s: same file as: %s\n", b, a);
+ eprintf("%s -> %s: same file\n", a, b);
if(fn(a, b) == -1)
- eprintf("%s:", b);
+ eprintf("%s -> %s:", a, b);
}
Received on Thu Jun 23 2011 - 00:45:08 CEST
This archive was generated by hypermail 2.2.0 : Thu Jun 23 2011 - 00:48:06 CEST