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 00023 #include <libexplain/buffer/einval.h> 00024 #include <libexplain/buffer/eperm.h> 00025 #include <libexplain/buffer/vt_consize.h> 00026 #include <libexplain/capability.h> 00027 #include <libexplain/iocontrol/generic.h> 00028 #include <libexplain/iocontrol/vt_resizex.h> 00029 #include <libexplain/is_efault.h> 00030 00031 #ifdef VT_RESIZEX 00032 00033 00034 static void 00035 print_explanation(const explain_iocontrol_t *p, explain_string_buffer_t *sb, int 00036 errnum, int fildes, int request, const void *data) 00037 { 00038 switch (errnum) 00039 { 00040 case EPERM: 00041 if (!explain_capability_sys_tty_config()) 00042 { 00043 explain_buffer_eperm_sys_tty_config(sb, "ioctl VT_RESIZEX"); 00044 break; 00045 } 00046 goto generic; 00047 00048 case EINVAL: 00049 { 00050 const struct vt_consize *arg; 00051 00052 arg = data; 00053 if (explain_is_efault_pointer(arg, sizeof(*arg))) 00054 { 00055 if (arg->v_clin > 32) 00056 { 00057 explain_buffer_einval_too_large2(sb, "data.v_clin", 32); 00058 break; 00059 } 00060 if 00061 ( 00062 arg->v_vcol 00063 && 00064 arg->v_ccol 00065 && 00066 arg->v_cols != arg->v_vcol / arg->v_ccol) 00067 { 00068 explain_buffer_einval_vague(sb, "data.v_cols"); 00069 break; 00070 } 00071 if 00072 ( 00073 arg->v_clin 00074 && 00075 arg->v_rows 00076 && 00077 arg->v_rows != arg->v_vlin / arg->v_clin) 00078 { 00079 explain_buffer_einval_vague(sb, "data.v_rows"); 00080 break; 00081 } 00082 } 00083 } 00084 goto generic; 00085 00086 default: 00087 generic: 00088 explain_iocontrol_generic_print_explanation 00089 ( 00090 p, 00091 sb, 00092 errnum, 00093 fildes, 00094 request, 00095 data 00096 ); 00097 break; 00098 } 00099 } 00100 00101 00102 static void 00103 print_data_returned(const explain_iocontrol_t *p, explain_string_buffer_t *sb, 00104 int errnum, int fildes, int request, const void *data) 00105 { 00106 (void)p; 00107 (void)errnum; 00108 (void)fildes; 00109 (void)request; 00110 explain_buffer_vt_consize(sb, data); 00111 } 00112 00113 00114 const explain_iocontrol_t explain_iocontrol_vt_resizex = 00115 { 00116 "VT_RESIZEX", /* name */ 00117 VT_RESIZEX, /* value */ 00118 0, /* disambiguate */ 00119 0, /* print_name */ 00120 explain_iocontrol_generic_print_data_pointer, /* print_data */ 00121 print_explanation, 00122 print_data_returned, 00123 sizeof(struct vt_consize), /* data_size */ 00124 "struct vt_consize *", /* data_type */ 00125 IOCONTROL_FLAG_SIZE_DOES_NOT_AGREE, /* flags */ 00126 __FILE__, 00127 __LINE__, 00128 }; 00129 00130 #else /* ndef VT_RESIZEX */ 00131 00132 const explain_iocontrol_t explain_iocontrol_vt_resizex = 00133 { 00134 0, /* name */ 00135 0, /* value */ 00136 0, /* disambiguate */ 00137 0, /* print_name */ 00138 0, /* print_data */ 00139 0, /* print_explanation */ 00140 0, /* print_data_returned */ 00141 0, /* data_size */ 00142 0, /* data_type */ 00143 0, /* flags */ 00144 __FILE__, 00145 __LINE__, 00146 }; 00147 00148 #endif /* VT_RESIZEX */ 00149 00150 00151 /* vim: set ts=8 sw=4 et : */