Date: Sun, 23 Jul 2017 07:42:33 GMT From: kneitinger@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r325005 - soc2017/kneitinger/libbe-head/sbin/be Message-ID: <201707230742.v6N7gXdN073291@socsvn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: kneitinger Date: Sun Jul 23 07:42:33 2017 New Revision: 325005 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=325005 Log: be(1): remove dependence on libzfs which cannot be included with src. Clean up add/rename/mount/unmount error reporting and structure. Modified: soc2017/kneitinger/libbe-head/sbin/be/Makefile soc2017/kneitinger/libbe-head/sbin/be/be.c Modified: soc2017/kneitinger/libbe-head/sbin/be/Makefile ============================================================================== --- soc2017/kneitinger/libbe-head/sbin/be/Makefile Sun Jul 23 06:33:58 2017 (r325004) +++ soc2017/kneitinger/libbe-head/sbin/be/Makefile Sun Jul 23 07:42:33 2017 (r325005) @@ -5,21 +5,5 @@ MAN= be.1 LIBADD+= be -LIBADD+= nvpair - -CFLAGS+= -I${SRCTOP}/lib/libbe - -CFLAGS+= -I${SRCTOP}/cddl/compat/opensolaris/include -CFLAGS+= -I${SRCTOP}/cddl/compat/opensolaris/lib/libumem -CFLAGS+= -I${SRCTOP}/cddl/contrib/opensolaris/lib/libzfs/common -CFLAGS+= -I${SRCTOP}/cddl/contrib/opensolaris/lib/libzfs_core/common -CFLAGS+= -I${SRCTOP}/cddl/contrib/opensolaris/lib/libzpool/common -CFLAGS+= -I${SRCTOP}/cddl/contrib/opensolaris/lib/libnvpair -CFLAGS+= -I${SRCTOP}/sys/cddl/compat/opensolaris -CFLAGS+= -I${SRCTOP}/sys/cddl/contrib/opensolaris/uts/common/fs/zfs -CFLAGS+= -I${SRCTOP}/sys/cddl/contrib/opensolaris/uts/common -CFLAGS+= -I${SRCTOP}/cddl/contrib/opensolaris/head - -CFLAGS+= -DNEED_SOLARIS_BOOLEAN .include <bsd.prog.mk> Modified: soc2017/kneitinger/libbe-head/sbin/be/be.c ============================================================================== --- soc2017/kneitinger/libbe-head/sbin/be/be.c Sun Jul 23 06:33:58 2017 (r325004) +++ soc2017/kneitinger/libbe-head/sbin/be/be.c Sun Jul 23 07:42:33 2017 (r325005) @@ -33,8 +33,6 @@ #include <sysexits.h> #include <unistd.h> -#include <libnvpair.h> - #include <be.h> static int be_cmd_activate(int argc, char *argv[]); @@ -189,8 +187,17 @@ } switch (err) { + case BE_ERR_SUCCESS: + break; default: - fprintf(stderr, "TODO FILL IN"); + if (existing == NULL) { + fprintf(stderr, + "failed to create bootenv %s\n", bootenv); + } else { + fprintf(stderr, + "failed to create bootenv %s from snapshot %s\n", + bootenv, existing); + } } return (err); @@ -227,6 +234,7 @@ } /* Determine bootenv name, and snapshot if provided */ + /* TODO: Handle be snapshot destroy */ char *buffer = malloc((strlen(argv[0])+1) * sizeof(char)); strcpy(buffer, argv[0]); char *delimiter; @@ -314,14 +322,10 @@ static int be_cmd_mount(int argc, char *argv[]) { - int err, flags; + int err; char *bootenv; char *mountpoint; - // TODO: force flag? - - flags = 0; - if (argc < 2) { fprintf(stderr, "be mount: missing argument(s)\n"); return (usage(false)); @@ -333,17 +337,22 @@ } bootenv = argv[1]; - mountpoint = argc == 3 ? argv[2] : NULL; + mountpoint = ((argc == 3) ? argv[2] : NULL); - err = be_mount(be, bootenv, mountpoint, flags); + err = be_mount(be, bootenv, mountpoint, 0); switch (err) { - BE_ERR_SUCCESS: - return (0); + case BE_ERR_SUCCESS: + break; + default: + fprintf(stderr, + (argc == 3) ? "failed to mount bootenv %s at %s\n" : + "failed to mount bootenv %s at temporary path %s\n", + bootenv, mountpoint); } - return (0); + return (err); } @@ -370,8 +379,11 @@ err = be_rename(be, src, dest); switch (err) { - BE_ERR_SUCCESS: - return (0); + case BE_ERR_SUCCESS: + break; + default: + fprintf(stderr, "failed to rename bootenv %s to %s\n", + src, dest); } return (0); @@ -452,11 +464,13 @@ err = be_unmount(be, bootenv, flags); switch (err) { + case BE_ERR_SUCCESS: + break; default: - fprintf(stderr, "TODO FILL ME IN"); + fprintf(stderr, "failed to unmount bootenv %s\n", bootenv); } - return (0); + return (err); }
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201707230742.v6N7gXdN073291>