libexplain
1.4.D001
|
00001 /* 00002 * libexplain - Explain errno values returned by libc functions 00003 * Copyright (C) 2009, 2011-2013 Peter Miller 00004 * 00005 * This program is free software; you can redistribute it and/or modify 00006 * it under the terms of the GNU Lesser General Public License as 00007 * published by the Free Software Foundation; either version 3 of the 00008 * License, or (at your option) any later version. 00009 * 00010 * This program is distributed in the hope that it will be useful, 00011 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00013 * Lesser General Public License for more details. 00014 * 00015 * You should have received a copy of the GNU Lesser General Public License 00016 * along with this program. If not, see <http://www.gnu.org/licenses/>. 00017 */ 00018 00019 #include <libexplain/ac/linux/blktrace_api.h> 00020 00021 #include <libexplain/buffer/blk_user_trace_setup.h> 00022 #include <libexplain/buffer/int64_t.h> 00023 #include <libexplain/buffer/long.h> 00024 #include <libexplain/buffer/pointer.h> 00025 #include <libexplain/is_efault.h> 00026 #include <libexplain/parse_bits.h> 00027 #include <libexplain/sizeof.h> 00028 00029 00030 #ifdef HAVE_LINUX_BLKTRACE_API_H 00031 00032 static void 00033 explain_buffer_blktrace_mask(explain_string_buffer_t *sb, int value) 00034 { 00035 static const explain_parse_bits_table_t table[] = 00036 { 00037 #ifdef BLK_TC_READ 00038 { "BLK_TC_READ", BLK_TC_READ }, 00039 #endif 00040 #ifdef BLK_TC_WRITE 00041 { "BLK_TC_WRITE", BLK_TC_WRITE }, 00042 #endif 00043 #ifdef BLK_TC_BARRIER 00044 { "BLK_TC_BARRIER", BLK_TC_BARRIER }, 00045 #endif 00046 #ifdef BLK_TC_SYNC 00047 { "BLK_TC_SYNC", BLK_TC_SYNC }, 00048 #endif 00049 #ifdef BLK_TC_QUEUE 00050 { "BLK_TC_QUEUE", BLK_TC_QUEUE }, 00051 #endif 00052 #ifdef BLK_TC_REQUEUE 00053 { "BLK_TC_REQUEUE", BLK_TC_REQUEUE }, 00054 #endif 00055 #ifdef BLK_TC_ISSUE 00056 { "BLK_TC_ISSUE", BLK_TC_ISSUE }, 00057 #endif 00058 #ifdef BLK_TC_COMPLETE 00059 { "BLK_TC_COMPLETE", BLK_TC_COMPLETE }, 00060 #endif 00061 #ifdef BLK_TC_FS 00062 { "BLK_TC_FS", BLK_TC_FS }, 00063 #endif 00064 #ifdef BLK_TC_PC 00065 { "BLK_TC_PC", BLK_TC_PC }, 00066 #endif 00067 #ifdef BLK_TC_NOTIFY 00068 { "BLK_TC_NOTIFY", BLK_TC_NOTIFY }, 00069 #endif 00070 #ifdef BLK_TC_AHEAD 00071 { "BLK_TC_AHEAD", BLK_TC_AHEAD }, 00072 #endif 00073 #ifdef BLK_TC_META 00074 { "BLK_TC_META", BLK_TC_META }, 00075 #endif 00076 #ifdef BLK_TC_DISCARD 00077 { "BLK_TC_DISCARD", BLK_TC_DISCARD }, 00078 #endif 00079 #ifdef BLK_TC_DRV_DATA 00080 { "BLK_TC_DRV_DATA", BLK_TC_DRV_DATA }, 00081 #endif 00082 #ifdef BLK_TC_END 00083 { "BLK_TC_END", BLK_TC_END }, 00084 #endif 00085 }; 00086 00087 explain_parse_bits_print(sb, value, table, SIZEOF(table)); 00088 } 00089 00090 00091 void 00092 explain_buffer_blk_user_trace_setup(explain_string_buffer_t *sb, 00093 const struct blk_user_trace_setup *data) 00094 { 00095 if (explain_is_efault_pointer(data, sizeof(*data))) 00096 { 00097 explain_buffer_pointer(sb, data); 00098 return; 00099 } 00100 00101 explain_string_buffer_puts(sb, "{ name = "); 00102 explain_string_buffer_puts_quoted_n(sb, data->name, sizeof(data->name)); 00103 explain_string_buffer_puts(sb, ", act_mask = "); 00104 explain_buffer_blktrace_mask(sb, data->act_mask); 00105 explain_string_buffer_puts(sb, ", buf_size = "); 00106 explain_buffer_ulong(sb, data->buf_size); 00107 explain_string_buffer_puts(sb, ", buf_nr = "); 00108 explain_buffer_ulong(sb, data->buf_nr); 00109 explain_string_buffer_puts(sb, ", start_lba = "); 00110 explain_buffer_uint64_t(sb, data->start_lba); 00111 explain_string_buffer_puts(sb, ", end_lba = "); 00112 explain_buffer_uint64_t(sb, data->end_lba); 00113 explain_string_buffer_puts(sb, ", pid = "); 00114 explain_buffer_ulong(sb, data->pid); 00115 explain_string_buffer_puts(sb, " }"); 00116 } 00117 00118 #else 00119 00120 void 00121 explain_buffer_blk_user_trace_setup(explain_string_buffer_t *sb, 00122 const struct blk_user_trace_setup *data) 00123 { 00124 explain_buffer_pointer(sb, data); 00125 } 00126 00127 #endif 00128 00129 00130 /* vim: set ts=8 sw=4 et : */