]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/blame - db/init.c
Update copyright dates (again)
[thirdparty/xfsprogs-dev.git] / db / init.c
CommitLineData
2bd0ea18 1/*
0d3e0b37 2 * Copyright (c) 2000-2002 Silicon Graphics, Inc. All Rights Reserved.
2bd0ea18
NS
3 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of version 2 of the GNU General Public License as
6 * published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it would be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11 *
12 * Further, this software is distributed without any warranty that it is
13 * free of the rightful claim of any third person regarding infringement
14 * or the like. Any license provided herein, whether implied or
15 * otherwise, applies only to this software file. Patent licenses, if
16 * any, provided herein do not apply to combinations of this program with
17 * other software, or any other product whatsoever.
18 *
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write the Free Software Foundation, Inc., 59
21 * Temple Place - Suite 330, Boston MA 02111-1307, USA.
22 *
23 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
24 * Mountain View, CA 94043, or:
25 *
26 * http://www.sgi.com
27 *
28 * For further information regarding this notice, see:
29 *
30 * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
31 */
32
33#include <libxfs.h>
34#include <getopt.h>
35#include <signal.h>
36#include "command.h"
37#include "data.h"
38#include "init.h"
39#include "input.h"
40#include "io.h"
41#include "mount.h"
42#include "sig.h"
43#include "output.h"
c6b24b3b 44#include "malloc.h"
2bd0ea18
NS
45
46char *fsdevice;
c6b24b3b
NS
47char **cmdline;
48int ncmdline;
2bd0ea18
NS
49
50static void
51usage(void)
52{
53 dbprintf("Usage: %s [-c cmd]... [-p prog] [-l logdev] [-frxV] devname\n", progname);
54 exit(1);
55}
56
57void
58init(
c6b24b3b
NS
59 int argc,
60 char **argv)
2bd0ea18 61{
c6b24b3b 62 int c;
2bd0ea18
NS
63
64 progname = basename(argv[0]);
65 while ((c = getopt(argc, argv, "c:fip:rxVl:")) != EOF) {
66 switch (c) {
67 case 'c':
c6b24b3b
NS
68 cmdline = xrealloc(cmdline, (ncmdline+1)*sizeof(char*));
69 cmdline[ncmdline++] = optarg;
2bd0ea18
NS
70 break;
71 case 'f':
72 xfsargs.disfile = 1;
73 break;
74 case 'i':
75 xfsargs.isreadonly =
76 (LIBXFS_ISREADONLY | LIBXFS_ISINACTIVE);
77 flag_readonly = 1;
78 break;
79 case 'p':
80 progname = optarg;
81 break;
82 case 'r':
83 xfsargs.isreadonly = LIBXFS_ISREADONLY;
84 flag_readonly = 1;
85 break;
86 case 'l':
87 xfsargs.logname = optarg;
88 break;
89 case 'x':
90 flag_expert_mode = 1;
91 break;
92 case 'V':
93 printf("%s version %s\n", progname, VERSION);
3d98fe63 94 exit(0);
2bd0ea18
NS
95 case '?':
96 usage();
97 /*NOTREACHED*/
98 }
99 }
100 if (optind + 1 != argc) {
101 usage();
102 /*NOTREACHED*/
103 }
104 fsdevice = argv[optind];
105 if (!xfsargs.disfile)
106 xfsargs.volname = fsdevice;
107 else
108 xfsargs.dname = fsdevice;
109 xfsargs.notvolok = 1;
110 if (!libxfs_init(&xfsargs)) {
111 fputs("\nfatal error -- couldn't initialize XFS library\n",
112 stderr);
113 exit(1);
114 }
115 mp = dbmount();
116 if (mp == NULL) {
117 dbprintf("%s: %s is not a valid filesystem\n",
118 progname, fsdevice);
119 exit(1);
120 /*NOTREACHED*/
121 }
122 blkbb = 1 << mp->m_blkbb_log;
123 push_cur();
124 init_commands();
125 init_sig();
2bd0ea18 126}