xref: /freebsd/lib/libbe/tests/target_prog.c (revision 1d386b48a555f61cb7325543adbbb5c3f3407a66)
1cddbc3b4SKyle Evans /*-
2*4d846d26SWarner Losh  * SPDX-License-Identifier: BSD-2-Clause
3cddbc3b4SKyle Evans  *
4cddbc3b4SKyle Evans  * Copyright (c) 2019 Rob Wing
5cddbc3b4SKyle Evans  *
6cddbc3b4SKyle Evans  * Redistribution and use in source and binary forms, with or without
7cddbc3b4SKyle Evans  * modification, are permitted provided that the following conditions
8cddbc3b4SKyle Evans  * are met:
9cddbc3b4SKyle Evans  * 1. Redistributions of source code must retain the above copyright
10cddbc3b4SKyle Evans  *    notice, this list of conditions and the following disclaimer.
11cddbc3b4SKyle Evans  * 2. Redistributions in binary form must reproduce the above copyright
12cddbc3b4SKyle Evans  *    notice, this list of conditions and the following disclaimer in the
13cddbc3b4SKyle Evans  *    documentation and/or other materials provided with the distribution.
14cddbc3b4SKyle Evans  *
15cddbc3b4SKyle Evans  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
16cddbc3b4SKyle Evans  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17cddbc3b4SKyle Evans  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18cddbc3b4SKyle Evans  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
19cddbc3b4SKyle Evans  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20cddbc3b4SKyle Evans  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21cddbc3b4SKyle Evans  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22cddbc3b4SKyle Evans  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23cddbc3b4SKyle Evans  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24cddbc3b4SKyle Evans  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25cddbc3b4SKyle Evans  * SUCH DAMAGE.
26cddbc3b4SKyle Evans  */
27cddbc3b4SKyle Evans 
28cddbc3b4SKyle Evans #include <sys/cdefs.h>
29cddbc3b4SKyle Evans #include <be.h>
30cddbc3b4SKyle Evans 
31cddbc3b4SKyle Evans /*
32cddbc3b4SKyle Evans  * argv[1] = root boot environment (e.g. zroot/ROOT),
33cddbc3b4SKyle Evans  * argv[2] = name of boot environment to create
34cddbc3b4SKyle Evans  * argv[3] = snapshot to create boot environment from
35cddbc3b4SKyle Evans  * argv[4] = depth
36cddbc3b4SKyle Evans  */
main(int argc,char * argv[])37cddbc3b4SKyle Evans int main(int argc, char *argv[]) {
38cddbc3b4SKyle Evans 
39cddbc3b4SKyle Evans         libbe_handle_t *lbh;
40cddbc3b4SKyle Evans 
41cddbc3b4SKyle Evans 	if (argc != 5)
42cddbc3b4SKyle Evans 		return -1;
43cddbc3b4SKyle Evans 
44cddbc3b4SKyle Evans         if ((lbh = libbe_init(argv[1])) == NULL)
45cddbc3b4SKyle Evans                 return -1;
46cddbc3b4SKyle Evans 
47cddbc3b4SKyle Evans 	libbe_print_on_error(lbh, true);
48cddbc3b4SKyle Evans 
49cddbc3b4SKyle Evans 	return (be_create_depth(lbh, argv[2], argv[3], atoi(argv[4])));
50cddbc3b4SKyle Evans }
51