libexplain  1.4.D001
libexplain/buffer/errno/fstatfs.c
Go to the documentation of this file.
00001 /*
00002  * libexplain - Explain errno values returned by libc functions
00003  * Copyright (C) 2009, 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,
00011  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013  * Lesser 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/statfs.h>
00021 
00022 #include <libexplain/buffer/ebadf.h>
00023 #include <libexplain/buffer/efault.h>
00024 #include <libexplain/buffer/eintr.h>
00025 #include <libexplain/buffer/eio.h>
00026 #include <libexplain/buffer/enomem.h>
00027 #include <libexplain/buffer/enosys.h>
00028 #include <libexplain/buffer/eoverflow.h>
00029 #include <libexplain/buffer/errno/fstatfs.h>
00030 #include <libexplain/buffer/errno/generic.h>
00031 #include <libexplain/buffer/fildes.h>
00032 #include <libexplain/buffer/pointer.h>
00033 #include <libexplain/explanation.h>
00034 
00035 
00036 static void
00037 explain_buffer_errno_fstatfs_system_call(explain_string_buffer_t *sb, int
00038     errnum, int fildes, struct statfs *data)
00039 {
00040     (void)errnum;
00041     explain_string_buffer_puts(sb, "fstatfs(fildes = ");
00042     explain_buffer_fildes(sb, fildes);
00043     explain_string_buffer_puts(sb, ", data = ");
00044     explain_buffer_pointer(sb, data);
00045     explain_string_buffer_putc(sb, ')');
00046 }
00047 
00048 
00049 static void
00050 explain_buffer_errno_fstatfs_explanation(explain_string_buffer_t *sb, int
00051     errnum, int fildes, struct statfs *data)
00052 {
00053     /*
00054      * http://www.opengroup.org/onlinepubs/009695399/functions/fstatfs.html
00055      */
00056     (void)data;
00057     switch (errnum)
00058     {
00059     case EBADF:
00060         explain_buffer_ebadf(sb, fildes, "fildes");
00061         break;
00062 
00063     case EFAULT:
00064         explain_buffer_efault(sb, "data");
00065         break;
00066 
00067     case EINTR:
00068         explain_buffer_eintr(sb, "fstatfs");
00069         break;
00070 
00071     case EIO:
00072         explain_buffer_eio_fildes(sb, fildes);
00073         break;
00074 
00075     case ENOMEM:
00076         explain_buffer_enomem_kernel(sb);
00077         break;
00078 
00079     case ENOSYS:
00080         explain_buffer_enosys_fildes(sb, fildes, "fildes", "fstatfs");
00081         break;
00082 
00083     case EOVERFLOW:
00084         explain_buffer_eoverflow(sb);
00085         break;
00086 
00087     default:
00088         explain_buffer_errno_generic(sb, errnum, "fstatfs");
00089         break;
00090     }
00091 }
00092 
00093 
00094 void
00095 explain_buffer_errno_fstatfs(explain_string_buffer_t *sb, int errnum, int
00096     fildes, struct statfs *data)
00097 {
00098     explain_explanation_t exp;
00099 
00100     explain_explanation_init(&exp, errnum);
00101     explain_buffer_errno_fstatfs_system_call(&exp.system_call_sb, errnum,
00102         fildes, data);
00103     explain_buffer_errno_fstatfs_explanation(&exp.explanation_sb, errnum,
00104         fildes, data);
00105     explain_explanation_assemble(&exp, sb);
00106 }
00107 
00108 
00109 /* vim: set ts=8 sw=4 et : */