1235537Sgber/*- 2235537Sgber * Copyright (c) 2012 The FreeBSD Foundation 3235537Sgber * All rights reserved. 4235537Sgber * 5235537Sgber * This software was developed by Semihalf under sponsorship 6235537Sgber * from the FreeBSD Foundation. 7235537Sgber * 8235537Sgber * Redistribution and use in source and binary forms, with or without 9235537Sgber * modification, are permitted provided that the following conditions 10235537Sgber * are met: 11235537Sgber * 12235537Sgber * 1. Redistributions of source code must retain the above copyright 13235537Sgber * notice, this list of conditions and the following disclaimer. 14235537Sgber * 2. Redistributions in binary form must reproduce the above copyright 15235537Sgber * notice, this list of conditions and the following disclaimer in the 16235537Sgber * documentation and/or other materials provided with the distribution. 17235537Sgber * 18235537Sgber * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 19235537Sgber * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 20235537Sgber * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 21235537Sgber * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 22235537Sgber * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 23235537Sgber * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 24235537Sgber * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 25235537Sgber * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 26235537Sgber * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 27235537Sgber * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 28235537Sgber * SUCH DAMAGE. 29235537Sgber */ 30235537Sgber 31235537Sgber#include <sys/cdefs.h> 32235537Sgber__FBSDID("$FreeBSD$"); 33235537Sgber 34235537Sgber#include <err.h> 35235537Sgber#include <stdio.h> 36235537Sgber#include <stdlib.h> 37235537Sgber#include <string.h> 38235537Sgber#include <sysexits.h> 39235537Sgber 40235537Sgber#include "nandfs.h" 41235537Sgber 42235537Sgberstatic void 43235537Sgberusage(void) 44235537Sgber{ 45235537Sgber 46235537Sgber fprintf(stderr, "usage: nandfs [lssnap | mksnap | rmsnap <snap>] " 47235537Sgber "node\n"); 48235537Sgber exit(1); 49235537Sgber} 50235537Sgber 51235537Sgberint 52235537Sgbermain(int argc, char **argv) 53235537Sgber{ 54235537Sgber int error = 0; 55235537Sgber char *cmd; 56235537Sgber 57235537Sgber if (argc < 2) 58235537Sgber usage(); 59235537Sgber 60235537Sgber cmd = argv[1]; 61235537Sgber argc -= 2; 62235537Sgber argv += 2; 63235537Sgber 64235537Sgber if (strcmp(cmd, "lssnap") == 0) 65235537Sgber error = nandfs_lssnap(argc, argv); 66235537Sgber else if (strcmp(cmd, "mksnap") == 0) 67235537Sgber error = nandfs_mksnap(argc, argv); 68235537Sgber else if (strcmp(cmd, "rmsnap") == 0) 69235537Sgber error = nandfs_rmsnap(argc, argv); 70235537Sgber else 71235537Sgber usage(); 72235537Sgber 73235537Sgber return (error); 74235537Sgber} 75