From owner-svn-src-head@FreeBSD.ORG Fri Apr 12 21:42:28 2013 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id B75B584C; Fri, 12 Apr 2013 21:42:28 +0000 (UTC) (envelope-from nparhar@gmail.com) Received: from mail-la0-x22e.google.com (mail-la0-x22e.google.com [IPv6:2a00:1450:4010:c03::22e]) by mx1.freebsd.org (Postfix) with ESMTP id A9B721EB1; Fri, 12 Apr 2013 21:42:27 +0000 (UTC) Received: by mail-la0-f46.google.com with SMTP id ea20so2923372lab.33 for ; Fri, 12 Apr 2013 14:42:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:x-received:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type; bh=1FP7XO5Y/Oq5vhl2/GSrtPxXlzZICF5YZ+a98vkpUgc=; b=0Yl6AWfbTf/jirjinj0Kf7XKddePAE1KTR+KUVmYLZNVJFU1r7uCJiI9SFm3JHIQN3 vEy+GuG/FA8Wltcwf9VsusBJSrc+beX+UejuHnbn+paSYJ1L3ItuJOtsJdQaKN/blct2 6uTTmlfqb1y7y05trn2AAGsHExbDR1Ly8DTm1J26O5LCLMUE+Az6h79t/g1yaVvimvf4 249gJ5CYP2h/pd6p9C5WeKc5WYfFa7CTgnnrgnLi9QJ+XZ7iktRX6kcgv7T3bAjEwpph QyACaCTynoc0neuNMHzFUyBQHpioiI5a+TGdL/vrnKOCPdkjhWtClEp9eNDAySIyK7Sf 0Uyg== MIME-Version: 1.0 X-Received: by 10.112.154.233 with SMTP id vr9mr5000014lbb.23.1365802946312; Fri, 12 Apr 2013 14:42:26 -0700 (PDT) Sender: nparhar@gmail.com Received: by 10.114.12.232 with HTTP; Fri, 12 Apr 2013 14:42:26 -0700 (PDT) In-Reply-To: <201304121558.r3CFwsb4059283@svn.freebsd.org> References: <201304121558.r3CFwsb4059283@svn.freebsd.org> Date: Fri, 12 Apr 2013 14:42:26 -0700 X-Google-Sender-Auth: J3iEPvJnjYaT2Idt5Oh2Phh96cg Message-ID: Subject: Re: svn commit: r249408 - head/sys/kern From: Navdeep Parhar To: "Jayachandran C." Content-Type: text/plain; charset=ISO-8859-1 Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 12 Apr 2013 21:42:28 -0000 This prevents my system from booting up properly. Backing out this change restores normal operation. The symptoms are that the kernel doesn't find the root fs itself but waits at the mountroot> prompt instead. I'm able to specify the filesystem to use and then the boot proceeds as normal. Once the system has booted up I see only two entries in kenv, indicating that something clobbered the environment. # kenv kern.devalias.ada0="ad4" kern.devalias.ada1="ad6" Regards, Navdeep On Fri, Apr 12, 2013 at 8:58 AM, Jayachandran C. wrote: > Author: jchandra > Date: Fri Apr 12 15:58:53 2013 > New Revision: 249408 > URL: http://svnweb.freebsd.org/changeset/base/249408 > > Log: > Fix kenv behavior when there is no static environment > > In case where there are no static kernel environment entries, the > function init_dynamic_kenv() adds an incorrect entry at position 0 of > the dynamic kernel environment. This in turn causes kenv(1) to print > and empty list even though there are dynamic entries added later. > > Fix this by checking env_pos in init_dynamic_kenv() and adding dynamic > entries only if there are static entries. > > Modified: > head/sys/kern/kern_environment.c > > Modified: head/sys/kern/kern_environment.c > ============================================================================== > --- head/sys/kern/kern_environment.c Fri Apr 12 15:19:35 2013 (r249407) > +++ head/sys/kern/kern_environment.c Fri Apr 12 15:58:53 2013 (r249408) > @@ -231,20 +231,23 @@ init_dynamic_kenv(void *data __unused) > kenvp = malloc((KENV_SIZE + 1) * sizeof(char *), M_KENV, > M_WAITOK | M_ZERO); > i = 0; > - for (cp = kern_envp; cp != NULL; cp = kernenv_next(cp)) { > - len = strlen(cp) + 1; > - if (len > KENV_MNAMELEN + 1 + KENV_MVALLEN + 1) { > - printf("WARNING: too long kenv string, ignoring %s\n", > - cp); > - continue; > + if (env_pos > 0) { > + for (cp = kern_envp; cp != NULL; cp = kernenv_next(cp)) { > + len = strlen(cp) + 1; > + if (len > KENV_MNAMELEN + 1 + KENV_MVALLEN + 1) { > + printf( > + "WARNING: too long kenv string, ignoring %s\n", > + cp); > + continue; > + } > + if (i < KENV_SIZE) { > + kenvp[i] = malloc(len, M_KENV, M_WAITOK); > + strcpy(kenvp[i++], cp); > + } else > + printf( > + "WARNING: too many kenv strings, ignoring %s\n", > + cp); > } > - if (i < KENV_SIZE) { > - kenvp[i] = malloc(len, M_KENV, M_WAITOK); > - strcpy(kenvp[i++], cp); > - } else > - printf( > - "WARNING: too many kenv strings, ignoring %s\n", > - cp); > } > kenvp[i] = NULL; >