2
* Copyright (c) 2003-2005 Silicon Graphics, Inc. All Rights Reserved.
2
* Copyright (c) 2003-2005 Silicon Graphics, Inc.
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
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
6
7
* published by the Free Software Foundation.
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.
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.
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.
23
* Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
24
* Mountain View, CA 94043, or:
28
* For further information regarding this notice, see:
30
* http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
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
33
#include <xfs/libxfs.h>
20
#include <xfs/command.h>
21
#include <xfs/input.h>
84
if (index >= filecount)
86
file = &filetable[index++];
94
if (!file && !(ct->flags & CMD_NOFILE_OK)) {
95
fprintf(stderr, _("no files are open, try 'help open'\n"));
98
if (!mapping && !(ct->flags & CMD_NOMAP_OK)) {
99
fprintf(stderr, _("no mapped regions, try 'help mmap'\n"));
102
if (file && !(ct->flags & CMD_FOREIGN_OK) &&
103
(file->flags & IO_FOREIGN)) {
105
_("foreign file active, %s command is for XFS filesystems only\n"),
96
127
pagesize = getpagesize();
97
128
gettimeofday(&stopwatch, NULL);
99
while ((c = getopt(argc, argv, "ac:dFfmp:rRstVx")) != EOF) {
130
while ((c = getopt(argc, argv, "ac:dFfmp:nrRstVx")) != EOF) {
101
case 'a': /* append */
102
133
flags |= IO_APPEND;
104
case 'c': /* commands */
106
cmdline = realloc(cmdline, sizeof(char*) * (ncmdline));
111
cmdline[ncmdline-1] = optarg;
136
add_user_command(optarg);
114
139
flags |= IO_DIRECT;
173
int c, i, j, done = 0;
177
203
init(argc, argv);
179
for (i = 0; !done && i < ncmdline; i++) {
180
for (j = 0; !done && j < filecount; j++) {
181
file = &filetable[j];
182
v = breakline(cmdline[i], &c);
184
done = command(c, v);
193
if ((input = fetchline()) == NULL)
195
v = breakline(input, &c);
197
done = command(c, v);