Subject: kern/4395: Bug in vfat generation number creation for msdosfs
To: None <netbsd-bugs@NetBSD.ORG>
From: Rick Byers <rickb@iaw.on.ca>
List: netbsd-bugs
Date: 11/14/1997 20:52:58
>Number:         4395
>Category:       kern
>Synopsis:       Short filename is wrong for generations > 9
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    kern-bug-people (Kernel Bug People)
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Fri Oct 31 10:20:08 1997
>Originator:     Rick Byers
>Organization:
=========================================================================
Rick Byers                                      Internet Access Worldwide
rickb@iaw.on.ca                                              System Admin
University of Waterloo, Computer Science                    (905)714-1400
http://www.iaw.on.ca/rickb/                         http://www.iaw.on.ca/


>Release:        October 25, 1997
>Environment:


System: NetBSD rickb 1.3_ALPHA NetBSD 1.3_ALPHA (RICKB) #16: Thu Oct 30 00:17:5
8 EST 1997 root@rickb:/usr/src/sys/arch/i386/compile/RICKB i386




>Description:
        When a file is created who's short name allready exists (but has
        a uniqe long filename), The short name is supposed to have it's
        generation number increased by 1 (i.e. ~2).  This works fine under
        NetBSD until generation 10 is reached.  Any generation above
        9 doesn't get created properly.  Instead of FILEN~10, NetBSD sets
        it to FILEN~0E.  When more than 60 files exist with the same short
        name, the kernel gets caught because it cannot create an unique
        short file name.
>How-To-Repeat:
        mount -t msdos -o -l /dev/wd0e /msdos
        for x in 1 2 3 4 5 6 7 8 9 10; do
                touch /msdos/"NetBSD long filename number $x"
        done
        umount /msdos
        mount -t msdos -o -l /dev/wd0e /msdos
        ls:


total 640
-rwxr-x---  1 root  msdos  0 Oct 29 16:42 netbsd~1
-rwxr-x---  1 root  msdos  0 Oct 29 16:42 netbsd~2
-rwxr-x---  1 root  msdos  0 Oct 29 16:42 netbsd~3
-rwxr-x---  1 root  msdos  0 Oct 29 16:42 netbsd~4
-rwxr-x---  1 root  msdos  0 Oct 29 16:42 netbsd~5
-rwxr-x---  1 root  msdos  0 Oct 29 16:42 netbsd~6
-rwxr-x---  1 root  msdos  0 Oct 29 16:42 netbsd~7
-rwxr-x---  1 root  msdos  0 Oct 29 16:42 netbsd~8
-rwxr-x---  1 root  msdos  0 Oct 29 16:43 netbsd~9
-rwxr-x---  1 root  msdos  0 Oct 29 16:43 netbs~0r


The last filename should be "netbsd~10".


>Fix:
Very simple patch.  Please note that fixing this problem may make other
bugs more likely to surface.  I will send-pr the other bugs I'm working on
as soon as I have a fix.

Index: msdosfs_conv.c
===================================================================
RCS file: /usr/cvsroot/netbsd/src/sys/msdosfs/msdosfs_conv.c,v
retrieving revision 1.1.1.2
retrieving revision 1.2
diff -c -r1.1.1.2 -r1.2
*** msdosfs_conv.c	1997/10/23 03:06:40	1.1.1.2
--- msdosfs_conv.c	1997/10/30 06:30:38	1.2
***************
*** 553,559 ****
  		i = 8 - (gentext + sizeof(gentext) - wcp + 1);
  	dn[i++] = '~';
  	while (wcp < gentext + sizeof(gentext))
! 		dn[i] = *wcp++;
  	return 3;
  }
  
--- 553,559 ----
  		i = 8 - (gentext + sizeof(gentext) - wcp + 1);
  	dn[i++] = '~';
  	while (wcp < gentext + sizeof(gentext))
! 		dn[i++] = *wcp++;
  	return 3;
  }
  


>Audit-Trail:
>Unformatted:


>Last-Modified:


=========================================================================
Rick Byers                                      Internet Access Worldwide
rickb@iaw.on.ca                                		     System Admin
University of Waterloo, Computer Science                    (905)714-1400
http://www.iaw.on.ca/rickb/                         http://www.iaw.on.ca/