Newsgroups: comp.sources.bugs
Subject: Mtools Patch1,  (Priority High)

	Patch1 fixes fixes alignment dependency problems in
msdos.h that made the code fail on the 3/80.  Somehow this worked
on the SparcStation,  I hang my head in shame.  Also minor change in
mkdfs.c allowing custom disk labels,  and defaulting to blank.

*** /tmp/,RCSt1a17064	Mon Mar 26 17:32:44 1990
--- mkdfs.c	Mon Mar 26 17:32:43 1990
***************
*** 27,33 ****
  #define FAT720 0xf9
  #define FAT1440 0xf0
  static char floppy[] = "/dev/rfd0c" ;
! static char disklabel[] = "ANYDSKLABEL" ;
  
  void move(), Write(), usage(), formatit() ;
  
--- 27,33 ----
  #define FAT720 0xf9
  #define FAT1440 0xf0
  static char floppy[] = "/dev/rfd0c" ;
! char disklabel[12] = "" ;
  
  void move(), Write(), usage(), formatit() ;
  
***************
*** 41,50 ****
    int fat = FAT720 ;
    int dir_len = 7 ;
    int hdflag=0, fflag = 0 ;
  
    progname = argv[0] ;
  
!   while( (c=getopt(argc,argv,"hf")) != EOF ) {
      switch(c) {
      case 'f' :
        fflag++ ;
--- 41,51 ----
    int fat = FAT720 ;
    int dir_len = 7 ;
    int hdflag=0, fflag = 0 ;
+   extern char *optarg;
  
    progname = argv[0] ;
  
!   while( (c=getopt(argc,argv,"hfl:")) != EOF ) {
      switch(c) {
      case 'f' :
        fflag++ ;
***************
*** 51,56 ****
--- 52,60 ----
        break;
      case 'h' :
        hdflag++ ;
+       break;
+     case 'l' :
+       strncpy(disklabel, optarg, 11) ;
        break;
      case '?':
      default:
*** /tmp/,RCSt1a17064	Mon Mar 26 17:32:45 1990
--- msdos.h	Mon Mar 26 17:18:43 1990
***************
*** 18,42 ****
  	unsigned char	size[4];	/* size of the file */
  };
  
- struct dos_word {
-   unsigned char dw_low ;		/* LSB */
-   unsigned char dw_high ;		/* MSB */
- } ;
- 
  struct superblock {
    unsigned char jump[3] ;       /* Jump to boot code */
!   unsigned char banner[8];      /* OEM name & version */
!   struct dos_word secsiz;       /* Bytes per sector hopefully 512 */
    unsigned char clsiz ;         /* Cluster size in sectors */
!   struct dos_word nrsvsect;     /* Number of reserved (boot) sectors */
    unsigned char nfat;           /* Number of FAT tables hopefully 2 */
!   struct dos_word dirents;      /* Number of directory slots */
!   struct dos_word psect;        /* Total sectors on disk */
    unsigned char descr;          /* Media descriptor=first byte of FAT */
!   struct dos_word fatlen;       /* Sectors in FAT */
!   struct dos_word nsect;        /* Sectors/track */
!   struct dos_word ntrack;       /* tracks/cyl */
!   struct dos_word nhs;          /* number of hidden sectors ? */
  } ;
  
  union bootblock {
--- 18,37 ----
  	unsigned char	size[4];	/* size of the file */
  };
  
  struct superblock {
    unsigned char jump[3] ;       /* Jump to boot code */
!   unsigned char banner[8];	/* OEM name & version */
!   unsigned char secsiz[2];	/* Bytes per sector hopefully 512 */
    unsigned char clsiz ;         /* Cluster size in sectors */
!   unsigned char nrsvsect[2];	/* Number of reserved (boot) sectors */
    unsigned char nfat;           /* Number of FAT tables hopefully 2 */
!   unsigned char dirents[2];	/* Number of directory slots */
!   unsigned char psect[2];	/* Total sectors on disk */
    unsigned char descr;          /* Media descriptor=first byte of FAT */
!   unsigned char fatlen[2];	/* Sectors in FAT */
!   unsigned char nsect[2];	/* Sectors/track */
!   unsigned char ntrack[2];	/* tracks/cyl */
!   unsigned char nhs[2];		/* number of hidden sectors ? */
  } ;
  
  union bootblock {
***************
*** 44,50 ****
    struct superblock sb ;
  } ;
  
! #define WORD_VAL(x) (x.dw_low + (x.dw_high <<8))
  
  #define SECSIZ(x)	WORD_VAL(x.secsiz)
  #define CLSIZ(x)	(x.clsiz)
--- 39,45 ----
    struct superblock sb ;
  } ;
  
! #define WORD_VAL(x) ((x)[0] + ((x)[1] << 8))
  
  #define SECSIZ(x)	WORD_VAL(x.secsiz)
  #define CLSIZ(x)	(x.clsiz)
*** /tmp/,RCSt1a17064	Mon Mar 26 17:32:45 1990
--- Mkdfs.1	Mon Mar 26 17:32:44 1990
***************
*** 9,14 ****
--- 9,18 ----
  [
  .B -f
  ]
+ [
+ .B -l
+ .I label
+ ]
  .SH DESCRIPTION
  .I Mkdfs
  Mkdfs formats and initializes a DOS file system on a 3.5 inch Sun 4/60 or
***************
*** 25,31 ****
  .TP
  .B f
  First reformat the drive,  useful for new or abused drives.  (Using the drive
! in a Mac counts in the last category)
  .SH SEE ALSO
  mdir(1), mread(1), mtype(1), mren(1), mkd(1), mrd(1), mdel(1), mcopy(1)
  .SH AUTHOR
--- 29,38 ----
  .TP
  .B f
  First reformat the drive,  useful for new or abused drives.  (Using the drive
! in a Mac counts in the last category).
! .TP
! .B l \fIlabel\fR
! Use \fIlabel\fR as the disk volume label (up to 11 characters).
  .SH SEE ALSO
  mdir(1), mread(1), mtype(1), mren(1), mkd(1), mrd(1), mdel(1), mcopy(1)
  .SH AUTHOR
