From owner-svn-src-head@freebsd.org Wed Dec 2 18:08:57 2020 Return-Path: Delivered-To: svn-src-head@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id E11214A285D; Wed, 2 Dec 2020 18:08:57 +0000 (UTC) (envelope-from kevans@freebsd.org) Received: from smtp.freebsd.org (smtp.freebsd.org [96.47.72.83]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "smtp.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4CmRmn62mHz3Nd2; Wed, 2 Dec 2020 18:08:57 +0000 (UTC) (envelope-from kevans@freebsd.org) Received: from mail-qk1-f180.google.com (mail-qk1-f180.google.com [209.85.222.180]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "GTS CA 1O1" (verified OK)) (Authenticated sender: kevans) by smtp.freebsd.org (Postfix) with ESMTPSA id BC9B826C77; Wed, 2 Dec 2020 18:08:57 +0000 (UTC) (envelope-from kevans@freebsd.org) Received: by mail-qk1-f180.google.com with SMTP id h20so2123536qkk.4; Wed, 02 Dec 2020 10:08:57 -0800 (PST) X-Gm-Message-State: AOAM530bS91lHiMpvwcjVp5AWKN73SsWPWX3wF3Di8tbeopie70cclCE dDEh7xMYre8hcPhvhtxpzEm21h05wTU6770h8Qk= X-Google-Smtp-Source: ABdhPJw4O3kSHT5RqdjHQuaYDY41B2dI4jTP4W01UHf8WwoligPYE5LLP2yWWrUKTcW1+NjClso1sGmsXfKBjzU1ofw= X-Received: by 2002:a37:ef05:: with SMTP id j5mr3885128qkk.120.1606932537353; Wed, 02 Dec 2020 10:08:57 -0800 (PST) MIME-Version: 1.0 References: <202011302105.0AUL5VHd035423@repo.freebsd.org> <20201202180159.GC69850@FreeBSD.org> In-Reply-To: <20201202180159.GC69850@FreeBSD.org> From: Kyle Evans Date: Wed, 2 Dec 2020 12:08:43 -0600 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: svn commit: r368197 - head/sbin/bectl To: Gleb Smirnoff Cc: src-committers , svn-src-all , svn-src-head Content-Type: text/plain; charset="UTF-8" X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 02 Dec 2020 18:08:57 -0000 On Wed, Dec 2, 2020 at 12:02 PM Gleb Smirnoff 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