From deae871343abd4c0f5eb217748c70f1f0f52e194 Mon Sep 17 00:00:00 2001 From: Philip Guenther Date: Sat, 7 Nov 2015 21:52:56 +0000 Subject: Use linkat() instead of link() so that hardlinks of symlinks work ok millert@ --- sbin/restore/utilities.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'sbin/restore') diff --git a/sbin/restore/utilities.c b/sbin/restore/utilities.c index ebaac08e981..5f499464345 100644 --- a/sbin/restore/utilities.c +++ b/sbin/restore/utilities.c @@ -1,4 +1,4 @@ -/* $OpenBSD: utilities.c,v 1.18 2015/01/16 06:40:00 deraadt Exp $ */ +/* $OpenBSD: utilities.c,v 1.19 2015/11/07 21:52:55 guenther Exp $ */ /* $NetBSD: utilities.c,v 1.11 1997/03/19 08:42:56 lukem Exp $ */ /* @@ -36,6 +36,7 @@ #include #include +#include #include #include #include @@ -200,7 +201,8 @@ linkit(char *existing, char *new, int type) return (FAIL); } } else if (type == HARDLINK) { - if (!Nflag && link(existing, new) < 0) { + if (!Nflag && linkat(AT_FDCWD, existing, AT_FDCWD, new, 0) + < 0) { warn("cannot create hard link %s->%s", new, existing); return (FAIL); -- cgit v1.2.3