1 /* 2 * Copyright (c) 2019 Tomohiro Kusumi <tkusumi@netbsd.org> 3 * Copyright (c) 2019 The DragonFly Project 4 * All rights reserved. 5 * 6 * This code is derived from software contributed to The DragonFly Project 7 * by Matthew Dillon <dillon@dragonflybsd.org> 8 * 9 * Redistribution and use in source and binary forms, with or without 10 * modification, are permitted provided that the following conditions 11 * are met: 12 * 13 * 1. Redistributions of source code must retain the above copyright 14 * notice, this list of conditions and the following disclaimer. 15 * 2. Redistributions in binary form must reproduce the above copyright 16 * notice, this list of conditions and the following disclaimer in 17 * the documentation and/or other materials provided with the 18 * distribution. 19 * 3. Neither the name of The DragonFly Project nor the names of its 20 * contributors may be used to endorse or promote products derived 21 * from this software without specific, prior written permission. 22 * 23 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 24 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 25 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 26 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 27 * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 28 * INCIDENTAL, SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING, 29 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 30 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 31 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 32 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 33 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 34 * SUCH DAMAGE. 35 */ 36 37 #include <unistd.h> 38 #include <stdio.h> 39 #include <stdlib.h> 40 41 #include "fsck_hammer2.h" 42 43 int DebugOpt; 44 int ForceOpt; 45 int VerboseOpt; 46 int QuietOpt; 47 int ScanBest; 48 int ScanPFS; 49 const char *PFSName; 50 51 static void 52 usage(void) 53 { 54 fprintf(stderr, "fsck_hammer2 [-f] [-v] [-q] [-b] [-p] [-l pfs_name] " 55 "special\n"); 56 exit(1); 57 } 58 59 int 60 main(int ac, char **av) 61 { 62 int ch; 63 64 while ((ch = getopt(ac, av, "dfvqbpl:")) != -1) { 65 switch(ch) { 66 case 'd': 67 DebugOpt = 1; 68 break; 69 case 'f': 70 ForceOpt = 1; 71 break; 72 case 'v': 73 if (QuietOpt) 74 --QuietOpt; 75 else 76 ++VerboseOpt; 77 break; 78 case 'q': 79 if (VerboseOpt) 80 --VerboseOpt; 81 else 82 ++QuietOpt; 83 break; 84 case 'b': 85 ScanBest = 1; 86 break; 87 case 'p': 88 ScanPFS = 1; 89 break; 90 case 'l': 91 PFSName = optarg; 92 break; 93 default: 94 usage(); 95 /* not reached */ 96 break; 97 } 98 } 99 100 ac -= optind; 101 av += optind; 102 if (ac < 1) { 103 usage(); 104 /* not reached */ 105 } 106 107 if (test_hammer2(av[0]) == -1) 108 exit(1); 109 110 return 0; 111 } 112