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
24 static cmdinfo_t inject_cmd
;
33 #define XFS_ERRTAG_NOERROR 0
34 { XFS_ERRTAG_NOERROR
, "noerror" },
35 #define XFS_ERRTAG_IFLUSH_1 1
36 { XFS_ERRTAG_IFLUSH_1
, "iflush1" },
37 #define XFS_ERRTAG_IFLUSH_2 2
38 { XFS_ERRTAG_IFLUSH_2
, "iflush2" },
39 #define XFS_ERRTAG_IFLUSH_3 3
40 { XFS_ERRTAG_IFLUSH_3
, "iflush3" },
41 #define XFS_ERRTAG_IFLUSH_4 4
42 { XFS_ERRTAG_IFLUSH_4
, "iflush4" },
43 #define XFS_ERRTAG_IFLUSH_5 5
44 { XFS_ERRTAG_IFLUSH_5
, "iflush5" },
45 #define XFS_ERRTAG_IFLUSH_6 6
46 { XFS_ERRTAG_IFLUSH_6
, "iflush6" },
47 #define XFS_ERRTAG_DA_READ_BUF 7
48 { XFS_ERRTAG_DA_READ_BUF
, "dareadbuf" },
49 #define XFS_ERRTAG_BTREE_CHECK_LBLOCK 8
50 { XFS_ERRTAG_BTREE_CHECK_LBLOCK
, "btree_chk_lblk" },
51 #define XFS_ERRTAG_BTREE_CHECK_SBLOCK 9
52 { XFS_ERRTAG_BTREE_CHECK_SBLOCK
, "btree_chk_sblk" },
53 #define XFS_ERRTAG_ALLOC_READ_AGF 10
54 { XFS_ERRTAG_ALLOC_READ_AGF
, "readagf" },
55 #define XFS_ERRTAG_IALLOC_READ_AGI 11
56 { XFS_ERRTAG_IALLOC_READ_AGI
, "readagi" },
57 #define XFS_ERRTAG_ITOBP_INOTOBP 12
58 { XFS_ERRTAG_ITOBP_INOTOBP
, "itobp" },
59 #define XFS_ERRTAG_IUNLINK 13
60 { XFS_ERRTAG_IUNLINK
, "iunlink" },
61 #define XFS_ERRTAG_IUNLINK_REMOVE 14
62 { XFS_ERRTAG_IUNLINK_REMOVE
, "iunlinkrm" },
63 #define XFS_ERRTAG_DIR_INO_VALIDATE 15
64 { XFS_ERRTAG_DIR_INO_VALIDATE
, "dirinovalid" },
65 #define XFS_ERRTAG_BULKSTAT_READ_CHUNK 16
66 { XFS_ERRTAG_BULKSTAT_READ_CHUNK
, "bulkstat" },
67 #define XFS_ERRTAG_IODONE_IOERR 17
68 { XFS_ERRTAG_IODONE_IOERR
, "logiodone" },
69 #define XFS_ERRTAG_STRATREAD_IOERR 18
70 { XFS_ERRTAG_STRATREAD_IOERR
, "stratread" },
71 #define XFS_ERRTAG_STRATCMPL_IOERR 19
72 { XFS_ERRTAG_STRATCMPL_IOERR
, "stratcmpl" },
73 #define XFS_ERRTAG_DIOWRITE_IOERR 20
74 { XFS_ERRTAG_DIOWRITE_IOERR
, "diowrite" },
75 #define XFS_ERRTAG_BMAPIFORMAT 21
76 { XFS_ERRTAG_BMAPIFORMAT
, "bmapifmt" },
77 #define XFS_ERRTAG_FREE_EXTENT 22
78 { XFS_ERRTAG_FREE_EXTENT
, "free_extent" },
79 #define XFS_ERRTAG_RMAP_FINISH_ONE 23
80 { XFS_ERRTAG_RMAP_FINISH_ONE
, "rmap_finish_one" },
81 #define XFS_ERRTAG_REFCOUNT_CONTINUE_UPDATE 24
82 { XFS_ERRTAG_REFCOUNT_CONTINUE_UPDATE
, "refcount_continue_update" },
83 #define XFS_ERRTAG_REFCOUNT_FINISH_ONE 25
84 { XFS_ERRTAG_REFCOUNT_FINISH_ONE
, "refcount_finish_one" },
85 #define XFS_ERRTAG_BMAP_FINISH_ONE 26
86 { XFS_ERRTAG_BMAP_FINISH_ONE
, "bmap_finish_one" },
87 #define XFS_ERRTAG_AG_RESV_CRITICAL 27
88 { XFS_ERRTAG_AG_RESV_CRITICAL
, "ag_resv_critical" },
89 #define XFS_ERRTAG_MAX 28
90 { XFS_ERRTAG_MAX
, NULL
}
94 /* Search for a name */
96 for (e
= eflags
; e
->name
; e
++)
97 if (strcmp(name
, e
->name
) == 0)
102 /* Dump all the names */
103 fputs("tags: [ ", stdout
);
104 for (count
= 0, e
= eflags
; e
->name
; e
++, count
++) {
108 fputs("\n\t", stdout
);
110 fputs(e
->name
, stdout
);
112 fputs(" ]\n", stdout
);
121 " inject errors into the filesystem of the currently open file\n"
124 " 'inject readagf' - cause errors on allocation group freespace reads\n"
126 " Causes the kernel to generate and react to errors within XFS, provided\n"
127 " the XFS kernel code has been built with debugging features enabled.\n"
128 " With no arguments, displays the list of error injection tags.\n"
137 xfs_error_injection_t error
;
138 int command
= XFS_IOC_ERROR_INJECTION
;
141 return error_tag(NULL
);
145 if ((error
.errtag
= error_tag(argv
[argc
])) < 0) {
146 fprintf(stderr
, _("no such tag -- %s\n"), argv
[1]);
149 if (error
.errtag
== XFS_ERRTAG_NOERROR
)
150 command
= XFS_IOC_ERROR_CLEARALL
;
151 if ((xfsctl(file
->name
, file
->fd
, command
, &error
)) < 0) {
152 perror("XFS_IOC_ERROR_INJECTION");
162 inject_cmd
.name
= "inject";
163 inject_cmd
.cfunc
= inject_f
;
164 inject_cmd
.argmin
= 0;
165 inject_cmd
.argmax
= -1;
166 inject_cmd
.flags
= CMD_NOMAP_OK
;
167 inject_cmd
.args
= _("[tag ...]");
168 inject_cmd
.oneline
= _("inject errors into a filesystem");
169 inject_cmd
.help
= inject_help
;
172 add_command(&inject_cmd
);