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 it 00006 * under the terms of the GNU Lesser General Public License as published by 00007 * the Free Software Foundation; either version 3 of the License, or (at your 00008 * option) any later version. 00009 * 00010 * This program is distributed in the hope that it will be useful,but WITHOUT 00011 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 00012 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 00013 * 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/sys/ioctl.h> 00020 #include <libexplain/ac/errno.h> 00021 #include <libexplain/ac/linux/hdreg.h> 00022 00023 #include <libexplain/buffer/dac.h> 00024 #include <libexplain/buffer/efault.h> 00025 #include <libexplain/buffer/long.h> 00026 #include <libexplain/buffer/pointer.h> 00027 #include <libexplain/capability.h> 00028 #include <libexplain/iocontrol/generic.h> 00029 #include <libexplain/iocontrol/hdio_get_unmaskintr.h> 00030 00031 #ifdef HDIO_GET_UNMASKINTR 00032 00033 00034 static void 00035 print_data(const explain_iocontrol_t *p, explain_string_buffer_t *sb, int 00036 errnum, int fildes, int request, const void *data) 00037 { 00038 (void)p; 00039 (void)errnum; 00040 (void)fildes; 00041 (void)request; 00042 explain_buffer_pointer(sb, data); 00043 } 00044 00045 00046 static void 00047 print_explanation(const explain_iocontrol_t *p, explain_string_buffer_t *sb, int 00048 errnum, int fildes, int request, const void *data) 00049 { 00050 switch (errnum) 00051 { 00052 case EACCES: 00053 if (!explain_capability_sys_admin()) 00054 { 00055 explain_buffer_dac_sys_admin(sb); 00056 break; 00057 } 00058 goto generic; 00059 00060 case EFAULT: 00061 explain_buffer_efault(sb, "data"); 00062 break; 00063 00064 default: 00065 generic: 00066 explain_iocontrol_generic_print_explanation 00067 ( 00068 p, 00069 sb, 00070 errnum, 00071 fildes, 00072 request, 00073 data 00074 ); 00075 break; 00076 } 00077 } 00078 00079 00080 static void 00081 print_data_returned(const explain_iocontrol_t *p, explain_string_buffer_t *sb, 00082 int errnum, int fildes, int request, const void *data) 00083 { 00084 (void)p; 00085 (void)errnum; 00086 (void)fildes; 00087 (void)request; 00088 explain_buffer_long_star(sb, data); 00089 } 00090 00091 00092 const explain_iocontrol_t explain_iocontrol_hdio_get_unmaskintr = 00093 { 00094 "HDIO_GET_UNMASKINTR", /* name */ 00095 HDIO_GET_UNMASKINTR, /* value */ 00096 0, /* disambiguate */ 00097 0, /* print_name */ 00098 print_data, 00099 print_explanation, 00100 print_data_returned, 00101 sizeof(long), /* data_size */ 00102 "long *", /* data_type */ 00103 IOCONTROL_FLAG_NON_META, /* flags */ 00104 __FILE__, 00105 __LINE__, 00106 }; 00107 00108 #else /* ndef HDIO_GET_UNMASKINTR */ 00109 00110 const explain_iocontrol_t explain_iocontrol_hdio_get_unmaskintr = 00111 { 00112 0, /* name */ 00113 0, /* value */ 00114 0, /* disambiguate */ 00115 0, /* print_name */ 00116 0, /* print_data */ 00117 0, /* print_explanation */ 00118 0, /* print_data_returned */ 00119 0, /* data_size */ 00120 0, /* data_type */ 00121 0, /* flags */ 00122 __FILE__, 00123 __LINE__, 00124 }; 00125 00126 #endif /* HDIO_GET_UNMASKINTR */ 00127 00128 00129 /* vim: set ts=8 sw=4 et : */