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/vt.h> 00022 #include <libexplain/ac/stdint.h> 00023 00024 #include <libexplain/buffer/einval.h> 00025 #include <libexplain/buffer/eperm.h> 00026 #include <libexplain/buffer/vt_mode.h> 00027 #include <libexplain/capability.h> 00028 #include <libexplain/iocontrol/generic.h> 00029 #include <libexplain/iocontrol/vt_reldisp.h> 00030 00031 #ifdef VT_RELDISP 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_vt_mode_mode(sb, (intptr_t)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 EPERM: 00053 if (!explain_capability_sys_tty_config()) 00054 { 00055 explain_buffer_eperm_sys_tty_config(sb, "ioctl VT_RELDISP"); 00056 break; 00057 } 00058 goto generic; 00059 00060 case EINVAL: 00061 explain_buffer_einval_vague(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 const explain_iocontrol_t explain_iocontrol_vt_reldisp = 00081 { 00082 "VT_RELDISP", /* name */ 00083 VT_RELDISP, /* value */ 00084 0, /* disambiguate */ 00085 0, /* print_name */ 00086 print_data, 00087 print_explanation, 00088 0, /* print_data_returned */ 00089 NOT_A_POINTER, /* data_size */ 00090 "intptr_t", /* data_type */ 00091 0, /* flags */ 00092 __FILE__, 00093 __LINE__, 00094 }; 00095 00096 #else /* ndef VT_RELDISP */ 00097 00098 const explain_iocontrol_t explain_iocontrol_vt_reldisp = 00099 { 00100 0, /* name */ 00101 0, /* value */ 00102 0, /* disambiguate */ 00103 0, /* print_name */ 00104 0, /* print_data */ 00105 0, /* print_explanation */ 00106 0, /* print_data_returned */ 00107 0, /* data_size */ 00108 0, /* data_type */ 00109 0, /* flags */ 00110 __FILE__, 00111 __LINE__, 00112 }; 00113 00114 #endif /* VT_RELDISP */ 00115 00116 00117 /* vim: set ts=8 sw=4 et : */