[4699] in Athena Bugs

home help back first fref pref prev next nref lref last post

vax 6.4R: mountfs does not close device if fails in mounting process

daemon@ATHENA.MIT.EDU (Ezra Peisach)
Thu Apr 5 19:15:34 1990

To: bugs@ATHENA.MIT.EDU
Date: Thu, 05 Apr 90 19:15:17 EDT
From: Ezra Peisach <epeisach@ATHENA.MIT.EDU>
System name:		wombat
Type and version:	MVAX-II 6.4R (1 update(s) to same version)
Display type:		QDSS

What were you trying to do?
	Trying to test the vs3100 floppy driver by mounting the floppy
drive without a floppy in the drive and the light stays on.

What's wrong:
	In ufs_vfsops.c the mountfs call will call open which succeeds,
but then fails in the read of the superblock. It never calls close.

What should have happened:
	The close routine should be called (so the floppy light will go
out :)

Fix:

(modeled after ufs_mount.c in 4.3tahoe, but not exactly.)

*** /tmp/,RCSt1005862	Thu Apr  5 19:13:53 1990
--- ufs_vfsops.c	Thu Apr  5 17:55:29 1990
***************
*** 146,164 ****
  	int i;
  	int size;
  	extern char *strncpy();
  
  	/*
- 	 * Open block device mounted on.
- 	 * When bio is fixed for vnodes this can all be vnode operations
- 	 */
- 	error =
- 	    (*bdevsw[major(dev)].d_open)(
- 		dev, (vfsp->vfs_flag & VFS_RDONLY) ? FREAD : FREAD|FWRITE);
- 	if (error) {
- 		/* return (error); */
- 		return (EIO);
- 	}
- 	/*
  	 * check for dev already mounted on
  	 */
  	for (mp = &mounttab[0]; mp < &mounttab[NMOUNT]; mp++) {
--- 146,154 ----
  	int i;
  	int size;
  	extern char *strncpy();
+ 	int needclose = 0;
  
  	/*
  	 * check for dev already mounted on
  	 */
  	for (mp = &mounttab[0]; mp < &mounttab[NMOUNT]; mp++) {
***************
*** 174,180 ****
--- 164,182 ----
  			goto found;
  	}
  	return (EBUSY);
+ 	/*
+ 	 * Open block device mounted on.
+ 	 * When bio is fixed for vnodes this can all be vnode operations
+ 	 */
  found:
+ 	error =
+ 	    (*bdevsw[major(dev)].d_open)(
+ 		dev, (vfsp->vfs_flag & VFS_RDONLY) ? FREAD : FREAD|FWRITE);
+ 	if (error) {
+ 		/* return (error); */
+ 		return (EIO);
+ 	}
+ 	needclose = 1;
  	vfsp->vfs_data = (caddr_t)mp;
  	mp->m_vfsp = vfsp;
  	/*
***************
*** 234,239 ****
--- 236,244 ----
  	VN_RELE(dev_vp);
  	return (0);
  out:
+ 	if (needclose)
+ 	    (*bdevsw[major(dev)].d_close)(
+ 		 dev, (vfsp->vfs_flag & VFS_RDONLY) ? FREAD : FREAD|FWRITE);
  	mp->m_bufp = 0;
  	if (bp)
  		brelse(bp);

home help back first fref pref prev next nref lref last post