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/fs.h> 00020 00021 #include <libexplain/buffer/file_inode_flags.h> 00022 #include <libexplain/buffer/int.h> 00023 #include <libexplain/buffer/pointer.h> 00024 #include <libexplain/is_efault.h> 00025 #include <libexplain/parse_bits.h> 00026 #include <libexplain/sizeof.h> 00027 00028 00029 #if defined(FS_IOC_GETFLAGS) || defined(FS_IOC32_GETFLAGS) 00030 00031 void 00032 explain_buffer_file_inode_flags(explain_string_buffer_t *sb, int value) 00033 { 00034 static const explain_parse_bits_table_t table[] = 00035 { 00036 { "FS_SECRM_FL", FS_SECRM_FL }, 00037 { "FS_UNRM_FL", FS_UNRM_FL }, 00038 { "FS_COMPR_FL", FS_COMPR_FL }, 00039 { "FS_SYNC_FL", FS_SYNC_FL }, 00040 { "FS_IMMUTABLE_FL", FS_IMMUTABLE_FL }, 00041 { "FS_APPEND_FL", FS_APPEND_FL }, 00042 { "FS_NODUMP_FL", FS_NODUMP_FL }, 00043 { "FS_NOATIME_FL", FS_NOATIME_FL }, 00044 { "FS_DIRTY_FL", FS_DIRTY_FL }, 00045 { "FS_COMPRBLK_FL", FS_COMPRBLK_FL }, 00046 { "FS_NOCOMP_FL", FS_NOCOMP_FL }, 00047 { "FS_ECOMPR_FL", FS_ECOMPR_FL }, 00048 { "FS_BTREE_FL", FS_BTREE_FL }, 00049 { "FS_INDEX_FL", FS_INDEX_FL }, 00050 { "FS_IMAGIC_FL", FS_IMAGIC_FL }, 00051 { "FS_JOURNAL_DATA_FL", FS_JOURNAL_DATA_FL }, 00052 { "FS_NOTAIL_FL", FS_NOTAIL_FL }, 00053 { "FS_DIRSYNC_FL", FS_DIRSYNC_FL }, 00054 { "FS_TOPDIR_FL", FS_TOPDIR_FL }, 00055 { "FS_EXTENT_FL", FS_EXTENT_FL }, 00056 { "FS_DIRECTIO_FL", FS_DIRECTIO_FL }, 00057 { "FS_RESERVED_FL", FS_RESERVED_FL }, 00058 }; 00059 00060 explain_parse_bits_print(sb, value, table, SIZEOF(table)); 00061 } 00062 00063 #else 00064 00065 void 00066 explain_buffer_file_inode_flags(explain_string_buffer_t *sb, int value) 00067 { 00068 explain_buffer_int(sb, value); 00069 } 00070 00071 #endif 00072 00073 00074 void 00075 explain_buffer_file_inode_flags_int_star(explain_string_buffer_t *sb, 00076 const int *data) 00077 { 00078 if (explain_is_efault_pointer(data, sizeof(*data))) 00079 { 00080 explain_buffer_pointer(sb, data); 00081 return; 00082 } 00083 00084 explain_string_buffer_puts(sb, "{ "); 00085 explain_buffer_file_inode_flags(sb, *data); 00086 explain_string_buffer_puts(sb, " }"); 00087 } 00088 00089 00090 void 00091 explain_buffer_file_inode_flags_long_star(explain_string_buffer_t *sb, 00092 const long *data) 00093 { 00094 if (explain_is_efault_pointer(data, sizeof(*data))) 00095 { 00096 explain_buffer_pointer(sb, data); 00097 return; 00098 } 00099 00100 explain_string_buffer_puts(sb, "{ "); 00101 explain_buffer_file_inode_flags(sb, *data); 00102 explain_string_buffer_puts(sb, " }"); 00103 } 00104 00105 00106 /* vim: set ts=8 sw=4 et : */