From owner-svn-soc-all@freebsd.org Tue Jun 27 04:22:22 2017 Return-Path: Delivered-To: svn-soc-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 37C82D9F0CE for ; Tue, 27 Jun 2017 04:22:22 +0000 (UTC) (envelope-from kneitinger@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 29D7E79B44 for ; Tue, 27 Jun 2017 04:22:22 +0000 (UTC) (envelope-from kneitinger@FreeBSD.org) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.15.2/8.15.2) with ESMTP id v5R4MMoQ047247 for ; Tue, 27 Jun 2017 04:22:22 GMT (envelope-from kneitinger@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.15.2/8.15.2/Submit) id v5R4MLe6047243 for svn-soc-all@FreeBSD.org; Tue, 27 Jun 2017 04:22:21 GMT (envelope-from kneitinger@FreeBSD.org) Date: Tue, 27 Jun 2017 04:22:21 GMT Message-Id: <201706270422.v5R4MLe6047243@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to kneitinger@FreeBSD.org using -f From: kneitinger@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r324008 - soc2017/kneitinger/libbe-head/lib/libbe MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 27 Jun 2017 04:22:22 -0000 Author: kneitinger Date: Tue Jun 27 04:22:20 2017 New Revision: 324008 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=324008 Log: Add libbe functions for getting the name/path oft he active bootenv, and the path of the root bootenv dataset Modified: soc2017/kneitinger/libbe-head/lib/libbe/be.c soc2017/kneitinger/libbe-head/lib/libbe/be.h Modified: soc2017/kneitinger/libbe-head/lib/libbe/be.c ============================================================================== --- soc2017/kneitinger/libbe-head/lib/libbe/be.c Tue Jun 27 03:57:31 2017 (r324007) +++ soc2017/kneitinger/libbe-head/lib/libbe/be.c Tue Jun 27 04:22:20 2017 (r324008) @@ -128,3 +128,35 @@ libzfs_fini(lbh->lzh); free(lbh); } + + +/* + * Returns the name of the active boot environment + */ +const char * +be_get_active_name(libbe_handle_t *lbh) +{ + const char *full_path = zfs_get_name(lbh->be_active); + + return (strrchr(full_path, '/') + 1); +} + + +/* + * Returns full path of the active boot environment + */ +const char * +be_get_active_path(libbe_handle_t *lbh) +{ + return (zfs_get_name(lbh->be_active)); +} + + +/* + * Returns the path of the boot environment root dataset + */ +const char * +be_get_root_path(libbe_handle_t *lbh) +{ + return (zfs_get_name(lbh->be_root)); +} Modified: soc2017/kneitinger/libbe-head/lib/libbe/be.h ============================================================================== --- soc2017/kneitinger/libbe-head/lib/libbe/be.h Tue Jun 27 03:57:31 2017 (r324007) +++ soc2017/kneitinger/libbe-head/lib/libbe/be.h Tue Jun 27 04:22:20 2017 (r324008) @@ -56,6 +56,13 @@ libbe_handle_t *libbe_init(void); void libbe_close(libbe_handle_t *); +/* Bootenv information functions */ +const char *be_get_active_name(libbe_handle_t *); +const char *be_get_active_path(libbe_handle_t *); +const char *be_get_root_path(libbe_handle_t *); + +/* Bootenv manipulation functions */ + /* Error related functions */ int libbe_errno(libbe_handle_t *);