NetBSD Problem Report #10569
Received: (qmail 16842 invoked from network); 11 Jul 2000 15:16:04 -0000
Message-Id: <200007111515.e6BFFx222731@edge.sky.yamashina.kyoto.jp>
Date: Wed, 12 Jul 2000 00:15:59 +0900 (JST)
From: Takahiro Kambe <taca@sky.yamashina.kyoto.jp>
Reply-To: taca@sky.yamashina.kyoto.jp
To: gnats-bugs@gnats.netbsd.org
Subject: Restore(8) with -u option failed to create hard link
X-Send-Pr-Version: 3.95
>Number: 10569
>Category: bin
>Synopsis: Restore(8) with -u option failed to create hard link
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: bin-bug-people
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Tue Jul 11 15:17:00 +0000 2000
>Closed-Date:
>Last-Modified:
>Originator: Takahiro Kambe
>Release: NetBSD 1.5_ALPHA (2000/7/9)
>Organization:
>Environment:
System: NetBSD edge.sky.yamashina.kyoto.jp 1.5_ALPHA NetBSD 1.5_ALPHA (CF-M33) #42: Sun Jul 9 01:03:24 JST 2000 root@edge.sky.yamashina.kyoto.jp:/usr/src/sys/arch/i386/compile/CF-M33 i386
>Description:
Restore(8) with -u option removes file before extraction, but dosen't
care much for creating hard link. Restore(8) with -u option should
be unlink a destination file (except it is a directory) before create
a hard link.
>How-To-Repeat:
Try restore(8) with -u option twice on the same directory,
it dosen't preserve hard links.
>Fix:
Sample fix, not tested much.
--- utilities.c.orig Mon Mar 20 23:37:04 2000
+++ utilities.c Wed Jul 12 00:13:31 2000
@@ -213,24 +213,35 @@
char *existing, *new;
int type;
{
+ struct stat st;
- if (type == SYMLINK) {
- if (!Nflag && symlink(existing, new) < 0) {
+ if (type != SYMLINK && HARDLINK) {
+ panic("linkit: unknown type %d\n", type);
+ return (FAIL);
+ }
+
+ if (!Nflag) {
+ if (uflag && lstat(new, &st) == 0 &&
+ (st.st_mode & S_IFMT) != S_IFDIR) {
+ if (unlink(new) < 0) {
+ fprintf(stderr,
+ "warning: cannot unlink %s: %s\n",
+ new, strerror(errno));
+ return (FAIL);
+ }
+ }
+
+ if (type == SYMLINK && symlink(existing, new) < 0) {
fprintf(stderr,
- "warning: cannot create symbolic link %s->%s: %s\n",
- new, existing, strerror(errno));
+ "warning: cannot create symbolic link %s->%s: %s\n",
+ new, existing, strerror(errno));
return (FAIL);
- }
- } else if (type == HARDLINK) {
- if (!Nflag && link(existing, new) < 0) {
+ } else if (type == HARDLINK && link(existing, new) < 0) {
fprintf(stderr,
- "warning: cannot create hard link %s->%s: %s\n",
- new, existing, strerror(errno));
+ "warning: cannot create hard link %s->%s: %s\n",
+ new, existing, strerror(errno));
return (FAIL);
}
- } else {
- panic("linkit: unknown type %d\n", type);
- return (FAIL);
}
vprintf(stdout, "Create %s link %s->%s\n",
type == SYMLINK ? "symbolic" : "hard", new, existing);
>Release-Note:
>Audit-Trail:
>Unformatted:
(Contact us)
$NetBSD: query-full-pr,v 1.39 2013/11/01 18:47:49 spz Exp $
$NetBSD: gnats_config.sh,v 1.8 2006/05/07 09:23:38 tsutsui Exp $
Copyright © 1994-2007
The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.