2 * Copyright (c) 2004-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
25 static cmdinfo_t inject_cmd
;
34 #define XFS_ERRTAG_NOERROR 0
35 { XFS_ERRTAG_NOERROR
, "noerror" },
36 #define XFS_ERRTAG_IFLUSH_1 1
37 { XFS_ERRTAG_IFLUSH_1
, "iflush1" },
38 #define XFS_ERRTAG_IFLUSH_2 2
39 { XFS_ERRTAG_IFLUSH_2
, "iflush2" },
40 #define XFS_ERRTAG_IFLUSH_3 3
41 { XFS_ERRTAG_IFLUSH_3
, "iflush3" },
42 #define XFS_ERRTAG_IFLUSH_4 4
43 { XFS_ERRTAG_IFLUSH_4
, "iflush4" },
44 #define XFS_ERRTAG_IFLUSH_5 5
45 { XFS_ERRTAG_IFLUSH_5
, "iflush5" },
46 #define XFS_ERRTAG_IFLUSH_6 6
47 { XFS_ERRTAG_IFLUSH_6
, "iflush6" },
48 #define XFS_ERRTAG_DA_READ_BUF 7
49 { XFS_ERRTAG_DA_READ_BUF
, "dareadbuf" },
50 #define XFS_ERRTAG_BTREE_CHECK_LBLOCK 8
51 { XFS_ERRTAG_BTREE_CHECK_LBLOCK
, "btree_chk_lblk" },
52 #define XFS_ERRTAG_BTREE_CHECK_SBLOCK 9
53 { XFS_ERRTAG_BTREE_CHECK_SBLOCK
, "btree_chk_sblk" },
54 #define XFS_ERRTAG_ALLOC_READ_AGF 10
55 { XFS_ERRTAG_ALLOC_READ_AGF
, "readagf" },
56 #define XFS_ERRTAG_IALLOC_READ_AGI 11
57 { XFS_ERRTAG_IALLOC_READ_AGI
, "readagi" },
58 #define XFS_ERRTAG_ITOBP_INOTOBP 12
59 { XFS_ERRTAG_ITOBP_INOTOBP
, "itobp" },
60 #define XFS_ERRTAG_IUNLINK 13
61 { XFS_ERRTAG_IUNLINK
, "iunlink" },
62 #define XFS_ERRTAG_IUNLINK_REMOVE 14
63 { XFS_ERRTAG_IUNLINK_REMOVE
, "iunlinkrm" },
64 #define XFS_ERRTAG_DIR_INO_VALIDATE 15
65 { XFS_ERRTAG_DIR_INO_VALIDATE
, "dirinovalid" },
66 #define XFS_ERRTAG_BULKSTAT_READ_CHUNK 16
67 { XFS_ERRTAG_BULKSTAT_READ_CHUNK
, "bulkstat" },
68 #define XFS_ERRTAG_IODONE_IOERR 17
69 { XFS_ERRTAG_IODONE_IOERR
, "logiodone" },
70 #define XFS_ERRTAG_STRATREAD_IOERR 18
71 { XFS_ERRTAG_STRATREAD_IOERR
, "stratread" },
72 #define XFS_ERRTAG_STRATCMPL_IOERR 19
73 { XFS_ERRTAG_STRATCMPL_IOERR
, "stratcmpl" },
74 #define XFS_ERRTAG_DIOWRITE_IOERR 20
75 { XFS_ERRTAG_DIOWRITE_IOERR
, "diowrite" },
76 #define XFS_ERRTAG_BMAPIFORMAT 21
77 { XFS_ERRTAG_BMAPIFORMAT
, "bmapifmt" },
78 #define XFS_ERRTAG_MAX 22
79 { XFS_ERRTAG_MAX
, NULL
}
83 /* Search for a name */
85 for (e
= eflags
; e
->name
; e
++)
86 if (strcmp(name
, e
->name
) == 0)
91 /* Dump all the names */
92 fputs("tags: [ ", stdout
);
93 for (count
= 0, e
= eflags
; e
->name
; e
++, count
++) {
97 fputs("\n\t", stdout
);
99 fputs(e
->name
, stdout
);
101 fputs(" ]\n", stdout
);
110 " inject errors into the filesystem of the currently open file\n"
113 " 'inject readagf' - cause errors on allocation group freespace reads\n"
115 " Causes the kernel to generate and react to errors within XFS, provided\n"
116 " the XFS kernel code has been built with debugging features enabled.\n"
117 " With no arguments, displays the list of error injection tags.\n"
126 xfs_error_injection_t error
;
127 int command
= XFS_IOC_ERROR_INJECTION
;
130 return error_tag(NULL
);
134 if ((error
.errtag
= error_tag(argv
[argc
])) < 0) {
135 fprintf(stderr
, _("no such tag -- %s\n"), argv
[1]);
138 if (error
.errtag
== XFS_ERRTAG_NOERROR
)
139 command
= XFS_IOC_ERROR_CLEARALL
;
140 if ((xfsctl(file
->name
, file
->fd
, command
, &error
)) < 0) {
141 perror("XFS_IOC_ERROR_INJECTION");
151 inject_cmd
.name
= "inject";
152 inject_cmd
.cfunc
= inject_f
;
153 inject_cmd
.argmin
= 0;
154 inject_cmd
.argmax
= -1;
155 inject_cmd
.flags
= CMD_NOMAP_OK
;
156 inject_cmd
.args
= _("[tag ...]");
157 inject_cmd
.oneline
= _("inject errors into a filesystem");
158 inject_cmd
.help
= inject_help
;
161 add_command(&inject_cmd
);