From owner-freebsd-current Tue Nov 26 10:16:46 2002 Delivered-To: freebsd-current@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 611C737B401 for ; Tue, 26 Nov 2002 10:16:44 -0800 (PST) Received: from angelica.unixdaemons.com (angelica.unixdaemons.com [209.148.64.135]) by mx1.FreeBSD.org (Postfix) with ESMTP id 84C4643EA9 for ; Tue, 26 Nov 2002 10:16:43 -0800 (PST) (envelope-from hiten@angelica.unixdaemons.com) Received: from angelica.unixdaemons.com (hiten@localhost.unixdaemons.com [127.0.0.1]) by angelica.unixdaemons.com (8.12.5/8.12.1) with ESMTP id gAQIGJSu097636; Tue, 26 Nov 2002 13:16:19 -0500 (EST) X-Authentication-Warning: angelica.unixdaemons.com: Host hiten@localhost.unixdaemons.com [127.0.0.1] claimed to be angelica.unixdaemons.com Received: (from hiten@localhost) by angelica.unixdaemons.com (8.12.5/8.12.1/Submit) id gAQIGIhn097635; Tue, 26 Nov 2002 13:16:18 -0500 (EST) (envelope-from hiten) Date: Tue, 26 Nov 2002 13:16:18 -0500 From: Hiten Pandya To: Bruce Evans Cc: "Vladimir B. Grebenschikov" , "current@freebsd.org" Subject: Re: MD broken in current Message-ID: <20021126181618.GA96598@angelica.unixdaemons.com> References: <1038301169.746.6.camel@vbook> <20021126205027.G3809-100000@gamplex.bde.org> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="X1bOJ3K7DJ5YkBrT" Content-Disposition: inline In-Reply-To: <20021126205027.G3809-100000@gamplex.bde.org> User-Agent: Mutt/1.4i X-Operating-System: FreeBSD i386 X-Public-Key: http://www.pittgoth.com/~hiten/pubkey.asc X-URL: http://www.unixdaemons.com/~hiten X-PGP: http://pgp.mit.edu:11371/pks/lookup?search=Hiten+Pandya&op=index Sender: owner-freebsd-current@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG --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 #include #include +#include #include #include @@ -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