libexplain  1.4.D001
libexplain/buffer/errno/fstatvfs.c
Go to the documentation of this file.
00001 /*
00002  * libexplain - Explain errno values returned by libc functions
00003  * Copyright (C) 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 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/eacces.h>
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/eloop.h>
00027 #include <libexplain/buffer/enametoolong.h>
00028 #include <libexplain/buffer/enoent.h>
00029 #include <libexplain/buffer/enomem.h>
00030 #include <libexplain/buffer/enosys.h>
00031 #include <libexplain/buffer/enotdir.h>
00032 #include <libexplain/buffer/eoverflow.h>
00033 #include <libexplain/buffer/errno/generic.h>
00034 #include <libexplain/buffer/errno/fstatvfs.h>
00035 #include <libexplain/buffer/fildes.h>
00036 #include <libexplain/buffer/pointer.h>
00037 #include <libexplain/explanation.h>
00038 
00039 
00040 static void
00041 explain_buffer_errno_fstatvfs_system_call(explain_string_buffer_t *sb, int
00042     errnum, int fildes, struct statvfs *data)
00043 {
00044     (void)errnum;
00045     explain_string_buffer_puts(sb, "fstatvfs(fildes = ");
00046     explain_buffer_fildes(sb, fildes);
00047     explain_string_buffer_puts(sb, ", data = ");
00048     explain_buffer_pointer(sb, data);
00049     explain_string_buffer_putc(sb, ')');
00050 }
00051 
00052 
00053 void
00054 explain_buffer_errno_fstatvfs_explanation(explain_string_buffer_t *sb, int
00055     errnum, const char *syscall_name, int fildes, struct statvfs *data)
00056 {
00057     /*
00058      * http://www.opengroup.org/onlinepubs/009695399/functions/fstatvfs.html
00059      */
00060     (void)data;
00061     switch (errnum)
00062     {
00063     case EBADF:
00064         explain_buffer_ebadf(sb, fildes, "fildes");
00065         break;
00066 
00067     case EFAULT:
00068         explain_buffer_efault(sb, "data");
00069         break;
00070 
00071     case EINTR:
00072         explain_buffer_eintr(sb, syscall_name);
00073         break;
00074 
00075     case EIO:
00076         explain_buffer_eio(sb);
00077         break;
00078 
00079     case ENOMEM:
00080         explain_buffer_enomem_kernel(sb);
00081         break;
00082 
00083     case ENOSYS:
00084 #if defined(EOPNOTSUPP) && ENOSYS != EOPNOTSUPP
00085     case EOPNOTSUPP:
00086 #endif
00087 #if defined(ENOTSUP) && (ENOTSUP != EOPNOTSUPP)
00088     case ENOTSUP:
00089 #endif
00090         explain_buffer_enosys_fildes(sb, fildes, "fildes", syscall_name);
00091         break;
00092 
00093     case EOVERFLOW:
00094         explain_buffer_eoverflow(sb);
00095         break;
00096 
00097     default:
00098         explain_buffer_errno_generic(sb, errnum, syscall_name);
00099         break;
00100     }
00101 }
00102 
00103 
00104 void
00105 explain_buffer_errno_fstatvfs(explain_string_buffer_t *sb, int errnum, int
00106     fildes, struct statvfs *data)
00107 {
00108     explain_explanation_t exp;
00109 
00110     explain_explanation_init(&exp, errnum);
00111     explain_buffer_errno_fstatvfs_system_call(&exp.system_call_sb, errnum,
00112         fildes, data);
00113     explain_buffer_errno_fstatvfs_explanation(&exp.explanation_sb, errnum,
00114         "fstatvfs", fildes, data);
00115     explain_explanation_assemble(&exp, sb);
00116 }
00117 
00118 
00119 /* vim: set ts=8 sw=4 et : */