From jin@eubie.lbl.gov  Fri Apr  7 10:54:27 2000
Return-Path: <jin@eubie.lbl.gov>
Received: from eubie.lbl.gov (eubie.lbl.gov [131.243.2.36])
	by hub.freebsd.org (Postfix) with ESMTP id 2C29437BD47
	for <FreeBSD-gnats-submit@freebsd.org>; Fri,  7 Apr 2000 10:54:27 -0700 (PDT)
	(envelope-from jin@eubie.lbl.gov)
Received: (from jin@localhost)
	by eubie.lbl.gov (8.9.3/8.9.3) id KAA00590;
	Fri, 7 Apr 2000 10:54:26 -0700 (PDT)
	(envelope-from jin)
Message-Id: <200004071754.KAA00590@eubie.lbl.gov>
Date: Fri, 7 Apr 2000 10:54:26 -0700 (PDT)
From: Jin Guojun (FTG staff) <jin@eubie.lbl.gov>
Reply-To: j_guojun@lbl.gov
To: FreeBSD-gnats-submit@freebsd.org
Subject: mv symbolic link cross partition fails
X-Send-Pr-Version: 3.2

>Number:         17847
>Category:       bin
>Synopsis:       mv symbolic link cross partition fails
>Confidential:   no
>Severity:       serious
>Priority:       high
>Responsible:    dwmalone
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Fri Apr  7 11:00:01 PDT 2000
>Closed-Date:    Fri Jul 14 12:26:23 PDT 2000
>Last-Modified:  Fri Jul 14 12:27:19 PDT 2000
>Originator:     Jin Guojun (FTG staff)
>Release:        FreeBSD ALL-RELEASE i386
>Organization:
>Environment:

	At least since FreeBSD 3.x-RELEASE

>Description:

	This is supposed to be for "mv slink another_partition"

[125] solaris: cd /tmp;	ln -s x y
[126] solaris: ll
lrwxrwxrwx   1 jin             1 Apr  7 10:32 y -> x
[127] solaris: mv y ~
[128] solaris: ll ~/y
lrwxrwxrwx   1 jin             1 Apr  7 10:32 /home/users/jin/y -> x

	This is what happened on FreeBSD mv:

[111] FreeBSD: cd /tmp
[112] FreeBSD: mkdir test
[113] FreeBSD: ln -s x y
[114] FreeBSD: mv y test
[115] FreeBSD: ll test
total 2
drwxr-xr-x  2 jin   wheel  512 Apr  7 10:34 ./
drwxrwxrwt  4 root  wheel  512 Apr  7 10:34 ../
lrwxr-xr-x  1 jin   wheel    1 Apr  7 10:34 y@ -> x	# ok for local mv

[116] FreeBSD: cd test
[117] FreeBSD: mv y ~
mv: y: No such file or directory			# failed HERE
[118] FreeBSD: echo abc > x
[119] FreeBSD: ll
total 3
drwxr-xr-x  2 jin   wheel  512 Apr  7 10:48 ./
drwxrwxrwt  4 root  wheel  512 Apr  7 10:34 ../
-rw-r--r--  1 jin   wheel    4 Apr  7 10:48 x
lrwxr-xr-x  1 jin   wheel    1 Apr  7 10:34 y@ -> x
[120] FreeBSD: mv y ~			# incorrect for crossing partition
[121] FreeBSD: ll ~/y
-rw-r--r--  1 jin  wheel  4 Apr  7 10:48 /home/users/jin/y
[122] FreeBSD: cat ~/y
abc
[123] FreeBSD: ll
total 3
drwxr-xr-x  2 jin   wheel  512 Apr  7 10:49 ./
drwxrwxrwt  4 root  wheel  512 Apr  7 10:34 ../
-rw-r--r--  1 jin   wheel    4 Apr  7 10:48 x


>How-To-Repeat:

	Just repeat above operatoins within the same/different partitions.

>Fix:

	If every one agree this incorrect, I can trace down the code to
	find a patch.


>Release-Note:
>Audit-Trail:

From: David Malone <dwmalone@maths.tcd.ie>
To: j_guojun@lbl.gov
Cc: FreeBSD-gnats-submit@freebsd.org
Subject: Re: bin/17847: mv symbolic link cross partition fails 
Date: Fri, 07 Apr 2000 20:28:07 +0100

 > 	If every one agree this incorrect, I can trace down the code to
 > 	find a patch.
 
 This sounds like a bug, as it doesn't do the same thing as mving
 a symlink on a local partition would. If the file the symlink points
 to is a regular file you'll end up getting a copy of that instead
 of the symlink.
 
 Digital Unix and Linux also do the same "correct" thing as solaris.
 
 It looks like mv has a stat, which should be an lstat. The included
 patch seems to fix it.
 
 BTW - for some strange reason your PR seems to be marked as
 confidential on the web site.
 
 	David.
 
 --- mv.c	Fri Apr  7 20:19:19 2000
 +++ mv.c.orig	Fri Apr  7 20:19:45 2000
 @@ -221,7 +221,7 @@
  	 * it's a regular file, do the copy internally; otherwise, use
  	 * cp and rm.
  	 */
 -	if (lstat(from, &sb)) {
 +	if (stat(from, &sb)) {
  		warn("%s", from);
  		return (1);
  	}
 

From: Jin Guojun (FTG staff) <jin@george.lbl.gov>
To: dwmalone@maths.tcd.ie
Cc: FreeBSD-gnats-submit@freebsd.org
Subject: Re: bin/17847: mv symbolic link cross partition fails
Date: Fri, 7 Apr 2000 13:43:02 -0700 (PDT)

 Yes, following patch fixed the problem.
 Shall we apply the patch and close the case?
 
 Thanks,
 
 	-Jin
 
 --------- original message ------
 >       If every one agree this incorrect, I can trace down the code to
 >       find a patch.
 
 This sounds like a bug, as it doesn't do the same thing as mving
 a symlink on a local partition would. If the file the symlink points
 to is a regular file you'll end up getting a copy of that instead
 of the symlink.
 
 Digital Unix and Linux also do the same "correct" thing as solaris.
 
 It looks like mv has a stat, which should be an lstat. The included
 patch seems to fix it.
 
 BTW - for some strange reason your PR seems to be marked as
 confidential on the web site.
 
         David.
 
 --- mv.c	Fri Apr  7 20:19:19 2000
 +++ mv.c.orig	Fri Apr  7 20:19:45 2000
 @@ -221,7 +221,7 @@
  	 * it's a regular file, do the copy internally; otherwise, use
  	 * cp and rm.
  	 */
 -	if (lstat(from, &sb)) {
 +	if (stat(from, &sb)) {
  		warn("%s", from);
  		return (1);
  	}
 
 
Responsible-Changed-From-To: freebsd-bugs->dwmalone 
Responsible-Changed-By: dwmalone 
Responsible-Changed-When: Tue Jul 11 04:44:31 PDT 2000 
Responsible-Changed-Why:  
I'm interested in this one. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=17847 
State-Changed-From-To: open->closed 
State-Changed-By: dwmalone 
State-Changed-When: Fri Jul 14 12:26:23 PDT 2000 
State-Changed-Why:  
Fix has been committed in RELENG_{3,4} and HEAD. 

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