libexplain  1.4.D001
libexplain/buffer/errno/acl_get_fd.c
Go to the documentation of this file.
00001 /*
00002  * libexplain - Explain errno values returned by libc functions
00003  * Copyright (C) 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 of
00012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
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 
00021 #include <libexplain/buffer/ebadf.h>
00022 #include <libexplain/buffer/enomem.h>
00023 #include <libexplain/buffer/enosys.h>
00024 #include <libexplain/buffer/errno/acl_get_fd.h>
00025 #include <libexplain/buffer/errno/generic.h>
00026 #include <libexplain/buffer/fildes.h>
00027 #include <libexplain/explanation.h>
00028 
00029 
00030 static void
00031 explain_buffer_errno_acl_get_fd_system_call(explain_string_buffer_t *sb, int
00032     errnum, int fildes)
00033 {
00034     (void)errnum;
00035     explain_string_buffer_puts(sb, "acl_get_fd(fildes = ");
00036     explain_buffer_fildes(sb, fildes);
00037     explain_string_buffer_putc(sb, ')');
00038 }
00039 
00040 
00041 void
00042 explain_buffer_errno_acl_get_fd_explanation(explain_string_buffer_t *sb, int
00043     errnum, const char *syscall_name, int fildes)
00044 {
00045     /* acl_type_t type = ACL_TYPE_ACCESS; */
00046 
00047     /*
00048      * http://www.opengroup.org/onlinepubs/009695399/functions/acl_get_fd.html
00049      */
00050     switch (errnum)
00051     {
00052     case EBADF:
00053         explain_buffer_ebadf(sb, fildes, "fildes");
00054         break;
00055 
00056     case ENOMEM:
00057         /*
00058          * The ACL working storage requires more memory than is
00059          * allowed by the hardware or system-imposed memory management
00060          * constraints.
00061          */
00062         explain_buffer_enomem_user(sb, 0);
00063         break;
00064 
00065     case ENOTSUP:
00066     case ENOSYS:
00067 #if defined(EOPNOTSUP) && ENOSYS != EOPNOTSUP
00068     case EOPNOTSUP:
00069 #endif
00070         explain_buffer_enosys_acl(sb, "fildes", syscall_name);
00071         break;
00072 
00073     default:
00074         explain_buffer_errno_generic(sb, errnum, syscall_name);
00075         break;
00076     }
00077 }
00078 
00079 
00080 void
00081 explain_buffer_errno_acl_get_fd(explain_string_buffer_t *sb, int errnum, int
00082     fildes)
00083 {
00084     explain_explanation_t exp;
00085 
00086     explain_explanation_init(&exp, errnum);
00087     explain_buffer_errno_acl_get_fd_system_call(&exp.system_call_sb, errnum,
00088         fildes);
00089     explain_buffer_errno_acl_get_fd_explanation(&exp.explanation_sb, errnum,
00090         "acl_get_fd", fildes);
00091     explain_explanation_assemble(&exp, sb);
00092 }
00093 
00094 
00095 /* vim: set ts=8 sw=4 et : */