]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/blob - include/command.h
xfs: account only rmapbt-used blocks against rmapbt perag res
[thirdparty/xfsprogs-dev.git] / include / command.h
1 /*
2 * Copyright (c) 2000-2005 Silicon Graphics, Inc.
3 * All Rights Reserved.
4 *
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.
8 *
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.
13 *
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
17 */
18 #ifndef __COMMAND_H__
19 #define __COMMAND_H__
20
21 #include <sys/time.h>
22
23 /*
24 * A "oneshot" command ony runs once per command execution. It does
25 * not iterate the command args function callout and so can be used
26 * for functions like "help" that should only ever be run once.
27 */
28 #define CMD_FLAG_ONESHOT (1u << 31)
29 #define CMD_FLAG_FOREIGN_OK (1u << 30) /* command not restricted to XFS */
30 #define CMD_FLAG_LIBRARY (1u << 29) /* command provided by libxcmd */
31
32 typedef int (*cfunc_t)(int argc, char **argv);
33 typedef void (*helpfunc_t)(void);
34
35 typedef struct cmdinfo {
36 const char *name;
37 const char *altname;
38 cfunc_t cfunc;
39 int argmin;
40 int argmax;
41 int canpush;
42 int flags;
43 const char *args;
44 const char *oneline;
45 helpfunc_t help;
46 } cmdinfo_t;
47
48 extern cmdinfo_t *cmdtab;
49 extern int ncmds;
50
51 extern void help_init(void);
52 extern void quit_init(void);
53
54 typedef int (*iterfunc_t)(int index);
55 typedef int (*checkfunc_t)(const cmdinfo_t *ci);
56
57 extern void add_command(const cmdinfo_t *ci);
58 extern void add_user_command(char *optarg);
59 extern void add_oneshot_user_command(char *optarg);
60 extern void add_command_iterator(iterfunc_t func);
61 extern void add_check_command(checkfunc_t cf);
62
63 extern const cmdinfo_t *find_command(const char *cmd);
64
65 extern void command_loop(void);
66 extern int command_usage(const cmdinfo_t *ci);
67 extern int command(const cmdinfo_t *ci, int argc, char **argv);
68
69 extern void report_io_times(const char *verb, struct timeval *t2,
70 long long offset, long long count,
71 long long total, int ops, int compact);
72
73 #endif /* __COMMAND_H__ */