🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.sources.bugs
Article #333

Patch #7 to Mtools v2.0

#333
From: Emmet P. Gray
Date: Sun, 06 Sep 1992 18:03
211 lines
6184 bytes
This is patch #7 to the Mtools v2.0 distribution package.  This patch
will change the method of determining if the FAT encoding scheme in the
devices.c file is correct.  The method introduced by patch #6 was naive
and easily fooled.

A pre-processor variable called CHK_FAT has been added to the fat_read.c
file just in case this new method isn't appropriate for all disks.

Mtools v2.0.5 was posted to the comp.sources.unix news group the 2nd
week of January 92 as v25i097 thru v25i099.  Patch #6 was posted to
comp.sources.bugs on 21 Aug.

Emmet P. Gray				US Army, HQ III Corps & Fort Hood
...!uunet!uiucuxc!fthood!egray		Attn: AFZF-DE-ENV
fthood!egray@uxc.cso.uiuc.edu		Directorate of Engineering & Housing
					Environmental Management Office
					Fort Hood, TX 76544-5057

-----------------------------------------------------------------------------
Prereq: "2.0.6"
*** old/patchlevel.h	Sat Aug 22 21:54:38 1992
--- patchlevel.h	Sun Sep  6 10:49:30 1992
***************
*** 1,19 ****
! #define VERSION	"2.0.6"
! #define DATE	"21 Aug 92"
! 
! /*
!  * Version 1.0		13 Oct 86
!  * Version 1.1		11 Jan 87
!  * Version 1.2		11 Jun 87
!  * Version 1.3		15 Jun 88
!  * Version 1.4		28 Sep 88
!  * Version 1.5		 9 Oct 88
!  * Version 1.6		 3 May 89
!  * Version 2.0		 8 Sep 90
!  *  patch #1		12 Oct 90
!  *  patch #2		21 Nov 90
!  *  patch #3		28 Nov 90
!  *  patch #4		11 Apr 91
!  *  patch #5		25 Aug 91
!  *  patch #6		21 Aug 92
!  */
--- 1,2 ----
! #define VERSION	"2.0.7"
! #define DATE	"6 Sep 92"
*** old/Configure	Sat Aug 22 21:54:35 1992
--- Configure	Sun Sep  6 10:52:40 1992
***************
*** 63,66 ****
--- 63,69 ----
  	configured to the "base" return type of signal();
  
+ 	The fat_read.c file has a preprocessor variable "CHK_FAT" that
+ 	can be undefined to turn off the fat encoding check if needed.
+ 
  3) The devices "database" in devices.c
  
*** old/Mtools.1	Sat Aug 22 21:54:37 1992
--- Mtools.1	Mon Aug 31 18:36:44 1992
***************
*** 35,38 ****
--- 35,59 ----
  pattern matching.
  .PP
+ Not all Unix filenames are appropriate in the MSDOS world.  The Mtools
+ commands may have to alter Unix names to fit the MSDOS filename
+ restrictions.  Most commands have a -v (verbose) option that will
+ display the new names if they have been changed.  The following table
+ shows some examples of filename conversions:
+ .PP
+ .in +0.5i
+ .(b L
+ .TS
+ l l l.
+ Unix name	MSDOS name	Reason for the change
+ _	_	_
+ thisisatest	THISISAT	filename too long
+ emmet.gray	EMMET.GRA	extension too long
+ prn.txt	XRN.TXT	PRN is a device name
+ \.abc	X.ABC	null filename
+ hot+cold	HOTXCOLD	illegal character
+ .TE
+ .)b
+ .in
+ .PP
  All options use the '-' (minus) flag, not '/' as you'd expect in MSDOS.
  .PP
*** old/Release.notes	Sat Aug 22 21:54:37 1992
--- Release.notes	Sun Sep  6 10:50:03 1992
***************
*** 1,2 ****
--- 1,12 ----
+ Patch #7, 6 Sep 92
+ 
+ This patch will change the method of determining if the FAT encoding
+ scheme in the devices.c file is correct.  The method introduced by patch
+ #6 was naive and easily fooled.
+ 
+ A pre-processor variable called CHK_FAT has been added to the fat_read.c
+ file just in case this new method isn't appropriate for all disks.
+ 
+ -----------------------------------------------------------------------------
  Patch #6, 21 Aug 92
  
*** old/devices.c	Sat Aug 22 21:54:37 1992
--- devices.c	Fri Aug 28 08:32:18 1992
***************
*** 63,67 ****
  	}
  
! 	gdbuf.params.cyls = ntracks * nheads;
  	gdbuf.params.heads = nheads;
  	gdbuf.params.psectrk = nsect;
--- 63,67 ----
  	}
  
! 	gdbuf.params.cyls = ntracks;
  	gdbuf.params.heads = nheads;
  	gdbuf.params.psectrk = nsect;
***************
*** 133,138 ****
  	}
  
! 	if (ntracks && nheads)
! 		dkbuf.ncyl = ntracks * nheads;
  	if (nheads)
  		dkbuf.nhead = nheads;
--- 133,138 ----
  	}
  
! 	if (ntracks)
! 		dkbuf.ncyl = ntracks;
  	if (nheads)
  		dkbuf.nhead = nheads;
*** old/fat_read.c	Sat Aug 22 21:54:37 1992
--- fat_read.c	Mon Aug 31 18:02:37 1992
***************
*** 2,5 ****
--- 2,7 ----
  #include "msdos.h"
  
+ #define CHK_FAT
+ 
  int fat_len;				/* length of FAT table (in sectors) */
  unsigned int end_fat;			/* the end-of-chain marker */
***************
*** 8,11 ****
--- 10,14 ----
  
  extern int fat_bits;
+ extern unsigned num_clus;
  
  /*
***************
*** 77,81 ****
  int start;
  {
! 	int i;
  	unsigned int buflen;
  	char *malloc();
--- 80,84 ----
  int start;
  {
! 	int i, fat_size;
  	unsigned int buflen;
  	char *malloc();
***************
*** 91,94 ****
--- 94,110 ----
  	}
  #endif /* INT16 */
+ 
+ 	/*
+ 	 * Let's see if the length of the FAT table is appropriate for
+ 	 * the number of clusters and the encoding scheme
+ 	 */
+ #ifdef CHK_FAT
+ 	fat_size = (fat_bits == 12) ? (num_clus +2) * 3 / 2 : (num_clus +2) * 2;
+ 	fat_size = (fat_size / 512) + ((fat_size % 512) ? 1 : 0);
+ 	if (fat_size != fat_len) {
+ 		fprintf(stderr, "fat_read: Wrong FAT encoding?\n");
+ 		exit(1);
+ 	}
+ #endif /* CHK_FAT */
  					/* only the first copy of the FAT */
  	buflen = fat_len * MSECTOR_SIZE;
***************
*** 106,113 ****
  		end_fat = 0xfff;
  		last_fat = 0xff8;
- 		if (fat_buf[3] == 0xff) {
- 			fprintf(stderr, "fat_read: wrong FAT encoding\n");
- 			exit(1);
- 		}
  	}
  	else {
--- 122,125 ----
***************
*** 114,121 ****
  		end_fat = 0xffff;
  		last_fat = 0xfff8;
- 		if (fat_buf[3] != 0xff) {
- 			fprintf(stderr, "fat_read: wrong FAT encoding\n");
- 			exit(1);
- 		}
  	}
  	return;
--- 126,129 ----
End of Patch
Technical Details
Message-ID: <Bu64t9.Iqs@news.cso.uiuc.edu>
Path: arc1-ca.pugleaf.net!sparky!uunet!zaphod.mps.ohio-state.edu!sdd.hp.com!ux1.cso.uiuc.edu!news.cso.uiuc.edu!osiris.cso.uiuc.edu!egray

Show Full Headers
Complete Article Headers
Newsgroups: comp.sources.bugs
Path: arc1-ca.pugleaf.net!sparky!uunet!zaphod.mps.ohio-state.edu!sdd.hp.com!ux1.cso.uiuc.edu!news.cso.uiuc.edu!osiris.cso.uiuc.edu!egray
From: egray@osiris.cso.uiuc.edu (Emmet P. Gray)
Subject: Patch #7 to Mtools v2.0
Message-ID: <Bu64t9.Iqs@news.cso.uiuc.edu>
Sender: usenet@news.cso.uiuc.edu (Net Noise owner)
Organization: US Army Corps of Engineers - Construction Eng Research Lab
Date: Sun, 6 Sep 1992 18:03:08 GMT
Lines: 211