libexplain
1.4.D001
|
00001 /* 00002 * libexplain - Explain errno values returned by libc functions 00003 * Copyright (C) 2009-2011, 2013, 2014 Peter Miller 00004 * Written by Peter Miller <pmiller@opensource.org.au> 00005 * 00006 * This program is free software; you can redistribute it and/or modify it 00007 * under the terms of the GNU Lesser General Public License as published by 00008 * the Free Software Foundation; either version 3 of the License, or (at your 00009 * option) any later version. 00010 * 00011 * This program is distributed in the hope that it will be useful, but WITHOUT 00012 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 00013 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 00014 * License for more details. 00015 * 00016 * You should have received a copy of the GNU Lesser General Public License 00017 * along with this program. If not, see <http://www.gnu.org/licenses/>. 00018 */ 00019 00020 #include <libexplain/ac/errno.h> 00021 #include <libexplain/ac/linux/fs.h> 00022 #include <libexplain/ac/sys/ioctl.h> 00023 00024 #include <libexplain/buffer/dac.h> 00025 #include <libexplain/buffer/ebusy.h> 00026 #include <libexplain/buffer/gettext.h> 00027 #include <libexplain/buffer/int.h> 00028 #include <libexplain/buffer/is_the_null_pointer.h> 00029 #include <libexplain/iocontrol/blkbszset.h> 00030 #include <libexplain/iocontrol/generic.h> 00031 #include <libexplain/string_buffer.h> 00032 00033 00034 #ifdef BLKBSZSET 00035 00036 /* 00037 * On the subject of data_size, the define is 00038 * 00039 * #define BLKBSZGET _IOR(0x12, 112, size_t) 00040 * 00041 * however the kernel actually uses "int" internally. 00042 * So which is correct? Guess the kernel is. 00043 */ 00044 00045 static void 00046 print_data(const explain_iocontrol_t *p, explain_string_buffer_t *sb, 00047 int errnum, int fildes, int request, const void *data) 00048 { 00049 (void)p; 00050 (void)errnum; 00051 (void)fildes; 00052 (void)request; 00053 explain_buffer_int_star(sb, data); 00054 } 00055 00056 00057 static void 00058 print_explanation(const explain_iocontrol_t *p, explain_string_buffer_t *sb, 00059 int errnum, int fildes, int request, const void *data) 00060 { 00061 switch (errnum) 00062 { 00063 case EACCES: 00064 explain_buffer_gettext 00065 ( 00066 sb, 00067 /* 00068 * xgettext: This error message is issued when ioctl 00069 * BLKBSZSET returns an EACCES error. 00070 */ 00071 i18n("the process does not have permission to change the " 00072 "logical block size") 00073 ); 00074 explain_buffer_dac_sys_admin(sb); 00075 break; 00076 00077 case EBUSY: 00078 explain_buffer_ebusy_fildes(sb, fildes, "fildes", "ioctl BLKBSZSET"); 00079 break; 00080 00081 case EINVAL: 00082 if (!data) 00083 { 00084 explain_buffer_is_the_null_pointer(sb, "data"); 00085 return; 00086 } 00087 /* fall through... */ 00088 00089 default: 00090 explain_iocontrol_generic.print_explanation 00091 ( 00092 p, 00093 sb, 00094 errnum, 00095 fildes, 00096 request, 00097 data 00098 ); 00099 break; 00100 } 00101 } 00102 00103 00104 const explain_iocontrol_t explain_iocontrol_blkbszset = 00105 { 00106 "BLKBSZSET", /* name */ 00107 BLKBSZSET, /* value */ 00108 0, /* disambiguate */ 00109 0, /* print_name */ 00110 print_data, 00111 print_explanation, 00112 0, /* print_data_returned */ 00113 sizeof(int), /* data_size */ 00114 "int *", /* data_type */ 00115 IOCONTROL_FLAG_SIZE_DOES_NOT_AGREE, /* flags */ 00116 __FILE__, 00117 __LINE__, 00118 }; 00119 00120 #else /* ndef BLKBSZSET */ 00121 00122 const explain_iocontrol_t explain_iocontrol_blkbszset = 00123 { 00124 0, /* name */ 00125 0, /* value */ 00126 0, /* disambiguate */ 00127 0, /* print_name */ 00128 0, /* print_data */ 00129 0, /* print_explanation */ 00130 0, /* print_data_returned */ 00131 0, /* data_size */ 00132 0, /* data_type */ 00133 0, /* flags */ 00134 __FILE__, 00135 __LINE__, 00136 }; 00137 00138 #endif /* BLKBSZSET */ 00139 00140 00141 /* vim: set ts=8 sw=4 et : */