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/capability.h> 00027 #include <libexplain/iocontrol/generic.h> 00028 #include <libexplain/iocontrol/vt_activate.h> 00029 00030 #ifdef VT_ACTIVATE 00031 00032 00033 static void 00034 print_explanation(const explain_iocontrol_t *p, explain_string_buffer_t *sb, int 00035 errnum, int fildes, int request, const void *data) 00036 { 00037 switch (errnum) 00038 { 00039 case ENXIO: 00040 if ((intptr_t)data <= 0 || (intptr_t)data > MAX_NR_CONSOLES) 00041 { 00042 explain_buffer_einval_out_of_range(sb, "data", 1, MAX_NR_CONSOLES); 00043 break; 00044 } 00045 goto generic; 00046 00047 case EPERM: 00048 if (!explain_capability_sys_tty_config()) 00049 { 00050 explain_buffer_eperm_sys_tty_config(sb, "ioctl VT_ACTIVATE"); 00051 break; 00052 } 00053 goto generic; 00054 00055 default: 00056 generic: 00057 explain_iocontrol_generic_print_explanation 00058 ( 00059 p, 00060 sb, 00061 errnum, 00062 fildes, 00063 request, 00064 data 00065 ); 00066 break; 00067 } 00068 } 00069 00070 00071 const explain_iocontrol_t explain_iocontrol_vt_activate = 00072 { 00073 "VT_ACTIVATE", /* name */ 00074 VT_ACTIVATE, /* value */ 00075 0, /* disambiguate */ 00076 0, /* print_name */ 00077 explain_iocontrol_generic_print_data_long, /* print_data */ 00078 print_explanation, 00079 0, /* print_data_returned */ 00080 NOT_A_POINTER, /* data_size */ 00081 "intptr_t", /* data_type */ 00082 0, /* flags */ 00083 __FILE__, 00084 __LINE__, 00085 }; 00086 00087 #else /* ndef VT_ACTIVATE */ 00088 00089 const explain_iocontrol_t explain_iocontrol_vt_activate = 00090 { 00091 0, /* name */ 00092 0, /* value */ 00093 0, /* disambiguate */ 00094 0, /* print_name */ 00095 0, /* print_data */ 00096 0, /* print_explanation */ 00097 0, /* print_data_returned */ 00098 0, /* data_size */ 00099 0, /* data_type */ 00100 0, /* flags */ 00101 __FILE__, 00102 __LINE__, 00103 }; 00104 00105 #endif /* VT_ACTIVATE */ 00106 00107 00108 /* vim: set ts=8 sw=4 et : */