Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 12 Apr 2013 14:42:26 -0700
From:      Navdeep Parhar <np@FreeBSD.org>
To:        "Jayachandran C." <jchandra@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:  <CAPFoGT8NNbEYyqZFU0ZOotPtjsOx6A%2BtgRX0wNqaBr1B0KGP_Q@mail.gmail.com>
In-Reply-To: <201304121558.r3CFwsb4059283@svn.freebsd.org>
References:  <201304121558.r3CFwsb4059283@svn.freebsd.org>

next in thread | previous in thread | raw e-mail | index | archive | help
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. <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;
>



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