libexplain
1.4.D001
|
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 00006 * it under the terms of the GNU Lesser General Public License as 00007 * published by the Free Software Foundation; either version 3 of the 00008 * License, or (at 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/sys/stat.h> 00020 00021 #include <libexplain/buffer/einval.h> 00022 #include <libexplain/buffer/file_type.h> 00023 #include <libexplain/buffer/gettext.h> 00024 #include <libexplain/buffer/more_appropriate.h> 00025 00026 00027 void 00028 explain_buffer_einval_mknod(explain_string_buffer_t *sb, int mode, 00029 const char *mode_caption, const char *syscall_name) 00030 { 00031 char filtyp[100]; 00032 explain_string_buffer_t filtyp_sb; 00033 00034 (void)mode_caption; 00035 explain_string_buffer_init(&filtyp_sb, filtyp, sizeof(filtyp)); 00036 explain_buffer_file_type(&filtyp_sb, mode); 00037 00038 explain_string_buffer_printf_gettext 00039 ( 00040 sb, 00041 /* 00042 * xgettext: This error message is issued when a system call 00043 * reports an EINVAL error, in the case where mkdir was trying 00044 * to create an inappropriate kind of file node. 00045 */ 00046 i18n("the %s system call cannot be used to create a %s"), 00047 syscall_name, 00048 filtyp 00049 ); 00050 00051 switch (mode & S_IFMT) 00052 { 00053 case S_IFDIR: 00054 explain_buffer_more_appropriate_syscall(sb, "mkdir"); 00055 break; 00056 00057 case S_IFLNK: 00058 explain_buffer_more_appropriate_syscall(sb, "symlink"); 00059 break; 00060 00061 #ifdef S_IFSOCK 00062 case S_IFSOCK: 00063 explain_buffer_more_appropriate_syscall(sb, "socket"); 00064 break; 00065 #endif 00066 00067 #ifdef S_IFIFO 00068 case S_IFIFO: 00069 explain_buffer_more_appropriate_syscall(sb, "bind"); 00070 break; 00071 #endif 00072 00073 default: 00074 break; 00075 } 00076 } 00077 00078 00079 /* vim: set ts=8 sw=4 et : */