Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
isv:cpanel:dev:EA4
apr
0003-Add-apr_stat_fd-to-file-io-layer.patch
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File 0003-Add-apr_stat_fd-to-file-io-layer.patch of Package apr
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: Rishwanth Yeddula <rish@cpanel.net> Date: Thu, 22 Mar 2018 13:23:22 -0500 Subject: [PATCH 3/4] Add apr_stat_fd to file io layer --- file_io/unix/filestat.c | 48 +++++++++++++++++++++++++++++++++++++++++ include/apr_file_io.h | 17 +++++++++++++++ 2 files changed, 65 insertions(+) diff --git a/file_io/unix/filestat.c b/file_io/unix/filestat.c index 220efd0..3ae0900 100644 --- a/file_io/unix/filestat.c +++ b/file_io/unix/filestat.c @@ -336,4 +336,52 @@ APR_DECLARE(apr_status_t) apr_stat(apr_finfo_t *finfo, } } +APR_DECLARE(apr_status_t) apr_stat_fd(apr_finfo_t *finfo, apr_file_t *fd, + apr_int32_t wanted, apr_pool_t *pool) +{ + struct_stat info; + int srv = fstat(fd->filedes, &info); + + if (srv == 0) { + finfo->pool = pool; + finfo->fname = fd->fname; + fill_out_finfo(finfo, &info, wanted); + if (wanted & APR_FINFO_LINK) + wanted &= ~APR_FINFO_LINK; + return (wanted & ~finfo->valid) ? APR_INCOMPLETE : APR_SUCCESS; + } + else { +#if !defined(ENOENT) || !defined(ENOTDIR) +#error ENOENT || ENOTDIR not defined; please see the +#error comments at this line in the source for a workaround. + /* + * If ENOENT || ENOTDIR is not defined in one of the your OS's + * include files, APR cannot report a good reason why the stat() + * of the file failed; there are cases where it can fail even though + * the file exists. This opens holes in Apache, for example, because + * it becomes possible for someone to get a directory listing of a + * directory even though there is an index (eg. index.html) file in + * it. If you do not have a problem with this, delete the above + * #error lines and start the compile again. If you need to do this, + * please submit a bug report to http://www.apache.org/bug_report.html + * letting us know that you needed to do this. Please be sure to + * include the operating system you are using. + */ + /* WARNING: All errors will be handled as not found + */ +#if !defined(ENOENT) + return APR_ENOENT; +#else + /* WARNING: All errors but not found will be handled as not directory + */ + if (errno != ENOENT) + return APR_ENOENT; + else + return errno; +#endif +#else /* All was defined well, report the usual: */ + return errno; +#endif + } +} diff --git a/include/apr_file_io.h b/include/apr_file_io.h index af93193..bdc6aa4 100644 --- a/include/apr_file_io.h +++ b/include/apr_file_io.h @@ -996,6 +996,23 @@ APR_DECLARE(apr_status_t) apr_file_mktemp(apr_file_t **fp, char *templ, APR_DECLARE(apr_status_t) apr_temp_dir_get(const char **temp_dir, apr_pool_t *p); +/** + * Get the specified file's stats. The file is specified by file + * descriptor. + * @param finfo Where to store the information about the file, which is + * never touched if the call fails. + * @param fd The file descriptor of the file to stat. + * @param wanted The desired apr_finfo_t fields, as a bit flag of APR_FINFO_ + values + * @param pool the pool to use to allocate the new file. + * + * @note If @c APR_INCOMPLETE is returned all the fields in @a finfo may + * not be filled in, and you need to check the @c finfo->valid bitmask + * to verify that what you're looking for is there. + */ +APR_DECLARE(apr_status_t) apr_stat_fd(apr_finfo_t *finfo, apr_file_t *fd, + apr_int32_t wanted, apr_pool_t *pool); + /** @} */ #ifdef __cplusplus
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor