svn commit: r368197 - head/sbin/bectl

Kyle Evans kevans at freebsd.org
Wed Dec 2 19:14:30 UTC 2020


On Wed, Dec 2, 2020 at 1:12 PM Gleb Smirnoff <glebius at freebsd.org> wrote:
>
>   Kyle,
>
> On Wed, Dec 02, 2020 at 12:08:43PM -0600, Kyle Evans wrote:
> K> > K> This should be gated on !cmd->silent, because some paths have
> K> > K> consumers that are specifically designed to not have to deal with
> K> > K> redirecting stderr. It was quite intentional that this didn't
> K> > K> previously print anything.
> K> >
> K> > AFAIK, the only command that has cmd->silent is "check".
> K> >
> K> > I can't agree that it should suppress stderr in case of libbe_init()
> K> > failure. Failure of the library is something different to failed
> K> > check of current system. It is permanent failure, meaning that command
> K> > is being with incorrect root argument or ZFS is missing at all. Pretty
> K> > much the same as using bectl with incorrect arguments or options.
> K> >
> K>
> K> The sole purpose of `bectl check` is to weed out if bectl will work
> K> (i.e. if libbe_init succeeds) so that scripts like freebsd-update can
> K> determine if they're running on a system or with a root (`bectl -r`)
> K> that can work with boot environments. It is not meant to give
> K> diagnostics like that upon failure, its sole purpose is to know if
> K> your script should proceed with doing bectl-y things safely or if it
> K> will just be fraught with peril.
>
> Understood. Sorry for my mistake. Is this patch a correct one?
>
> Index: bectl.c
> ===================================================================
> --- bectl.c     (revision 368197)
> +++ bectl.c     (working copy)
> @@ -585,8 +585,9 @@ main(int argc, char *argv[])
>         }
>
>         if ((be = libbe_init(root)) == NULL) {
> -               fprintf(stderr, "libbe_init(\"%s\") failed.\n",
> -                   root != NULL ? root : "");
> +               if (!cmd->silent)
> +                       fprintf(stderr, "libbe_init(\"%s\") failed.\n",
> +                           root != NULL ? root : "");
>                 return (-1);
>         }
>

Yup, looks good to me! Thanks! :-)


More information about the svn-src-all mailing list