From owner-svn-src-head@FreeBSD.ORG Sat Apr 13 05:51:20 2013 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.FreeBSD.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id E577399D; Sat, 13 Apr 2013 05:51:20 +0000 (UTC) (envelope-from c.jayachandran@gmail.com) Received: from mail-ie0-x22c.google.com (mail-ie0-x22c.google.com [IPv6:2607:f8b0:4001:c03::22c]) by mx1.freebsd.org (Postfix) with ESMTP id 98D55A4; Sat, 13 Apr 2013 05:51:20 +0000 (UTC) Received: by mail-ie0-f172.google.com with SMTP id c10so4206760ieb.3 for ; Fri, 12 Apr 2013 22:51:20 -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=6ED90G7qgUq7NHR2FYM1L8u2oq70/VtFKB77BwHHWB0=; b=0xTaS7rBWTrPKZ6ZyNsApPW4202WwfJKcw5aetzrls5x+oY/K7n0qszkebgbaIaxxU ToWX2L6wTbxJxRFdVz24soJrKMWupEFIhecA+mEjRZsaCGYnPzeiJxXZiesggXGjIHTT MfDKkswnzT5L3qv2ub6lcVSAbFNY3NqYmAq6PWudaK8vdPHyd4ANcngG3kLHu3R2Irjr LNfMuABLPBu0FsyyKqjpGRe9Zt2rp9tKRvTveCplH//329o7J9t8n2eN78ASIVUhO4vf 46OSN5UXSQlHxgRlT4ELS8k0YDX0XK5NgyFYvYaXWky/SPUyIT5HqksU5hzkFry3WLhr ZCTQ== MIME-Version: 1.0 X-Received: by 10.50.67.18 with SMTP id j18mr855825igt.110.1365832280271; Fri, 12 Apr 2013 22:51:20 -0700 (PDT) Sender: c.jayachandran@gmail.com Received: by 10.64.138.67 with HTTP; Fri, 12 Apr 2013 22:51:20 -0700 (PDT) In-Reply-To: References: <201304121558.r3CFwsb4059283@svn.freebsd.org> Date: Sat, 13 Apr 2013 11:21:20 +0530 X-Google-Sender-Auth: esT9v_i4AUvX-Br07t9B8GAaN4M Message-ID: Subject: Re: svn commit: r249408 - head/sys/kern From: "Jayachandran C." To: Navdeep Parhar Content-Type: multipart/mixed; boundary=047d7bdc0532e3711204da379be5 X-Content-Filtered-By: Mailman/MimeDel 2.1.14 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: Sat, 13 Apr 2013 05:51:21 -0000 --047d7bdc0532e3711204da379be5 Content-Type: text/plain; charset=ISO-8859-1 On Sat, Apr 13, 2013 at 3:12 AM, Navdeep Parhar wrote: > 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" > > After looking at the changes again, I realized that most architectures do not update the env_pos when they setup kern_envp. If there are no objections, I will check-in the attached change, otherwise I will revert this commit. Thanks for reporting this, and sorry for the mess. JC. > 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; > > > --047d7bdc0532e3711204da379be5 Content-Type: application/octet-stream; name="kenv-fix.diff" Content-Disposition: attachment; filename="kenv-fix.diff" Content-Transfer-Encoding: base64 X-Attachment-Id: f_hfgcmq3w0 SW5kZXg6IHN5cy9rZXJuL2tlcm5fZW52aXJvbm1lbnQuYwo9PT09PT09PT09PT09PT09PT09PT09 PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09Ci0tLSBzeXMva2Vy bi9rZXJuX2Vudmlyb25tZW50LmMJKHJldmlzaW9uIDI0OTQwOCkKKysrIHN5cy9rZXJuL2tlcm5f ZW52aXJvbm1lbnQuYwkod29ya2luZyBjb3B5KQpAQCAtMjMxLDcgKzIzMSw3IEBACiAJa2VudnAg PSBtYWxsb2MoKEtFTlZfU0laRSArIDEpICogc2l6ZW9mKGNoYXIgKiksIE1fS0VOViwKIAkJTV9X QUlUT0sgfCBNX1pFUk8pOwogCWkgPSAwOwotCWlmIChlbnZfcG9zID4gMCkgeworCWlmICgqa2Vy bl9lbnZwICE9ICdcMCcpIHsKIAkJZm9yIChjcCA9IGtlcm5fZW52cDsgY3AgIT0gTlVMTDsgY3Ag PSBrZXJuZW52X25leHQoY3ApKSB7CiAJCQlsZW4gPSBzdHJsZW4oY3ApICsgMTsKIAkJCWlmIChs ZW4gPiBLRU5WX01OQU1FTEVOICsgMSArIEtFTlZfTVZBTExFTiArIDEpIHsK --047d7bdc0532e3711204da379be5--