diff options
author | Philip Guenther <guenther@cvs.openbsd.org> | 2015-11-07 21:52:56 +0000 |
---|---|---|
committer | Philip Guenther <guenther@cvs.openbsd.org> | 2015-11-07 21:52:56 +0000 |
commit | deae871343abd4c0f5eb217748c70f1f0f52e194 (patch) | |
tree | 31fb4c234b60838678d9b3c714d4cf3b0fe3ff98 /sbin/restore | |
parent | aae7b7ebe81ba98596f22f2f87fed605c217e067 (diff) |
Use linkat() instead of link() so that hardlinks of symlinks work
ok millert@
Diffstat (limited to 'sbin/restore')
-rw-r--r-- | sbin/restore/utilities.c | 6 |
1 files changed, 4 insertions, 2 deletions
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 <ufs/ufs/dir.h> #include <err.h> +#include <fcntl.h> #include <stdarg.h> #include <stdio.h> #include <stdlib.h> @@ -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); |