]>
git.ipfire.org Git - thirdparty/xfsprogs-dev.git/blob - io/init.c
2 * Copyright (c) 2003-2005 Silicon Graphics, Inc.
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License as
7 * published by the Free Software Foundation.
9 * This program is distributed in the hope that it would be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write the Free Software Foundation,
16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19 #include "platform_defs.h"
29 struct timeval stopwatch
;
35 _("Usage: %s [-adfmnrRstVx] [-p prog] [-c cmd]... file\n"),
45 if (!file
|| (file
->flags
& IO_FOREIGN
)) {
49 *blocksize
= file
->geom
.blocksize
;
50 *sectsize
= file
->geom
.sectsize
;
94 if (index
>= filecount
)
96 file
= &filetable
[index
++];
104 if (ct
->flags
& CMD_FLAG_GLOBAL
)
107 if (!file
&& !(ct
->flags
& CMD_NOFILE_OK
)) {
108 fprintf(stderr
, _("no files are open, try 'help open'\n"));
111 if (!mapping
&& !(ct
->flags
& CMD_NOMAP_OK
)) {
112 fprintf(stderr
, _("no mapped regions, try 'help mmap'\n"));
115 if (file
&& !(ct
->flags
& CMD_FOREIGN_OK
) &&
116 (file
->flags
& IO_FOREIGN
)) {
118 _("foreign file active, %s command is for XFS filesystems only\n"),
133 xfs_fsop_geom_t geometry
= { 0 };
135 progname
= basename(argv
[0]);
136 setlocale(LC_ALL
, "");
137 bindtextdomain(PACKAGE
, LOCALEDIR
);
140 pagesize
= getpagesize();
141 gettimeofday(&stopwatch
, NULL
);
143 while ((c
= getopt(argc
, argv
, "ac:dFfmp:nrRstTVx")) != EOF
) {
149 add_user_command(optarg
);
155 /* Ignored / deprecated now, handled automatically */
161 mode
= strtoul(optarg
, &sp
, 0);
162 if (!sp
|| sp
== optarg
) {
163 fprintf(stderr
, _("non-numeric mode -- %s\n"),
169 flags
|= IO_NONBLOCK
;
175 flags
|= IO_READONLY
;
184 flags
|= IO_REALTIME
;
193 printf(_("%s version %s\n"), progname
, VERSION
);
200 while (optind
< argc
) {
201 if ((c
= openfile(argv
[optind
], &geometry
, flags
, mode
)) < 0)
203 if (!platform_test_xfs_fd(c
))
205 if (addfile(argv
[optind
], c
, &geometry
, flags
) < 0)
211 add_args_command(init_args_command
);
212 add_check_command(init_check_command
);