Subject: port-amiga/2232: ADOSFS improvements
To: None <gnats-bugs@NetBSD.ORG>
From: Matthias Scheler <tron@colwyn.owl.de>
List: netbsd-bugs
Date: 03/17/1996 19:21:53
>Number:         2232
>Category:       port-amiga
>Synopsis:       ADOSFS improvements
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    gnats-admin (GNATS administrator)
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sun Mar 17 14:20:03 1996
>Last-Modified:
>Originator:     Matthias Scheler
>Organization:
Matthias Scheler
tron@colwyn.owl.de
>Release:        960213
>Environment:
NetBSD lyssa 1.1A NetBSD 1.1A (LYSSA) #33: Sun Mar 17 18:59:19 GMT+0100 1996     tron@lyssa:/usr/src/sys/arch/amiga/compile/LYSSA amiga

>Description:
NetBSD 1.1(a)'s ADOSFS has lots of flaws:
1.) It doesn't support OFS.
2.) It doesn't support international FS or DC-FS.
3.) And even worse: it doesn't check what kind of filesystem it is dealing
    with, the bootblock is not even read. It blindly assumes that it gets a
    DOS\1 filesystem.
4.) The support for block sizes >512 byte is not complete and the RDB reading
    code doesn't pass the propper informations to the ADOSFS.
5.) The calculation of the location of the root block is broken for floppies
    so that you can't mount AmigaDOS floppy disks.

>How-To-Repeat:
Varios possibilities e.g. trying mounting a floppy disk or a harddisk
partition with blocksize >512 byte.

>Fix:

Here it is:

*** src/sys/adosfs/advfsops.c.orig	Sat Feb 10 13:26:39 1996
--- src/sys/adosfs/advfsops.c	Sun Mar 17 18:12:17 1996
***************
*** 2,7 ****
--- 2,8 ----
  
  /*
   * Copyright (c) 1994 Christian E. Hopps
+  * Copyright (c) 1996 Matthias Scheler
   * All rights reserved.
   *
   * Redistribution and use in source and binary forms, with or without
*************** adosfs_mountfs(devvp, mp, p)
*** 154,159 ****
--- 155,161 ----
  	struct disklabel dl;
  	struct partition *parp;
  	struct adosfsmount *amp;
+ 	struct buf *bp;
  	struct vnode *rvp;
  	int error, part, i;
  
*************** adosfs_mountfs(devvp, mp, p)
*** 186,198 ****
  	amp = malloc(sizeof(struct adosfsmount), M_ADOSFSMNT, M_WAITOK);
  	bzero((char *)amp, (u_long)sizeof(struct adosfsmount));
  	amp->mp = mp;
! 	amp->startb = parp->p_offset;
! 	amp->endb = parp->p_offset + parp->p_size;
! 	amp->bsize = dl.d_secsize;
  	amp->nwords = amp->bsize >> 2;
  	amp->devvp = devvp;
- /*	amp->rootb = (parp->p_size - 1 + 2) >> 1;*/
- 	amp->rootb = (parp->p_size - 1 + parp->p_cpg) >> 1;
  	
  	mp->mnt_data = (qaddr_t)amp;
          mp->mnt_stat.f_fsid.val[0] = (long)devvp->v_rdev;
--- 188,221 ----
  	amp = malloc(sizeof(struct adosfsmount), M_ADOSFSMNT, M_WAITOK);
  	bzero((char *)amp, (u_long)sizeof(struct adosfsmount));
  	amp->mp = mp;
! 	if (dl.d_type == DTYPE_FLOPPY) {
! 		amp->bsize = dl.d_secsize;
! 		amp->secsperblk = 1;
! 		amp->rootb = (parp->p_size + 1) >> 1;
! 	}
! 	else {
! 		amp->bsize = parp->p_fsize * parp->p_frag;
! 		amp->secsperblk = parp->p_frag;
! 		amp->rootb = (parp->p_size / parp->p_frag - 1 + parp->p_cpg)
! 			     >> 1;
! 	}
! 
! 	bp = NULL;
! 	if ((error = bread(devvp, (daddr_t)BBOFF,
! 			   amp->bsize, NOCRED, &bp)) != 0)
! 		goto fail;
! 
! 	amp->dostype = adoswordn(bp, 0);
! 	brelse(bp);
! 
! 	if (amp->dostype < 0x444f5300 || amp->dostype > 0x444f5305) {
! 		error = EINVAL;
! 		goto fail;
! 	}
! 
  	amp->nwords = amp->bsize >> 2;
+ 	amp->dbsize = amp->bsize - (IS_FFS(amp) ? 0 : OFS_DATA_OFFSET);
  	amp->devvp = devvp;
  	
  	mp->mnt_data = (qaddr_t)amp;
          mp->mnt_stat.f_fsid.val[0] = (long)devvp->v_rdev;
*************** adosfs_statfs(mp, sbp, p)
*** 281,287 ****
  	amp = VFSTOADOSFS(mp);
  	sbp->f_type = 0;
  	sbp->f_bsize = amp->bsize;
! 	sbp->f_iosize = amp->bsize;
  	sbp->f_blocks = 2;		/* XXX */
  	sbp->f_bfree = 0;		/* none */
  	sbp->f_bavail = 0;		/* none */
--- 304,310 ----
  	amp = VFSTOADOSFS(mp);
  	sbp->f_type = 0;
  	sbp->f_bsize = amp->bsize;
! 	sbp->f_iosize = amp->dbsize;
  	sbp->f_blocks = 2;		/* XXX */
  	sbp->f_bfree = 0;		/* none */
  	sbp->f_bavail = 0;		/* none */
*************** adosfs_vget(mp, an, vpp)
*** 337,343 ****
  	ap->nwords = amp->nwords;
  	adosfs_ainshash(amp, ap);
  
! 	if ((error = bread(amp->devvp, an, amp->bsize, NOCRED, &bp)) != 0) {
  		vput(vp);
  		return (error);
  	}
--- 360,367 ----
  	ap->nwords = amp->nwords;
  	adosfs_ainshash(amp, ap);
  
! 	if ((error = bread(amp->devvp, an * amp->secsperblk,
! 			   amp->bsize, NOCRED, &bp)) != 0) {
  		vput(vp);
  		return (error);
  	}
*************** adosfs_vget(mp, an, vpp)
*** 434,444 ****
  		ap->lastindblk = ap->linkto;
  
  	if (ap->type == AROOT) {
! 		ap->adprot = 0;
  		ap->uid = amp->uid;
  		ap->gid = amp->gid;
  	} else {
! 		ap->adprot = adoswordn(bp, ap->nwords - 48);
  		/*
  		 * Get uid/gid from extensions in file header
  		 * (really need to know if this is a muFS partition)
--- 458,468 ----
  		ap->lastindblk = ap->linkto;
  
  	if (ap->type == AROOT) {
! 		ap->adprot = 15;
  		ap->uid = amp->uid;
  		ap->gid = amp->gid;
  	} else {
! 		ap->adprot = adoswordn(bp, ap->nwords - 48) ^ 15;
  		/*
  		 * Get uid/gid from extensions in file header
  		 * (really need to know if this is a muFS partition)
*** src/sys/adosfs/advnops.c.orig	Sat Feb 10 13:26:39 1996
--- src/sys/adosfs/advnops.c	Sun Mar 17 17:53:36 1996
***************
*** 2,7 ****
--- 2,8 ----
  
  /*
   * Copyright (c) 1994 Christian E. Hopps
+  * Copyright (c) 1996 Matthias Scheler
   * All rights reserved.
   *
   * Redistribution and use in source and binary forms, with or without
*************** adosfs_getattr(v)
*** 212,223 ****
  		 * round up to nearest blocks add number of file list 
  		 * blocks needed and mutiply by number of bytes per block.
  		 */
! 		fblks = howmany(ap->fsize, amp->bsize);
  		fblks += howmany(fblks, ANODENDATBLKENT(ap));
! 		vap->va_bytes = fblks * amp->bsize;
  		vap->va_size = ap->fsize;
  
! 		vap->va_blocksize = amp->bsize;
  	}
  #ifdef ADOSFS_DIAGNOSTIC
  	printf(" 0)");
--- 213,224 ----
  		 * round up to nearest blocks add number of file list 
  		 * blocks needed and mutiply by number of bytes per block.
  		 */
! 		fblks = howmany(ap->fsize, amp->dbsize);
  		fblks += howmany(fblks, ANODENDATBLKENT(ap));
! 		vap->va_bytes = fblks * amp->dbsize;
  		vap->va_size = ap->fsize;
  
! 		vap->va_blocksize = amp->dbsize;
  	}
  #ifdef ADOSFS_DIAGNOSTIC
  	printf(" 0)");
*************** adosfs_read(v)
*** 280,288 ****
  	do {
  		/*
  		 * we are only supporting ADosFFS currently
! 		 * (which have data blocks of 512 bytes)
  		 */
! 		size = amp->bsize;
  		lbn = uio->uio_offset / size;
  		on = uio->uio_offset % size;
  		n = min((u_int)(size - on), uio->uio_resid);
--- 281,289 ----
  	do {
  		/*
  		 * we are only supporting ADosFFS currently
! 		 * (which have data blocks without headers)
  		 */
! 		size = amp->dbsize;
  		lbn = uio->uio_offset / size;
  		on = uio->uio_offset % size;
  		n = min((u_int)(size - on), uio->uio_resid);
*************** adosfs_read(v)
*** 299,307 ****
  		 * but not much as ados makes little attempt to 
  		 * make things contigous
  		 */
! 		error = bread(sp->a_vp, lbn, size, NOCRED, &bp);
  		sp->a_vp->v_lastr = lbn;
! 		n = min(n, (u_int)size - bp->b_resid);
  		if (error) {
  			brelse(bp);
  			goto reterr;
--- 300,328 ----
  		 * but not much as ados makes little attempt to 
  		 * make things contigous
  		 */
! 		error = bread(sp->a_vp, lbn * amp->secsperblk,
! 			      amp->bsize, NOCRED, &bp);
  		sp->a_vp->v_lastr = lbn;
! 
! 		if (!IS_FFS(amp)) {
! 			if (bp->b_resid > 0)
! 				error = EIO; /* OFS needs the complete block */
! 			else if (adoswordn(bp, 0) != BPT_DATA) {
! #ifdef DIAGNOSTIC
! 				printf("adosfs: bad primary type blk %d\n",
! 				       bp->b_blkno / amp->secsperblk);
! #endif
! 				error=EINVAL;
! 			}
! 			else if ( adoscksum(bp, ap->nwords)) {
! #ifdef DIAGNOSTIC
! 				printf("adosfs: blk %d failed cksum.\n",
! 				       bp->b_blkno / amp->secsperblk);
! #endif
! 				error=EINVAL;
! 			}
! 		}
! 
  		if (error) {
  			brelse(bp);
  			goto reterr;
*************** adosfs_read(v)
*** 309,315 ****
  #ifdef ADOSFS_DIAGNOSTIC
  	printf(" %d+%d-%d+%d", lbn, on, lbn, n);
  #endif
! 		error = uiomove(bp->b_un.b_addr + on, (int)n, uio);
  		brelse(bp);
  	} while (error == 0 && uio->uio_resid > 0 && n != 0);
  reterr:
--- 330,338 ----
  #ifdef ADOSFS_DIAGNOSTIC
  	printf(" %d+%d-%d+%d", lbn, on, lbn, n);
  #endif
! 		n = min(n, (u_int)size - bp->b_resid);
! 		error = uiomove(bp->b_un.b_addr + on +
! 				amp->bsize - amp->dbsize, (int)n, uio);
  		brelse(bp);
  	} while (error == 0 && uio->uio_resid > 0 && n != 0);
  reterr:
*************** adosfs_bmap(v)
*** 568,577 ****
  #ifdef ADOSFS_DIAGNOSTIC
  	advopprint(sp);
  #endif
! 	bn = sp->a_bn;
  	bnp = sp->a_bnp;
  	error = 0;
- 	ap = VTOA(sp->a_vp);
  
  	if (sp->a_vpp != NULL)
  		*sp->a_vpp = ap->amp->devvp;
--- 591,600 ----
  #ifdef ADOSFS_DIAGNOSTIC
  	advopprint(sp);
  #endif
! 	ap = VTOA(sp->a_vp);
! 	bn = sp->a_bn / ap->amp->secsperblk;
  	bnp = sp->a_bnp;
  	error = 0;
  
  	if (sp->a_vpp != NULL)
  		*sp->a_vpp = ap->amp->devvp;
*************** adosfs_bmap(v)
*** 622,629 ****
  			error = EINVAL;
  			goto reterr;
  		}
! 		error = bread(ap->amp->devvp, nb, ap->amp->bsize,
! 			      NOCRED, &flbp);
  		if (error)
  			goto reterr;
  		if (adoscksum(flbp, ap->nwords)) {
--- 645,652 ----
  			error = EINVAL;
  			goto reterr;
  		}
! 		error = bread(ap->amp->devvp, nb * ap->amp->secsperblk,
! 			      ap->amp->bsize, NOCRED, &flbp);
  		if (error)
  			goto reterr;
  		if (adoscksum(flbp, ap->nwords)) {
*************** adosfs_bmap(v)
*** 651,661 ****
  	flblkoff = bn % ANODENDATBLKENT(ap);
  	if (flblkoff < adoswordn(flbp, 2 /* ADBI_NBLKTABENT */)) {
  		flblkoff = (ap->nwords - 51) - flblkoff;
! 		*bnp = adoswordn(flbp, flblkoff);
  	} else {
  #ifdef DIAGNOSTIC
  		printf("flblk offset %d too large in lblk %d blk %d\n", 
! 		    flblkoff, bn, flbp->b_blkno);
  #endif
  		error = EINVAL;
  	}
--- 674,684 ----
  	flblkoff = bn % ANODENDATBLKENT(ap);
  	if (flblkoff < adoswordn(flbp, 2 /* ADBI_NBLKTABENT */)) {
  		flblkoff = (ap->nwords - 51) - flblkoff;
! 		*bnp = adoswordn(flbp, flblkoff) * ap->amp->secsperblk;
  	} else {
  #ifdef DIAGNOSTIC
  		printf("flblk offset %d too large in lblk %d blk %d\n", 
! 		    flblkoff, bn / ap->amp->secsperblk , flbp->b_blkno);
  #endif
  		error = EINVAL;
  	}
*** src/sys/adosfs/adutil.c.orig	Sat Feb 10 13:26:38 1996
--- src/sys/adosfs/adutil.c	Sun Mar 17 18:58:25 1996
***************
*** 2,7 ****
--- 2,8 ----
  
  /*
   * Copyright (c) 1994 Christian E. Hopps
+  * Copyright (c) 1996 Matthias Scheler
   * All rights reserved.
   *
   * Redistribution and use in source and binary forms, with or without
***************
*** 44,50 ****
   * look for anode in the mount's hash table, return locked.
   */
  #define AHASH(an) ((an) & (ANODEHASHSZ - 1))
! static int toupper __P((int));
  
  struct vnode * 
  adosfs_ahashget(mp, an)
--- 45,51 ----
   * look for anode in the mount's hash table, return locked.
   */
  #define AHASH(an) ((an) & (ANODEHASHSZ - 1))
! static int CapitalChar __P((int, int));
  
  struct vnode * 
  adosfs_ahashget(mp, an)
*************** adosfs_getblktype(amp, bp)
*** 98,104 ****
  {
  	if (adoscksum(bp, amp->nwords)) {
  #ifdef DIAGNOSTIC
! 		printf("adosfs: aget: cksum of blk %d failed\n", bp->b_blkno);
  #endif
  		return (-1);
  	}
--- 99,106 ----
  {
  	if (adoscksum(bp, amp->nwords)) {
  #ifdef DIAGNOSTIC
! 		printf("adosfs: aget: cksum of blk %d failed\n",
! 		       bp->b_blkno / amp->secsperblk);
  #endif
  		return (-1);
  	}
*************** adosfs_getblktype(amp, bp)
*** 108,114 ****
  	 */
  	if (adoswordn(bp, 0) != BPT_SHORT) {
  #ifdef DIAGNOSTIC
! 		printf("adosfs: aget: bad primary type blk %d\n", bp->b_blkno);
  #endif
  		return (-1);
  	}
--- 110,117 ----
  	 */
  	if (adoswordn(bp, 0) != BPT_SHORT) {
  #ifdef DIAGNOSTIC
! 		printf("adosfs: aget: bad primary type blk %d\n",
! 		       bp->b_blkno / amp->secsperblk);
  #endif
  		return (-1);
  	}
*************** adunixprot(adprot)
*** 135,156 ****
  	int adprot;
  {
  	if (adprot & 0xc000ee00) {
! 		adprot = ((adprot & 0xee00) | (~adprot & 0x000e)) >> 1;
! 		return (((adprot & 0x7) << 6) | ((adprot & 0x700) >> 5) |
! 			(adprot >> 12));
  	}
  	else {
! 		adprot = (~adprot >> 1) & 0x7;
  		return((adprot << 6) | (adprot << 3) | adprot);
  	}
  }
  
  static int
! toupper(ch)
! 	int ch;
  {
! 	if (ch >= 'a' && ch <= 'z')
! 		return(ch & ~(0x20));
  	return(ch);
  }
  
--- 138,161 ----
  	int adprot;
  {
  	if (adprot & 0xc000ee00) {
! 		adprot = (adprot & 0xee0e) >> 1;
! 		return (((adprot & 0x7) << 6) |
! 			((adprot & 0x700) >> 5) |
! 			((adprot & 0x7000) >> 12));
  	}
  	else {
! 		adprot = (adprot >> 1) & 0x7;
  		return((adprot << 6) | (adprot << 3) | adprot);
  	}
  }
  
  static int
! CapitalChar(ch, inter)
! 	int ch, inter;
  {
! 	if ((ch >= 'a' && ch <= 'z') || 
! 	    (inter && ch >= '\340' && ch <= '\376' && ch != '\367'))
! 		return(ch - ('a' - 'A'));
  	return(ch);
  }
  
*************** adoscksum(bp, n)
*** 170,184 ****
  }
  
  int
! adoshash(nam, namlen, nelt)
  	const char *nam;
! 	int namlen, nelt;
  {
  	int val;
  
  	val = namlen;
  	while (namlen--)
! 		val = ((val * 13) + toupper(*nam++)) & 0x7ff;
  	return(val % nelt);
  }
  
--- 175,189 ----
  }
  
  int
! adoshash(nam, namlen, nelt, inter)
  	const char *nam;
! 	int namlen, nelt, inter;
  {
  	int val;
  
  	val = namlen;
  	while (namlen--)
! 		val = ((val * 13) + CapitalChar(*nam++, inter)) & 0x7ff;
  	return(val % nelt);
  }
  
*************** tvtods(tvp, dsp)
*** 204,209 ****
--- 209,215 ----
  }
  #endif
  
+ #ifndef m68k
  long
  adoswordn(bp, wn)
  	struct buf *bp;
*************** adoswordn(bp, wn)
*** 214,216 ****
--- 220,223 ----
  	 */
  	return(ntohl(*((long *)bp->b_data + wn)));
  }
+ #endif
*** src/sys/adosfs/adosfs.h.orig	Sat Feb 10 13:26:38 1996
--- src/sys/adosfs/adosfs.h	Sun Mar 17 17:53:08 1996
***************
*** 2,7 ****
--- 2,8 ----
  
  /*
   * Copyright (c) 1994 Christian E. Hopps
+  * Copyright (c) 1996 Matthias Scheler
   * All rights reserved.
   *
   * Redistribution and use in source and binary forms, with or without
*************** struct anode {
*** 77,86 ****
  	int flags;		/* misc flags */ 
  	char *slinkto;		/* name of file or dir */
  };
! #define VTOA(vp)	((struct anode *)(vp)->v_data)
! #define ATOV(ap)	((ap)->vp)
! #define ANODETABSZ(ap)	(((ap)->nwords - 56) * sizeof(long))
! #define ANODETABENT(ap)	((ap)->nwords - 56)
  #define ANODENDATBLKENT(ap)	((ap)->nwords - 56)
  
  /*
--- 78,87 ----
  	int flags;		/* misc flags */ 
  	char *slinkto;		/* name of file or dir */
  };
! #define VTOA(vp)		((struct anode *)(vp)->v_data)
! #define ATOV(ap)		((ap)->vp)
! #define ANODETABSZ(ap)		(((ap)->nwords - 56) * sizeof(long))
! #define ANODETABENT(ap)		((ap)->nwords - 56)
  #define ANODENDATBLKENT(ap)	((ap)->nwords - 56)
  
  /*
*************** struct anode {
*** 91,101 ****
  struct adosfsmount {
  	LIST_HEAD(anodechain, anode) anodetab[ANODEHASHSZ];
  	struct mount *mp;	/* owner mount */
  	u_long rootb;		/* root block number */
! 	u_long startb;		/* start block */
! 	u_long endb;		/* one block past last */
  	u_long bsize;		/* size of blocks */
  	u_long nwords;		/* size of blocks in long words */
  	uid_t  uid;		/* uid of mounting user */
  	gid_t  gid;		/* gid of mounting user */
  	u_long mask;		/* mode mask */
--- 92,103 ----
  struct adosfsmount {
  	LIST_HEAD(anodechain, anode) anodetab[ANODEHASHSZ];
  	struct mount *mp;	/* owner mount */
+ 	u_long dostype;		/* type of volume */
  	u_long rootb;		/* root block number */
! 	u_long secsperblk;	/* sectors per block */
  	u_long bsize;		/* size of blocks */
  	u_long nwords;		/* size of blocks in long words */
+ 	u_long dbsize;		/* data bytes per block */
  	uid_t  uid;		/* uid of mounting user */
  	gid_t  gid;		/* gid of mounting user */
  	u_long mask;		/* mode mask */
*************** struct adosfsmount {
*** 105,114 ****
--- 107,122 ----
  };
  #define VFSTOADOSFS(mp) ((struct adosfsmount *)(mp)->mnt_data)
  
+ #define IS_FFS(amp)	((amp)->dostype & 1)
+ #define IS_INTER(amp)	(((amp)->dostype & 7) > 1)
+ 
  /*
   * AmigaDOS block stuff.
   */
+ #define BBOFF		(0)
+ 
  #define BPT_SHORT	(2)
+ #define BPT_DATA	(8)
  #define BPT_LIST	(16)
  
  #define BST_RDIR	(1)
*************** struct adosfsmount {
*** 118,129 ****
  #define BST_FILE	(-3L)
  #define BST_LFILE	(-4L)
  
  /*
   * utility protos
   */
  long adoswordn __P((struct buf *, int));
  long adoscksum __P((struct buf *, long));
! int adoshash __P((const char *, int, int));
  int adunixprot __P((int));
  int adosfs_getblktype __P((struct adosfsmount *, struct buf *));
  
--- 126,144 ----
  #define BST_FILE	(-3L)
  #define BST_LFILE	(-4L)
  
+ #define	OFS_DATA_OFFSET	(24)
+ 
  /*
   * utility protos
   */
+ #ifndef m68k
  long adoswordn __P((struct buf *, int));
+ #else
+ #define adoswordn(bp,wn) (*((long *)(bp)->b_data + (wn)))
+ #endif
+ 
  long adoscksum __P((struct buf *, long));
! int adoshash __P((const char *, int, int, int));
  int adunixprot __P((int));
  int adosfs_getblktype __P((struct adosfsmount *, struct buf *));
  
*** src/sys/adosfs/adlookup.c.orig	Wed Feb 14 13:29:52 1996
--- src/sys/adosfs/adlookup.c	Sun Mar 17 17:53:19 1996
***************
*** 2,7 ****
--- 2,8 ----
  
  /*
   * Copyright (c) 1994 Christian E. Hopps
+  * Copyright (c) 1996 Matthias Scheler
   * All rights reserved.
   *
   * Redistribution and use in source and binary forms, with or without
*************** adosfs_lookup(v)
*** 185,191 ****
  	 * then walk the chain. if chain has not been fully
  	 * walked before, track the count in `tabi'
  	 */
! 	hval = adoshash(pelt, plen, adp->ntabent);
  	bn = adp->tab[hval];
  	i = min(adp->tabi[hval], 0);
  	while (bn != 0) {
--- 186,192 ----
  	 * then walk the chain. if chain has not been fully
  	 * walked before, track the count in `tabi'
  	 */
! 	hval = adoshash(pelt, plen, adp->ntabent, IS_INTER(adp->amp));
  	bn = adp->tab[hval];
  	i = min(adp->tabi[hval], 0);
  	while (bn != 0) {
*** src/sys/arch/amiga/amiga/disksubr.c.orig	Mon Jan  8 13:20:15 1996
--- src/sys/arch/amiga/amiga/disksubr.c	Sun Mar 17 00:01:15 1996
*************** readdisklabel(dev, strat, lp, clp)
*** 351,372 ****
  		    * lp->d_secpercyl;
  		pp->p_offset = pbp->e.lowcyl * lp->d_secpercyl;
  		pp->p_fstype = adt.fstype;
- 		if (pbp->e.tabsize > 22 && ISFSARCH_NETBSD(adt)) {
- 			pp->p_fsize = pbp->e.fsize;
- 			pp->p_frag = pbp->e.frag;	
- 			pp->p_cpg = pbp->e.cpg;
- 		} else {
- 			pp->p_fsize = 1024;
- 			pp->p_frag = 8;	
- 			pp->p_cpg = 0;
- 		}
  		if (adt.archtype == ADT_AMIGADOS) {
  			/*
  			 * Save reserved blocks at begin in cpg and
  			 *  adjust size by reserved blocks at end
  			 */
  			pp->p_cpg = pbp->e.resvblocks;
  			pp->p_size -= pbp->e.prefac;
  		}
  
  		/*
--- 351,373 ----
  		    * lp->d_secpercyl;
  		pp->p_offset = pbp->e.lowcyl * lp->d_secpercyl;
  		pp->p_fstype = adt.fstype;
  		if (adt.archtype == ADT_AMIGADOS) {
  			/*
  			 * Save reserved blocks at begin in cpg and
  			 *  adjust size by reserved blocks at end
  			 */
+ 			pp->p_fsize = 512;
+ 			pp->p_frag = pbp->e.secperblk;
  			pp->p_cpg = pbp->e.resvblocks;
  			pp->p_size -= pbp->e.prefac;
+ 		} else if (pbp->e.tabsize > 22 && ISFSARCH_NETBSD(adt)) {
+ 			pp->p_fsize = pbp->e.fsize;
+ 			pp->p_frag = pbp->e.frag;
+ 			pp->p_cpg = pbp->e.cpg;
+ 		} else {
+ 			pp->p_fsize = 1024;
+ 			pp->p_frag = 8;
+ 			pp->p_cpg = 0;
  		}
  
  		/*
*************** getadostype(dostype)
*** 543,551 ****
  		return(adt);
  	case DOST_MUFS:
  		/* check for 'muFS'? */
- 	case DOST_DOS:
  		adt.archtype = ADT_AMIGADOS;
  		adt.fstype = FS_ADOS;
  		return(adt);
  	case DOST_AMIX:
  		adt.archtype = ADT_AMIX;
--- 544,558 ----
  		return(adt);
  	case DOST_MUFS:
  		/* check for 'muFS'? */
  		adt.archtype = ADT_AMIGADOS;
  		adt.fstype = FS_ADOS;
+ 		return(adt);
+ 	case DOST_DOS:
+ 		adt.archtype = ADT_AMIGADOS;
+                 if (b1 > 5)
+ 			adt.fstype = FS_UNUSED;
+ 		else
+ 			adt.fstype = FS_ADOS;
  		return(adt);
  	case DOST_AMIX:
  		adt.archtype = ADT_AMIX;

>Audit-Trail:
>Unformatted: