From fanf@demon.net Wed Oct  6 14:56:37 1999
Return-Path: <fanf@demon.net>
Received: from internal.mail.demon.net (internal.mail.demon.net [193.195.224.3])
	by hub.freebsd.org (Postfix) with ESMTP id 51091152B5
	for <FreeBSD-gnats-submit@freebsd.org>; Wed,  6 Oct 1999 14:56:26 -0700 (PDT)
	(envelope-from fanf@demon.net)
Received: from fanf.eng.demon.net (fanf.eng.demon.net [195.11.55.89])
	by internal.mail.demon.net with ESMTP id WAA06083;
	Wed, 6 Oct 1999 22:55:19 +0100 (BST)
Received: from fanf by fanf.eng.demon.net with local (Exim 3.03 #2)
	id 11Yz1M-000MdD-00
	for FreeBSD-gnats-submit@freebsd.org; Wed, 06 Oct 1999 22:54:48 +0100
Message-Id: <E11Yz1M-000MdD-00@fanf.eng.demon.net>
Date: Wed, 06 Oct 1999 22:54:48 +0100
From: Tony Finch <fanf@demon.net>
Reply-To: fanf@demon.net
To: FreeBSD-gnats-submit@freebsd.org
Subject: [PATCH] create symbolic links using mtree
X-Send-Pr-Version: 3.2

>Number:         14171
>Category:       bin
>Synopsis:       [PATCH] create symbolic links using mtree
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    joe
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Wed Oct  6 15:00:01 PDT 1999
>Closed-Date:    Thu Jul 13 15:28:53 PDT 2000
>Last-Modified:  Thu Jul 13 15:31:46 PDT 2000
>Originator:     Tony Finch
>Release:        FreeBSD 3.3-STABLE-19990927 i386
>Organization:
Demon Internet Ltd
>Environment:


>Description:

It would be useful to be able to create hierarchies containing
symbolic links using mtree, so I implemented this patch.

>How-To-Repeat:


>Fix:
	
--- /usr/src/usr.sbin/mtree/verify.c	Wed Sep  1 17:24:19 1999
+++ /usr/src/usr.sbin/mtree/verify.c	Wed Oct  6 22:45:47 1999
@@ -160,6 +160,7 @@
 {
 	register int create;
 	register char *tp;
+	const char *type;
 
 	for (; p; p = p->next) {
 		if (p->type != F_DIR && (dflag || p->flags & F_VISIT))
@@ -167,18 +168,32 @@
 		(void)strcpy(tail, p->name);
 		if (!(p->flags & F_VISIT))
 			(void)printf("missing: %s", path);
-		if (p->type != F_DIR) {
+		if (p->type != F_DIR && p->type != F_LINK) {
 			putchar('\n');
 			continue;
 		}
 
 		create = 0;
+		if (p->type == F_LINK)
+		    type = "symlink";
+		else
+		    type = "directory";
 		if (!(p->flags & F_VISIT) && uflag)
 			if (!(p->flags & (F_UID | F_UNAME)))
-			    (void)printf(" (directory not created: user not specified)");
+			    (void)printf(" (%s not created: user not specified)", type);
 			else if (!(p->flags & (F_GID | F_GNAME)))
-			    (void)printf(" (directory not created: group not specified)");
-			else if (!(p->flags & F_MODE))
+			    (void)printf(" (%s not created: group not specified)", type);
+			else if (p->type == F_LINK) {
+				if (symlink(p->slink, path))
+					(void)printf(" (symlink not created: %s)\n",
+					    strerror(errno));
+				else
+					(void)printf(" (created)\n");
+				if (lchown(path, p->st_uid, p->st_gid))
+					(void)printf("%s: user/group not modified: %s\n",
+					    path, strerror(errno));
+				continue;
+			} else if (!(p->flags & F_MODE))
 			    (void)printf(" (directory not created: mode not specified)");
 			else if (mkdir(path, S_IRWXU))
 				(void)printf(" (directory not created: %s)",

>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-bugs->joe 
Responsible-Changed-By: joe 
Responsible-Changed-When: Thu Nov 25 08:46:15 PST 1999 
Responsible-Changed-Why:  
I'm working on mtree at the moment, so I'll take responsibility 
for this patch. 
State-Changed-From-To: open->closed 
State-Changed-By: joe 
State-Changed-When: Thu Jul 13 15:28:53 PDT 2000 
State-Changed-Why:  
Committed.  I also committed an additional fix to allow mtree to 
examine the symlink itself instead of what it pointed to. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=14171 
>Unformatted:
