Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 26 Nov 2002 13:16:18 -0500
From:      Hiten Pandya <hiten@angelica.unixdaemons.com>
To:        Bruce Evans <bde@zeta.org.au>
Cc:        "Vladimir B.  Grebenschikov" <vova@sw.ru>, "current@freebsd.org" <current@FreeBSD.ORG>
Subject:   Re: MD broken in current
Message-ID:  <20021126181618.GA96598@angelica.unixdaemons.com>
In-Reply-To: <20021126205027.G3809-100000@gamplex.bde.org>
References:  <1038301169.746.6.camel@vbook> <20021126205027.G3809-100000@gamplex.bde.org>

next in thread | previous in thread | raw e-mail | index | archive | help

--X1bOJ3K7DJ5YkBrT
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline

On Tue, Nov 26, 2002 at 09:00:37PM +1100, Bruce Evans wrote the words in effect of:
> On 26 Nov 2002, Vladimir B.  Grebenschikov wrote:
> 
> > # mdconfig  -a -t vnode ./bootimg.bin
> > mdconfig: ioctl(/dev/mdctl): Bad address
> 
> This should be ... "-t vnode -f ./bootimg.bin".
> 
> The bug is just low quality option parsing.  ./bootimg.bin is garbage
> when it is not preceded by -f, and garbage args are silently ignored.
> A "-f file" is required to specify the vnode for "-t vnode" but neither
> the man page synopsis nor the usage message are detailed enough to
> say this.  When no file arg is specified, the file arg is NULL and
> this causes the "Bad address" error.

There is also a problem, when the md(4) driver is passed a 0 byte file,
i.e. mdconfig -a -t -vnode -f /tmp/mdimage.zero.  It simply hangs the
process in the `mddestroy' state, making it unkillable.

David Wolfskill tested a patch, which I made.  It could be a _possible_
fix to the problem.   When a 0 byte file is found, by mdcreate_vnode()
it passes up an EINVAL.

I used the stat structure, and the vn_stat() routine to get the information,
although I am not sure if that is the best/sane way of doing it.  The URL for
the patch is: http://www.unixdaemons.com/~hiten/work/diffs/md.c.patch

Cheers.

-- 
Hiten Pandya (hiten@unixdaemons.com, hiten@uk.FreeBSD.org)
http://www.unixdaemons.com/~hiten/

--X1bOJ3K7DJ5YkBrT
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="md.c.patch"

Index: md.c
===================================================================
RCS file: /home/ncvs/src/sys/dev/md/md.c,v
retrieving revision 1.74
diff -u -r1.74 md.c
--- md.c	2002/10/21 20:08:28	1.74
+++ md.c	2002/11/24 23:43:40
@@ -79,6 +79,7 @@
 #include <sys/stdint.h>
 #include <sys/sysctl.h>
 #include <sys/vnode.h>
+#include <sys/stat.h>
 
 #include <vm/vm.h>
 #include <vm/vm_object.h>
@@ -807,6 +808,7 @@
 	struct md_s *sc;
 	struct vattr vattr;
 	struct nameidata nd;
+	struct stat sb;
 	int error, flags;
 
 	flags = FREAD|FWRITE;
@@ -828,6 +830,13 @@
 		(void) vn_close(nd.ni_vp, flags, td->td_ucred, td);
 		return (error ? error : EINVAL);
 	}
+
+	error = vn_stat(nd.ni_vp, &sb, td->td_ucred, NOCRED, td);
+	if (error)
+		return (error);
+	if (sb.st_size == 0)
+		return (EINVAL);
+	
 	VOP_UNLOCK(nd.ni_vp, 0, td);
 
 	if (mdio->md_options & MD_AUTOUNIT) {

--X1bOJ3K7DJ5YkBrT--

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-current" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20021126181618.GA96598>