From hiroo@oikumene.gcd.org  Wed Oct  3 07:46:13 2001
Return-Path: <hiroo@oikumene.gcd.org>
Received: from mail151.nifty.com (mail151.nifty.com [202.248.37.144])
	by hub.freebsd.org (Postfix) with ESMTP id 768DA37B401
	for <FreeBSD-gnats-submit@freebsd.org>; Wed,  3 Oct 2001 07:46:12 -0700 (PDT)
Received: from chrysanthe.oikumene.gcd.org
	by mail151.nifty.com (8.11.4+3.4W/3.7W-10/13/99) with SMTP id f93Ek9A28466
	for <FreeBSD-gnats-submit@freebsd.org>; Wed, 3 Oct 2001 23:46:09 +0900
Received: (qmail 69193 invoked by uid 1001); 3 Oct 2001 14:46:08 -0000
Message-Id: <20011003144608.69192.qmail@chrysanthe.oikumene.gcd.org>
Date: 3 Oct 2001 14:46:08 -0000
From: hiroo@oikumene.gcd.org
To: FreeBSD-gnats-submit@freebsd.org
Cc:
Subject: Installing current snapshot fails at sysintall/install.c:installFilesystems()
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         31009
>Category:       bin
>Synopsis:       Installing the current snapshot fails when calling MakeDevChunk().
>Confidential:   no
>Severity:       serious
>Priority:       low
>Responsible:    matusita
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Wed Oct 03 07:50:00 PDT 2001
>Closed-Date:    Wed Nov 14 04:39:48 PST 2001
>Last-Modified:  Wed Nov 14 04:42:27 PST 2001
>Originator:     Hiroo ONO
>Release:        FreeBSD-current
>Organization:
>Environment:
System: 5.0-CURRENT-20011002-JPSNAP for i386 (build at current.jp.FreeBSD.org).
>Description:
	Installation of recent current snapshot fails.
	Editing of disklabel may fail from the same reason.

	installFilesystems() of usr.bin/sysinstall/install.c rev.1.307
	calls MakeDevChunk() of lib/libdisk/create_chunk.c rev.1.61,
	which then calls the function MakeDev() of the same file.
	Then, MakeDev() calls mknod(2) which fails when DEVFS is enabled.

>How-To-Repeat:
	Install the snapshot after October 1, 2001 or edit disklabels
	from the sysinstall. It will stop with the error message like:
	  mknod of /dev/rad0a1b returned failure status!

>Fix:
	(1) Checking DEVFS MIB using sysctl(3) in MakeDev() of the libdisk
	    and skip calling mknod(2) may be the best solution.
	(2) Or checking if DEVFS is enabled or not (as above) in
	    installFilesystems() of usr.bin/sysinstall can be an alternative.
	    But, it will not avoid similar problems if other programs call
	    MakeDevChunk() or MakeDev().
	(3) Disabling DEVFS in the install kernerl may be a quick but bad
	    solution. The bug will stay if one uses sysinstall in a system
	   with DEVFS enabled (e.g. when adding a HDD).
>Release-Note:
>Audit-Trail:

From: Hiroo ONO (=?iso-2022-jp?B?GyRCPi5MbjQyQDgbKEI=?=) <hiroo@oikumene.gcd.org>
To: freebsd-gnats-submit@FreeBSD.org
Cc:  
Subject: Re: bin/31009: Installing current snapshot fails at
 sysintall/install.c:installFilesystems()
Date: Fri, 05 Oct 2001 03:10:39 +0900

 ----Next_Part(Fri_Oct__5_02:54:40_2001_41)--
 Content-Type: Text/Plain; charset=us-ascii
 Content-Transfer-Encoding: 7bit
 
 I think the patch for lib/libdisk/create_chunk.c below solves the
 problem. It checks the devfs MIB exists and return 1 if it exists.
 As I failed to install FreeBSD-current due to this bug, I cannot test
 if it works :-)
 
 thanks to Masahide -mac- NODA, Hajimu UMEMOTO and Makoto `MAR' MATSUSHITA
 for the advice.
 
 ----Next_Part(Fri_Oct__5_02:54:40_2001_41)--
 Content-Type: Text/Plain; charset=us-ascii
 Content-Transfer-Encoding: 7bit
 Content-Disposition: attachment; filename="create_chunk.c.diff"
 
 *** create_chunk.c.orig	Fri Oct  5 02:07:06 2001
 --- create_chunk.c	Fri Oct  5 02:31:10 2001
 ***************
 *** 22,27 ****
 --- 22,28 ----
   #include <sys/diskslice.h>
   #include <sys/types.h>
   #include <sys/stat.h>
 + #include <sys/sysctl.h>
   #include <grp.h>
   #include <paths.h>
   #include <pwd.h>
 ***************
 *** 283,294 ****
 --- 284,303 ----
       struct passwd *pwd;
       uid_t owner;
       gid_t group;
 +     int mib[4];
 +     size_t miblen;
   
       *buf2 = '\0';
 +     miblen = sizeof(mib)/sizeof(mib[0]);
       if (isDebug())
   	msgDebug("MakeDev: Called with %s on path %s\n", p, path);
       if (!strcmp(p, "X"))
   	return 0;
 +     if (!sysctlnametomib("vfs.devfs.generation", &mib, &miblen)) {
 + 	if (isDebug())
 + 	    msgDebug("MakeDev: No need to mknod(2) with DEVFS.\n");
 + 	return 1;
 +     }
   
       if (!strncmp(p, "ad", 2))
   	cmaj = 116, p += 2;
 
 ----Next_Part(Fri_Oct__5_02:54:40_2001_41)----

From: Makoto Matsushita <matusita@jp.freebsd.org>
To: freebsd-gnats-submit@FreeBSD.org
Cc: jkh@FreeBSD.org
Subject: Re: bin/31009: Installing current snapshot fails at
 sysintall/install.c:installFilesystems()
Date: Fri, 09 Nov 2001 01:36:51 +0900

 Hiroo-san's patch has a bug: if kernel does know about DEVFS, libdisk
 doesn't do mknod(2) even if it's actually not DEVFS.  This causes that
 current 5-current's sysinstall(8) fails to create filesystem while a
 fresh installation procedure.
 
 I've reported this bug (sysinstall fails to create filesystem) from
 users of snapshots.jp.FreeBSD.org, and confirmed that hiroo-san's
 patch is not an actual fix.
 
 Jordan, would you please check my patch?  If you are OK, please commit
 or I'll do.
 
 P.S.: I've already discussed with hiroo-san about this patch.
 
 -- -
 Makoto `MAR' MATSUSHITA
 
 Index: create_chunk.c
 ===================================================================
 RCS file: /home/ncvs/src/lib/libdisk/create_chunk.c,v
 retrieving revision 1.62
 diff -u -r1.62 create_chunk.c
 --- create_chunk.c	10 Oct 2001 07:46:04 -0000	1.62
 +++ create_chunk.c	8 Nov 2001 16:23:17 -0000
 @@ -17,10 +17,10 @@
  #include <ctype.h>
  #include <fcntl.h>
  #include <stdarg.h>
 -#include <sys/types.h>
 +#include <sys/param.h>
  #include <sys/disklabel.h>
  #include <sys/diskslice.h>
 -#include <sys/types.h>
 +#include <sys/mount.h>
  #include <sys/stat.h>
  #include <sys/sysctl.h>
  #include <grp.h>
 @@ -282,18 +282,22 @@
      char buf[BUFSIZ], buf2[BUFSIZ];
      struct group *grp;
      struct passwd *pwd;
 +    struct statfs fs;
      uid_t owner;
      gid_t group;
 -    int mib[4];
 -    size_t miblen;
  
      *buf2 = '\0';
 -    miblen = sizeof(mib)/sizeof(mib[0]);
      if (isDebug())
  	msgDebug("MakeDev: Called with %s on path %s\n", p, path);
      if (!strcmp(p, "X"))
  	return 0;
 -    if (!sysctlnametomib("vfs.devfs.generation", &mib, &miblen)) {
 +    if (statfs(path, &fs) != 0) {
 +#ifdef DEBUG
 +	warn("statfs(%s) failed\n", path);
 +#endif
 +	return 0;
 +    }
 +    if (strcmp(fs.f_fstypename, "devfs") == 0) {
  	if (isDebug())
  	    msgDebug("MakeDev: No need to mknod(2) with DEVFS.\n");
  	return 1;

From: Makoto Matsushita <matusita@jp.freebsd.org>
To: freebsd-gnats-submit@FreeBSD.org, jkh@FreeBSD.org
Cc:  
Subject: Re: bin/31009: Installing current snapshot fails at
 sysintall/install.c:installFilesystems()
Date: Mon, 12 Nov 2001 00:14:01 +0900

 matusita> Hiroo-san's patch has a bug: if kernel does know about
 matusita> DEVFS, libdisk doesn't do mknod(2) even if it's actually not
 matusita> DEVFS.  This causes that current 5-current's sysinstall(8)
 matusita> fails to create filesystem while a fresh installation
 matusita> procedure.
 
 I've made a small test, and this patch seems working as expected.  To
 make more verification, I commited this patch.  I'll test with next
 5-current SNAPSHOTs.
 
 If it works fine, I'll close this PR.
 
 -- -
 Makoto `MAR' Matsushita
State-Changed-From-To: open->feedback 
State-Changed-By: matusita 
State-Changed-When: Sun Nov 11 15:48:09 PST 2001 
State-Changed-Why:  
I've applied my patch as src/lib/libidisk/create_chunk.c rev 1.63, 
and 5.0-CURRENT-20011112-JPSNAP which was included a patch seems 
working.  Hiroo-san, would you please confirm that this bug is disappeared? 


Responsible-Changed-From-To: freebsd-bugs->matusita 
Responsible-Changed-By: matusita 
Responsible-Changed-When: Sun Nov 11 15:48:09 PST 2001 
Responsible-Changed-Why:  
I'll handle this to close this PR if problem is solved. 

http://www.FreeBSD.org/cgi/query-pr.cgi?pr=31009 

From: Galen Sampson <galen_sampson@yahoo.com>
To: freebsd-gnats-submit@FreeBSD.org, hiroo@oikumene.gcd.org
Cc:  
Subject: Re: bin/31009: Installing the current snapshot fails when calling MakeDevChunk().
Date: Tue, 13 Nov 2001 14:16:58 -0800 (PST)

 I have successfully been able to install -current with kern.flp and mfsroot.flp
 downloaded from
 ftp://current.freebsd.org/pub/FreeBSD/snapshots/i386/5.0-20011112-CURRENT.  The
 same disks failed to install properly from 11-09, 11-10, and 11-11.  It seems
 that the patch mentioned is working.
 
 Galen
 
 __________________________________________________
 Do You Yahoo!?
 Find the one for you at Yahoo! Personals
 http://personals.yahoo.com

From: Makoto Matsushita <matusita@jp.freebsd.org>
To: galen_sampson@yahoo.com
Cc: freebsd-gnats-submit@FreeBSD.org
Subject: Re: bin/31009: Installing the current snapshot fails when calling
 MakeDevChunk().
Date: Wed, 14 Nov 2001 14:45:52 +0900

 galen_sampson>  I have successfully been able to install -current with
 galen_sampson>  kern.flp and mfsroot.flp downloaded from
 galen_sampson>  ftp://current.freebsd.org/pub/FreeBSD/snapshots/i386/5.0-20011112-CURRENT.
 
 Glad to hear that, thank you.
 
 -- -
 Makoto `MAR' Matsushita
State-Changed-From-To: feedback->closed 
State-Changed-By: matusita 
State-Changed-When: Wed Nov 14 04:39:48 PST 2001 
State-Changed-Why:  
src/lib/libdisk/create_chunk.c rev 1.63 fixes this problem. 
I and Galen Sampson <galen_sampson@yahoo.com> confirm that 
current SNAPSHOTs floppies do the right things. 

http://www.FreeBSD.org/cgi/query-pr.cgi?pr=31009 
>Unformatted:
