/*-1* SPDX-License-Identifier: BSD-2-Clause2*3* Copyright (c) 2022 NetApp, Inc.4*5* Redistribution and use in source and binary forms, with or without6* modification, are permitted provided that the following conditions7* are met:8* 1. Redistributions of source code must retain the above copyright9* notice, this list of conditions and the following disclaimer.10* 2. Redistributions in binary form must reproduce the above copyright11* notice, this list of conditions and the following disclaimer in the12* documentation and/or other materials provided with the distribution.13*14* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND15* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE16* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE17* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE18* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL19* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS20* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)21* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT22* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY23* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF24* SUCH DAMAGE.25*/2627#include <sys/types.h>28#include <sys/boottrace.h>29#include <sys/sysctl.h>30#include <sys/wait.h>3132#include <err.h>33#include <errno.h>34#include <stdio.h>35#include <stdlib.h>36#include <string.h>37#include <unistd.h>3839static void40usage(void)41{42fprintf(stderr, "usage: boottrace utility [argument ...]\n");43exit(1);44}4546int47main(int argc, char **argv)48{49pid_t pid;50int status;5152if (argc < 2)53usage();54argv++;5556BOOTTRACE("%s start", *argv);57pid = fork();58if (pid == -1) {59exit(1);60} else if (pid == 0) {61execvp(*argv, argv);62err(errno == ENOENT ? 127 : 126, "execvp %s", *argv);63}64waitpid(pid, &status, 0);65if (!WIFEXITED(status))66warnx("command terminated abnormally");67BOOTTRACE("%s done", *argv);6869return (WIFEXITED(status) ? WEXITSTATUS(status) : EXIT_FAILURE);70}717273