svn commit: r249408 - head/sys/kern

Jayachandran C. jchandra at freebsd.org
Sat Apr 13 05:51:21 UTC 2013


On Sat, Apr 13, 2013 at 3:12 AM, Navdeep Parhar <np at 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 at 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;
> >
>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: kenv-fix.diff
Type: application/octet-stream
Size: 501 bytes
Desc: not available
URL: <http://lists.freebsd.org/pipermail/svn-src-head/attachments/20130413/af26d138/attachment.obj>


More information about the svn-src-head mailing list