Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 13 Apr 2013 11:21:20 +0530
From:      "Jayachandran C." <jchandra@freebsd.org>
To:        Navdeep Parhar <np@freebsd.org>
Cc:        svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org
Subject:   Re: svn commit: r249408 - head/sys/kern
Message-ID:  <CA%2B7sy7DB1_ZWj3P1ADuH1pJokhicM05_nxvF7a37twvgoWK-Tw@mail.gmail.com>
In-Reply-To: <CAPFoGT8NNbEYyqZFU0ZOotPtjsOx6A%2BtgRX0wNqaBr1B0KGP_Q@mail.gmail.com>
References:  <201304121558.r3CFwsb4059283@svn.freebsd.org> <CAPFoGT8NNbEYyqZFU0ZOotPtjsOx6A%2BtgRX0wNqaBr1B0KGP_Q@mail.gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help
--047d7bdc0532e3711204da379be5
Content-Type: text/plain; charset=ISO-8859-1

On Sat, Apr 13, 2013 at 3:12 AM, Navdeep Parhar <np@freebsd.org> 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. <jchandra@freebsd.org>
> 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--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CA%2B7sy7DB1_ZWj3P1ADuH1pJokhicM05_nxvF7a37twvgoWK-Tw>