libexplain
1.4.D001
|
00001 /* 00002 * libexplain - Explain errno values returned by libc functions 00003 * Copyright (C) 2010, 2013 Peter Miller 00004 * Written by Peter Miller <pmiller@opensource.org.au> 00005 * 00006 * This program is free software; you can redistribute it and/or modify 00007 * it under the terms of the GNU Lesser General Public License as 00008 * published by the Free Software Foundation; either version 3 of the 00009 * License, or (at your option) any later version. 00010 * 00011 * This program is distributed in the hope that it will be useful, 00012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00014 * Lesser General Public License for more details. 00015 * 00016 * You should have received a copy of the GNU Lesser General Public License 00017 * along with this program. If not, see <http://www.gnu.org/licenses/>. 00018 */ 00019 00020 #include <libexplain/ac/limits.h> /* for PATH_MAX on Solaris */ 00021 #include <libexplain/ac/sys/param.h> /* for PATH_MAX except Solaris */ 00022 #include <libexplain/ac/sys/stat.h> 00023 #include <libexplain/ac/unistd.h> 00024 00025 #include <libexplain/buffer/emlink.h> 00026 #include <libexplain/get_link_max.h> 00027 #include <libexplain/option.h> 00028 00029 00030 void 00031 explain_buffer_emlink_mkdir(explain_string_buffer_t *sb, const char *parent, 00032 const char *pathname_caption) 00033 { 00034 explain_string_buffer_t parentq_sb; 00035 char parentq[PATH_MAX]; 00036 00037 explain_string_buffer_init(&parentq_sb, parentq, sizeof(parentq)); 00038 explain_string_buffer_puts_quoted(&parentq_sb, parent); 00039 00040 explain_string_buffer_printf_gettext 00041 ( 00042 sb, 00043 /* 00044 * xgettext: This message is used when explaining an EMLINK 00045 * error, in the case where mkdir fails because a directory 00046 * already has too many hand links. 00047 * 00048 * Note that this message may be followed by the actual 00049 * limit in parentheses, so it helps of the last phrase 00050 * can be sensably followed by it. 00051 * 00052 * %1$s => The name of the offending syscall argument. 00053 * %2$s => The name (already quoted) of the parent directory 00054 * that has the problem. 00055 */ 00056 i18n("the %s parent directory %s already has the " 00057 "maximum number of links"), 00058 pathname_caption, 00059 parentq 00060 ); 00061 if (explain_option_dialect_specific()) 00062 { 00063 struct stat st; 00064 long link_max; 00065 00066 /* 00067 * If possible, display the actual value in the directory, 00068 * rather than the value returned by pathconf(). 00069 */ 00070 if (stat(parent, &st) >= 0) 00071 link_max = st.st_nlink; 00072 else 00073 link_max = explain_get_link_max(parent); 00074 explain_string_buffer_printf(sb, " (%ld)", link_max); 00075 } 00076 } 00077 00078 00079 /* vim: set ts=8 sw=4 et : */