2 * Copyright (c) 2004 Silicon Graphics, Inc. All Rights Reserved.
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.
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/
33 #include <xfs/libxfs.h>
34 #include <xfs/command.h>
35 #include <xfs/input.h>
39 static cmdinfo_t inject_cmd
;
48 #define XFS_ERRTAG_NOERROR 0
49 { XFS_ERRTAG_NOERROR
, "noerror" },
50 #define XFS_ERRTAG_IFLUSH_1 1
51 { XFS_ERRTAG_IFLUSH_1
, "iflush1" },
52 #define XFS_ERRTAG_IFLUSH_2 2
53 { XFS_ERRTAG_IFLUSH_2
, "iflush2" },
54 #define XFS_ERRTAG_IFLUSH_3 3
55 { XFS_ERRTAG_IFLUSH_3
, "iflush3" },
56 #define XFS_ERRTAG_IFLUSH_4 4
57 { XFS_ERRTAG_IFLUSH_4
, "iflush4" },
58 #define XFS_ERRTAG_IFLUSH_5 5
59 { XFS_ERRTAG_IFLUSH_5
, "iflush5" },
60 #define XFS_ERRTAG_IFLUSH_6 6
61 { XFS_ERRTAG_IFLUSH_6
, "iflush6" },
62 #define XFS_ERRTAG_DA_READ_BUF 7
63 { XFS_ERRTAG_DA_READ_BUF
, "dareadbuf" },
64 #define XFS_ERRTAG_BTREE_CHECK_LBLOCK 8
65 { XFS_ERRTAG_BTREE_CHECK_LBLOCK
, "btree_chk_lblk" },
66 #define XFS_ERRTAG_BTREE_CHECK_SBLOCK 9
67 { XFS_ERRTAG_BTREE_CHECK_SBLOCK
, "btree_chk_sblk" },
68 #define XFS_ERRTAG_ALLOC_READ_AGF 10
69 { XFS_ERRTAG_ALLOC_READ_AGF
, "readagf" },
70 #define XFS_ERRTAG_IALLOC_READ_AGI 11
71 { XFS_ERRTAG_IALLOC_READ_AGI
, "readagi" },
72 #define XFS_ERRTAG_ITOBP_INOTOBP 12
73 { XFS_ERRTAG_ITOBP_INOTOBP
, "itobp" },
74 #define XFS_ERRTAG_IUNLINK 13
75 { XFS_ERRTAG_IUNLINK
, "iunlink" },
76 #define XFS_ERRTAG_IUNLINK_REMOVE 14
77 { XFS_ERRTAG_IUNLINK_REMOVE
, "iunlinkrm" },
78 #define XFS_ERRTAG_DIR_INO_VALIDATE 15
79 { XFS_ERRTAG_DIR_INO_VALIDATE
, "dirinovalid" },
80 #define XFS_ERRTAG_BULKSTAT_READ_CHUNK 16
81 { XFS_ERRTAG_BULKSTAT_READ_CHUNK
, "bulkstat" },
82 #define XFS_ERRTAG_IODONE_IOERR 17
83 { XFS_ERRTAG_IODONE_IOERR
, "logiodone" },
84 #define XFS_ERRTAG_STRATREAD_IOERR 18
85 { XFS_ERRTAG_STRATREAD_IOERR
, "stratread" },
86 #define XFS_ERRTAG_STRATCMPL_IOERR 19
87 { XFS_ERRTAG_STRATCMPL_IOERR
, "stratcmpl" },
88 #define XFS_ERRTAG_DIOWRITE_IOERR 20
89 { XFS_ERRTAG_DIOWRITE_IOERR
, "diowrite" },
90 #define XFS_ERRTAG_BMAPIFORMAT 21
91 { XFS_ERRTAG_BMAPIFORMAT
, "bmapifmt" },
92 #define XFS_ERRTAG_MAX 22
93 { XFS_ERRTAG_MAX
, NULL
}
97 /* Search for a name */
99 for (e
= eflags
; e
->name
; e
++)
100 if (strcmp(name
, e
->name
) == 0)
105 /* Dump all the names */
106 fputs("tags: [ ", stdout
);
107 for (count
= 0, e
= eflags
; e
->name
; e
++, count
++) {
111 fputs("\n\t", stdout
);
113 fputs(e
->name
, stdout
);
115 fputs(" ]\n", stdout
);
124 " inject errors into the filesystem of the currently open file\n"
127 " 'inject readagf' - cause errors on allocation group freespace reads\n"
129 " Causes the kernel to generate and react to errors within XFS, provided\n"
130 " the XFS kernel code has been built with debugging features enabled.\n"
131 " With no arguments, displays the list of error injection tags.\n"
140 xfs_error_injection_t error
;
141 int command
= XFS_IOC_ERROR_INJECTION
;
144 return error_tag(NULL
);
148 if ((error
.errtag
= error_tag(argv
[argc
])) < 0) {
149 fprintf(stderr
, _("no such tag -- %s\n"), argv
[1]);
152 if (error
.errtag
== XFS_ERRTAG_NOERROR
)
153 command
= XFS_IOC_ERROR_CLEARALL
;
154 if ((xfsctl(file
->name
, file
->fd
, command
, &error
)) < 0) {
155 perror("XFS_IOC_ERROR_INJECTION");
165 inject_cmd
.name
= _("inject");
166 inject_cmd
.cfunc
= inject_f
;
167 inject_cmd
.argmin
= 0;
168 inject_cmd
.argmax
= -1;
169 inject_cmd
.flags
= CMD_NOMAP_OK
;
170 inject_cmd
.args
= _("[tag ...]");
171 inject_cmd
.oneline
= _("inject errors into a filesystem");
172 inject_cmd
.help
= inject_help
;
175 add_command(&inject_cmd
);