libexplain  1.4.D001
libexplain/buffer/errno/ustat.c
Go to the documentation of this file.
00001 /*
00002  * libexplain - Explain errno values returned by libc functions
00003  * Copyright (C) 2009, 2011, 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 
00021 #include <libexplain/buffer/dev_t.h>
00022 #include <libexplain/buffer/efault.h>
00023 #include <libexplain/buffer/enosys.h>
00024 #include <libexplain/buffer/errno/generic.h>
00025 #include <libexplain/buffer/errno/ustat.h>
00026 #include <libexplain/buffer/gettext.h>
00027 #include <libexplain/buffer/pointer.h>
00028 #include <libexplain/explanation.h>
00029 
00030 
00031 static void
00032 explain_buffer_errno_ustat_system_call(explain_string_buffer_t *sb, int errnum,
00033     dev_t dev, struct ustat *data)
00034 {
00035     (void)errnum;
00036     explain_string_buffer_puts(sb, "ustat(dev = ");
00037     explain_buffer_dev_t(sb, dev);
00038     explain_string_buffer_puts(sb, ", data = ");
00039     explain_buffer_pointer(sb, data);
00040     explain_string_buffer_putc(sb, ')');
00041 }
00042 
00043 
00044 void
00045 explain_buffer_errno_ustat_explanation(explain_string_buffer_t *sb, int errnum,
00046     const char *syscall_name, dev_t dev, struct ustat *data)
00047 {
00048     /*
00049      * http://www.opengroup.org/onlinepubs/009695399/functions/ustat.html
00050      */
00051     (void)dev;
00052     (void)data;
00053     switch (errnum)
00054     {
00055     case EFAULT:
00056         explain_buffer_efault(sb, "data");
00057         break;
00058 
00059     case EINVAL:
00060         explain_string_buffer_printf_gettext
00061         (
00062             sb,
00063             /*
00064              * xgettext: This error message is issued to explain an EINVAL error
00065              * reported by the ustat syatem call, in the case where the devive
00066              * specified does not contain a mounted file system.
00067              *
00068              * %1$s => the name of the offending system call argument
00069              */
00070             i18n("the %s argument does not refer to a device containing "
00071                 "a mounted file system"),
00072             "dev"
00073         );
00074         break;
00075 
00076     case ENOSYS:
00077 #if defined(EOPNOTSUPP) && ENOSYS != EOPNOTSUPP
00078     case EOPNOTSUPP:
00079 #endif
00080         explain_buffer_enosys_vague(sb, syscall_name);
00081         break;
00082 
00083     default:
00084         explain_buffer_errno_generic(sb, errnum, syscall_name);
00085         break;
00086     }
00087 }
00088 
00089 
00090 void
00091 explain_buffer_errno_ustat(explain_string_buffer_t *sb, int errnum, dev_t dev,
00092     struct ustat *data)
00093 {
00094     explain_explanation_t exp;
00095 
00096     explain_explanation_init(&exp, errnum);
00097     explain_buffer_errno_ustat_system_call(&exp.system_call_sb, errnum, dev,
00098         data);
00099     explain_buffer_errno_ustat_explanation(&exp.explanation_sb, errnum, "ustat",
00100         dev, data);
00101     explain_explanation_assemble(&exp, sb);
00102 }
00103 
00104 
00105 /* vim: set ts=8 sw=4 et : */