libexplain  1.4.D001
libexplain/buffer/errno/path_resolution.h
Go to the documentation of this file.
00001 /*
00002  * libexplain - Explain errno values returned by libc functions
00003  * Copyright (C) 2008, 2009, 2012, 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 published by
00008  * the Free Software Foundation; either version 3 of the License, or (at
00009  * 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 #ifndef LIBEXPLAIN_BUFFER_ERRNO_PATH_RESOLUTION_H
00021 #define LIBEXPLAIN_BUFFER_ERRNO_PATH_RESOLUTION_H
00022 
00023 #include <libexplain/have_permission.h>
00024 #include <libexplain/string_buffer.h>
00025 
00026 typedef struct explain_final_t explain_final_t;
00027 struct explain_final_t
00028 {
00029     unsigned        want_to_read    :1;
00030     unsigned        want_to_write   :1;
00031     unsigned        want_to_search  :1;
00032     unsigned        want_to_execute :1;
00033     unsigned        want_to_create  :1;
00034     unsigned        want_to_modify_inode :1;
00035     unsigned        want_to_unlink  :1;
00036     unsigned        must_exist      :1;
00037     unsigned        must_not_exist  :1;
00038     unsigned        follow_symlink  :1;
00039 
00046     unsigned        must_be_a_st_mode :1;
00047 
00055     unsigned        follow_interpreter :1;
00056 
00066     unsigned        st_mode;
00067 
00068     /*
00069      * The specific UID and GID to test against.
00070      * Defaults to geteuid() and getegid().
00071      * Required by the access(2) system call.
00072      */
00073     explain_have_identity_t id;
00074 
00075     /*
00076      * The specific maximum path length to test against.
00077      * Defaults to -1, meaning use pathconf(_PC_PATH_MAX).
00078      * This is needed when explaining sockaddr_un.sun_path errors.
00079      */
00080     long            path_max;
00081 
00082     /*
00083      * When you add to this struct, be sure to add to the
00084      * explain_final_init() code which initialises the fields to
00085      * default settings.
00086      */
00087 };
00088 
00096 void explain_final_init(explain_final_t *final_component);
00097 
00118 int explain_buffer_errno_path_resolution(explain_string_buffer_t *sb,
00119     int errnum, const char *pathname, const char *pathname_caption,
00120     const explain_final_t *final_component);
00121 
00122 #define must_be_a_directory(fcp) \
00123     (fcp->must_be_a_st_mode && fcp->st_mode == S_IFDIR)
00124 
00147 int explain_buffer_errno_path_resolution_at(explain_string_buffer_t *sb,
00148     int errnum, int fildes, const char *pathname, const char *pathname_caption,
00149     const explain_final_t *final_component);
00150 
00151 #endif /* LIBEXPLAIN_BUFFER_ERRNO_PATH_RESOLUTION_H */
00152 /* vim: set ts=8 sw=4 et : */