libexplain
1.4.D001
|
00001 /* 00002 * libexplain - Explain errno values returned by libc functions 00003 * Copyright (C) 2008, 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/errno.h> 00020 00021 #include <libexplain/buffer/eacces.h> 00022 #include <libexplain/buffer/errno/path_resolution.h> 00023 00024 00025 void 00026 explain_buffer_eacces(explain_string_buffer_t *sb, const char *pathname, 00027 const char *caption, const explain_final_t *final_component) 00028 { 00029 if 00030 ( 00031 explain_buffer_errno_path_resolution 00032 ( 00033 sb, 00034 EACCES, 00035 pathname, 00036 caption, 00037 final_component 00038 ) 00039 ) 00040 { 00041 if (final_component->want_to_unlink || final_component->want_to_create) 00042 { 00043 explain_string_buffer_printf_gettext 00044 ( 00045 sb, 00046 /* 00047 * xgettext: This message is used to explain an EACCES error, 00048 * when attempting to create or remove a file, when 00049 * path_resolution(7) can not find anything more specific. 00050 * 00051 * %1$s => the name of the problematic system call cargument 00052 * %2$s => identical to the above 00053 */ 00054 i18n("search permission is denied for a directory component of " 00055 "%s; or, the directory containing %s is not writable by " 00056 "the user"), 00057 caption, 00058 caption 00059 ); 00060 } 00061 else if (final_component->want_to_read) 00062 { 00063 explain_string_buffer_printf_gettext 00064 ( 00065 sb, 00066 /* 00067 * xgettext: This message is used to explain an EACCES error, 00068 * when attempting to read a file, when path_resolution(7) can 00069 * not find anything more specific. 00070 * 00071 * %1$s => the name of the problematic system call cargument 00072 * %2$s => identical to the above 00073 */ 00074 i18n("read access to %s was not allowed, or one of the " 00075 "directory components of %s did not allow search " 00076 "permission"), 00077 caption, 00078 caption 00079 ); 00080 } 00081 else if 00082 ( 00083 final_component->want_to_write 00084 || 00085 final_component->want_to_modify_inode 00086 ) 00087 { 00088 explain_string_buffer_printf_gettext 00089 ( 00090 sb, 00091 /* 00092 * xgettext: This message is used to explain an EACCES error, 00093 * when attempting to write a file, when path_resolution(7) can 00094 * not find anything more specific. 00095 * 00096 * %1$s => the name of the problematic system call cargument 00097 * %2$s => identical to the above 00098 */ 00099 i18n("write access to %s was not allowed, or one of the " 00100 "directory components of %s did not allow search " 00101 "permission"), 00102 caption, 00103 caption 00104 ); 00105 } 00106 else 00107 { 00108 explain_string_buffer_printf_gettext 00109 ( 00110 sb, 00111 /* 00112 * xgettext: This message is used to explain an EACCES error, 00113 * when path_resolution(7) can not find anything more specific. 00114 * 00115 * %1$s => the name of the problematic system call cargument 00116 */ 00117 i18n("search permission is denied for a directory " 00118 "component of %s"), 00119 caption 00120 ); 00121 } 00122 } 00123 } 00124 00125 00126 /* vim: set ts=8 sw=4 et : */