libexplain
1.4.D001
|
00001 /* 00002 * libexplain - Explain errno values returned by libc functions 00003 * Copyright (C) 2009, 2010, 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 00008 * your option) any later version. 00009 * 00010 * This program is distributed in the hope that it will be useful,but 00011 * WITHOUT ANY WARRANTY; without even the implied warranty 00012 * ofMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNULesser 00013 * General Public License 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/errno.h> 00020 #include <libexplain/ac/sys/timerfd.h> 00021 00022 #include <libexplain/buffer/clockid.h> 00023 #include <libexplain/buffer/einval.h> 00024 #include <libexplain/buffer/emfile.h> 00025 #include <libexplain/buffer/enfile.h> 00026 #include <libexplain/buffer/enodev.h> 00027 #include <libexplain/buffer/enomem.h> 00028 #include <libexplain/buffer/enosys.h> 00029 #include <libexplain/buffer/errno/generic.h> 00030 #include <libexplain/buffer/errno/timerfd_create.h> 00031 #include <libexplain/buffer/timerfd_flags.h> 00032 #include <libexplain/explanation.h> 00033 00034 00035 static void 00036 explain_buffer_errno_timerfd_create_system_call(explain_string_buffer_t *sb, 00037 int errnum, int clockid, int flags) 00038 { 00039 (void)errnum; 00040 explain_string_buffer_puts(sb, "timerfd_create(clockid = "); 00041 explain_buffer_clockid(sb, clockid); 00042 explain_string_buffer_puts(sb, ", flags = "); 00043 explain_buffer_timerfd_flags(sb, flags); 00044 explain_string_buffer_putc(sb, ')'); 00045 } 00046 00047 00048 static void 00049 explain_buffer_errno_timerfd_create_explanation(explain_string_buffer_t *sb, 00050 int errnum, const char *syscall_name, int clockid, int flags) 00051 { 00052 (void)flags; 00053 switch (errnum) 00054 { 00055 case EINVAL: 00056 if (clockid != CLOCK_MONOTONIC && clockid != CLOCK_REALTIME) 00057 explain_buffer_einval_vague(sb, "clockid"); 00058 else 00059 explain_buffer_einval_bits(sb, "flags"); 00060 break; 00061 00062 case EMFILE: 00063 explain_buffer_emfile(sb); 00064 break; 00065 00066 case ENFILE: 00067 explain_buffer_enfile(sb); 00068 break; 00069 00070 case ENODEV: 00071 explain_buffer_enodev_anon_inodes(sb, syscall_name); 00072 break; 00073 00074 case ENOMEM: 00075 explain_buffer_enomem_kernel(sb); 00076 break; 00077 00078 case ENOSYS: 00079 #if defined(EOPNOTSUPP) && EOPNOTSUPP != ENOSYS 00080 case EOPNOTSUPP: 00081 #endif 00082 explain_buffer_enosys_vague(sb, syscall_name); 00083 break; 00084 00085 default: 00086 explain_buffer_errno_generic(sb, errnum, syscall_name); 00087 break; 00088 } 00089 } 00090 00091 00092 void 00093 explain_buffer_errno_timerfd_create(explain_string_buffer_t *sb, int errnum, int 00094 clockid, int flags) 00095 { 00096 explain_explanation_t exp; 00097 00098 explain_explanation_init(&exp, errnum); 00099 explain_buffer_errno_timerfd_create_system_call 00100 ( 00101 &exp.system_call_sb, 00102 errnum, 00103 clockid, 00104 flags 00105 ); 00106 explain_buffer_errno_timerfd_create_explanation 00107 ( 00108 &exp.explanation_sb, 00109 errnum, 00110 "timerfd_create", 00111 clockid, 00112 flags 00113 ); 00114 explain_explanation_assemble(&exp, sb); 00115 } 00116 00117 00118 /* vim: set ts=8 sw=4 et : */