svn commit: r368197 - head/sbin/bectl

Kyle Evans kevans at freebsd.org
Wed Dec 2 18:08:57 UTC 2020


On Wed, Dec 2, 2020 at 12:02 PM Gleb Smirnoff <glebius at freebsd.org> wrote:
>
>   Kyle,
>
> On Mon, Nov 30, 2020 at 08:28:58PM -0600, Kyle Evans wrote:
> K> > Log:
> K> >   Print at least something when failing.
> K> >
> K> > Modified:
> K> >   head/sbin/bectl/bectl.c
> K> >
> K> > Modified: head/sbin/bectl/bectl.c
> K> > ==============================================================================
> K> > --- head/sbin/bectl/bectl.c     Mon Nov 30 20:58:42 2020        (r368196)
> K> > +++ head/sbin/bectl/bectl.c     Mon Nov 30 21:05:31 2020        (r368197)
> K> > @@ -584,8 +584,11 @@ main(int argc, char *argv[])
> K> >                 return (usage(false));
> K> >         }
> K> >
> K> > -       if ((be = libbe_init(root)) == NULL)
> K> > +       if ((be = libbe_init(root)) == NULL) {
> K> > +               fprintf(stderr, "libbe_init(\"%s\") failed.\n",
> K> > +                   root != NULL ? root : "");
> K> >                 return (-1);
> K> > +       }
> K> >
> K> >         libbe_print_on_error(be, !cmd->silent);
> K> >
> K>
> K> This should be gated on !cmd->silent, because some paths have
> K> consumers that are specifically designed to not have to deal with
> K> redirecting stderr. It was quite intentional that this didn't
> K> previously print anything.
>
> AFAIK, the only command that has cmd->silent is "check".
>
> I can't agree that it should suppress stderr in case of libbe_init()
> failure. Failure of the library is something different to failed
> check of current system. It is permanent failure, meaning that command
> is being with incorrect root argument or ZFS is missing at all. Pretty
> much the same as using bectl with incorrect arguments or options.
>

Hi,

The sole purpose of `bectl check` is to weed out if bectl will work
(i.e. if libbe_init succeeds) so that scripts like freebsd-update can
determine if they're running on a system or with a root (`bectl -r`)
that can work with boot environments. It is not meant to give
diagnostics like that upon failure, its sole purpose is to know if
your script should proceed with doing bectl-y things safely or if it
will just be fraught with peril.

Thanks,

Kyle Evans


More information about the svn-src-all mailing list