Subject: kern/1644: msdosfs panics (locking against myself) with mv foo.xxx foo.xxx.~1~
To: None <gnats-bugs@gnats.netbsd.org>
From: John Kohl <jtk@kolvir.arlington.ma.us>
List: netbsd-bugs
Date: 10/17/1995 23:56:23
>Number:         1644
>Category:       kern
>Synopsis:       msdosfs panics (locking against myself) with mv foo.xxx foo.xxx.~1~
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    kern-bug-people (Kernel Bug People)
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Wed Oct 18 07:20:32 1995
>Last-Modified:
>Originator:     John Kohl
>Organization:
NetBSD Kernel Hackers `R` Us
>Release:        NetBSD-current, roughly 1995/09/22
>Environment:
	
System: NetBSD pattern 1.0A NetBSD 1.0A (PATTERN) #128: Mon Sep 25 23:09:21 EDT 1995 jtk@pattern:/u1/NetBSD-current/src/sys/arch/i386/compile/PATTERN i386


>Description:
in msdosfs, this will panic a system with DIAGNOSTIC or hang a process
without DIAGNOSTIC:
	% mv foo.xxx foo.xxx.~1~
>How-To-Repeat:
do that
>Fix:
===================================================================
RCS file: RCS/msdosfs_vnops.c,v
retrieving revision 1.1
diff -c -r1.1 msdosfs_vnops.c
*** msdosfs_vnops.c	1995/09/26 02:42:21	1.1
--- msdosfs_vnops.c	1995/09/26 03:08:47
***************
*** 876,882 ****
  		vrele(fvp);
  		return (error);
  	}
! 
  	/*
  	 * Convert the filename in tcnp into a dos filename. We copy this
  	 * into the denode and directory entry for the destination
--- 876,903 ----
  		vrele(fvp);
  		return (error);
  	}
! 	/*
! 	 * Check for rename onto itself.  e.g. rename("foo.emu", "foo.emu.~1~")
! 	 * which appears to the vnode layer as just like renaming one
! 	 * hardlinked file onto the other.  It happens here due to name
! 	 * mapping.
! 	 * (Can it happen due to hard links in a corrupted file system?
! 	 * should we worry about that?)
! 	 */
! 	if (fvp == tvp) {
! 	    /*
! 	     * the "to" name is valid, but so is the "from" name.
! 	     * what should we return as an error code?
! 	     * 0 is not quite right--the source still exists and the user
! 	     * may have uttered different file names.  However, it's probably
! 	     * the closest to correct.
! 	     * 
! 	     * maybe EMLINK?
! 	     */
! 	    error = 0 /*EMLINK*/;
! 	    goto abortit;
! 	}
! 	    
  	/*
  	 * Convert the filename in tcnp into a dos filename. We copy this
  	 * into the denode and directory entry for the destination


>Audit-Trail:
>Unformatted: