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/fiemap.h> 00020 00021 #include <libexplain/buffer/fiemap.h> 00022 #include <libexplain/buffer/int64_t.h> 00023 #include <libexplain/buffer/long.h> 00024 #include <libexplain/buffer/pointer.h> 00025 #include <libexplain/parse_bits.h> 00026 #include <libexplain/is_efault.h> 00027 #include <libexplain/sizeof.h> 00028 00029 #ifdef HAVE_LINUX_FIEMAP_H 00030 00031 00032 static void 00033 explain_buffer_fiemap_flags(explain_string_buffer_t *sb, int value) 00034 { 00035 static const explain_parse_bits_table_t table[] = 00036 { 00037 { "FIEMAP_FLAG_SYNC", FIEMAP_FLAG_SYNC }, 00038 { "FIEMAP_FLAG_XATTR", FIEMAP_FLAG_XATTR }, 00039 }; 00040 00041 explain_parse_bits_print(sb, value, table, SIZEOF(table)); 00042 } 00043 00044 00045 void 00046 explain_buffer_fiemap(explain_string_buffer_t *sb, 00047 const struct fiemap *data) 00048 { 00049 if (explain_is_efault_pointer(data, sizeof(*data))) 00050 { 00051 explain_buffer_pointer(sb, data); 00052 return; 00053 } 00054 00055 /* 00056 * We only print the (in) fields. 00057 */ 00058 explain_string_buffer_puts(sb, "{ fm_start = "); 00059 explain_buffer_uint64_t(sb, data->fm_start); 00060 explain_string_buffer_puts(sb, ", fm_length = "); 00061 explain_buffer_uint64_t(sb, data->fm_length); 00062 explain_string_buffer_puts(sb, ", fm_flags = "); 00063 explain_buffer_fiemap_flags(sb, data->fm_flags); 00064 explain_string_buffer_puts(sb, ", fm_extent_count = "); 00065 explain_buffer_ulong(sb, data->fm_extent_count); 00066 explain_string_buffer_puts(sb, " }"); 00067 } 00068 00069 00070 #else 00071 00072 00073 void 00074 explain_buffer_fiemap(explain_string_buffer_t *sb, 00075 const struct fiemap *data) 00076 { 00077 explain_buffer_pointer(sb, data); 00078 } 00079 00080 00081 #endif 00082 00083 00084 /* vim: set ts=8 sw=4 et : */