From owner-svn-soc-all@freebsd.org Thu Jun 22 07:26:05 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 D6608DA8229 for ; Thu, 22 Jun 2017 07:26:05 +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 C888C70DBD for ; Thu, 22 Jun 2017 07:26:05 +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 v5M7Q5FF010322 for ; Thu, 22 Jun 2017 07:26:05 GMT (envelope-from kneitinger@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.15.2/8.15.2/Submit) id v5M7Q5oi010318 for svn-soc-all@FreeBSD.org; Thu, 22 Jun 2017 07:26:05 GMT (envelope-from kneitinger@FreeBSD.org) Date: Thu, 22 Jun 2017 07:26:05 GMT Message-Id: <201706220726.v5M7Q5oi010318@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: r323831 - soc2017/kneitinger/libbe-head/sbin/be 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: Thu, 22 Jun 2017 07:26:05 -0000 Author: kneitinger Date: Thu Jun 22 07:26:04 2017 New Revision: 323831 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=323831 Log: Add parser for be mount and unmount commands Modified: soc2017/kneitinger/libbe-head/sbin/be/be.c Modified: soc2017/kneitinger/libbe-head/sbin/be/be.c ============================================================================== --- soc2017/kneitinger/libbe-head/sbin/be/be.c Thu Jun 22 06:25:34 2017 (r323830) +++ soc2017/kneitinger/libbe-head/sbin/be/be.c Thu Jun 22 07:26:04 2017 (r323831) @@ -315,7 +315,23 @@ static int be_mount(int argc, char *argv[]) { - return (EX_USAGE); + char *bootenv; + char *mountpoint; + + if (argc < 2) { + fprintf(stderr, "be mount: missing argument(s)\n"); + return (usage(false)); + } + + if (argc > 3) { + fprintf(stderr, "be rename: too many arguments\n"); + return (usage(false)); + } + + bootenv = argv[1]; + mountpoint = argc == 3 ? argv[2] : NULL; + + return (0); } @@ -352,7 +368,39 @@ static int be_unmount(int argc, char *argv[]) { - return (EX_USAGE); + int opt; + bool force; + char *cmd, *mountpoint; + + /* Store alias used */ + cmd = argv[0]; + + force = false; + while ((opt = getopt(argc, argv, "f")) != -1) { + switch (opt) { + case 'f': + force = true; + break; + default: + fprintf(stderr, "be %s: unknown option '-%c'\n", + cmd, optopt); + return (usage(false)); + } + } + + argc -= optind; + argv += optind; + + if (argc != 1) { + fprintf(stderr, "be %s: wrong number of arguments\n", cmd); + return (usage(false)); + } + + mountpoint = argv[0]; + + /* activate logic goes here */ + + return (0); }