From 504f7802d4c9b43db4820f496c4d00e078effa18 Mon Sep 17 00:00:00 2001 From: David Lawrence Date: Fri, 8 Jun 2001 21:53:49 +0000 Subject: [PATCH] 893. [func] Removed isc_file_test() and added isc_file_exists() for the basic functionality that was being added with isc_file_test(). --- CHANGES | 4 +++ bin/rndc/rndc.c | 6 ++--- lib/isc/include/isc/file.h | 55 ++++---------------------------------- lib/isc/unix/file.c | 29 +++----------------- 4 files changed, 15 insertions(+), 79 deletions(-) diff --git a/CHANGES b/CHANGES index 1647eafead..0b7aec4c97 100644 --- a/CHANGES +++ b/CHANGES @@ -1,4 +1,8 @@ + 893. [func] Removed isc_file_test() and added isc_file_exists() + for the basic functionality that was being added + with isc_file_test(). + 892. [placeholder] 891. [bug] Return an error when a SIG(0) signed response to diff --git a/bin/rndc/rndc.c b/bin/rndc/rndc.c index 8c0fde3e6e..5de6b9de1f 100644 --- a/bin/rndc/rndc.c +++ b/bin/rndc/rndc.c @@ -15,7 +15,7 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: rndc.c,v 1.62 2001/05/31 10:42:49 tale Exp $ */ +/* $Id: rndc.c,v 1.63 2001/06/08 21:53:47 tale Exp $ */ /* * Principal Author: DCL @@ -351,10 +351,10 @@ parse_config(isc_mem_t *mctx, isc_log_t *log, cfg_parser_t **pctxp, isc_result_t result; const char *conffile = admin_conffile; - if (! isc_file_test(conffile, ISC_FILE_EXISTS)) { + if (! isc_file_exists(conffile)) { conffile = auto_conffile; - if (! isc_file_test(conffile, ISC_FILE_EXISTS)) + if (! isc_file_exists(conffile)) fatal("neither %s nor %s was found", admin_conffile, auto_conffile); } diff --git a/lib/isc/include/isc/file.h b/lib/isc/include/isc/file.h index 9541d3e0ec..5b89efce75 100644 --- a/lib/isc/include/isc/file.h +++ b/lib/isc/include/isc/file.h @@ -15,7 +15,7 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: file.h,v 1.19 2001/05/31 10:53:13 tale Exp $ */ +/* $Id: file.h,v 1.20 2001/06/08 21:53:48 tale Exp $ */ #ifndef ISC_FILE_H #define ISC_FILE_H 1 @@ -25,39 +25,6 @@ #include #include -/* - * Definitions for the isc_file_test() 'what' argument. - * - * Notes: - * ISC_FILE_EXISTS tests for existence, but not type. It can fail - * if the user does not have sufficient permissions to explore the - * full path of the file. - * - * ISC_FILE_ABSOLUTE tests for pathnames that start from the root - * of a filesystem hierarchy. - * - * ISC_FILE_CURRENTDIR is an extremely simplistic test. On Unix systems, - * it only returns true if the pathname is ".". It will return false - * for "subdir/..", for example. - * - * Unimplemented, perhaps desirable: - * ISC_FILE_REGULAR - * ISC_FILE_DIRECTORY - * ISC_FILE_SYMLINK - * ISC_FILE_SPECIAL - * ISC_FILE_BLOCK ? - * ISC_FILE_CHARACTER ? - * ISC_FILE_PIPE ? - * ISC_FILE_SOCKET ? - * ISC_FILE_READABLE - * ISC_FILE_WRITABLE - * ISC_FILE_RUNABLE - * ISC_FILE_EMPTY - */ -#define ISC_FILE_EXISTS 0x00000001 -#define ISC_FILE_ABSOLUTE 0x00000002 -#define ISC_FILE_CURRENTDIR 0x00000004 - ISC_LANG_BEGINDECLS isc_result_t @@ -199,23 +166,11 @@ isc_file_rename(const char *oldname, const char *newname); */ isc_boolean_t -isc_file_test(const char *filename, isc_uint32_t what); +isc_file_exists(const char *pathname); /* - * Test for various file attributes, such as existence or writability. - * - * Notes: - * This is like the Unix shell test(1) command. - * - * If more than one test is specified in 'what' then ALL - * of them must be true for ISC_TRUE to be returned. - * To test instead for traits that can be independently true, - * use multiple calls to isc_file_test(). - * - * Functionality is being added only as it is needed. See the list - * at the start of the file for which tests have been implemented. - * - * It is intended that this function will supersede both - * isc_file_isabsolute() and isc_file_iscurrentdir(). + * Return ISC_TRUE iff the calling process can tell that the given file exists. + * Will not return true if the calling process has insufficient privileges + * to search the entire path. */ isc_boolean_t diff --git a/lib/isc/unix/file.c b/lib/isc/unix/file.c index 2c98d54d6d..b2fb04f3bb 100644 --- a/lib/isc/unix/file.c +++ b/lib/isc/unix/file.c @@ -15,7 +15,7 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: file.c,v 1.34 2001/05/31 10:53:14 tale Exp $ */ +/* $Id: file.c,v 1.35 2001/06/08 21:53:49 tale Exp $ */ #include @@ -226,33 +226,10 @@ isc_file_rename(const char *oldname, const char *newname) { } isc_boolean_t -isc_file_test(const char *pathname, isc_uint32_t what) { - isc_boolean_t tf = ISC_TRUE; - isc_result_t result; +isc_file_exists(const char *pathname) { struct stat stats; - INSIST(what != 0); - INSIST((what & ~(ISC_FILE_EXISTS | - ISC_FILE_ABSOLUTE | - ISC_FILE_CURRENTDIR)) - == 0); - - if ((what & ISC_FILE_EXISTS) != 0) { - /* - * When file type tests are implemented, only one - * file_stats() should be done. - */ - result = file_stats(pathname, &stats); - tf = ISC_TF(tf && result == ISC_R_SUCCESS); - } - - if ((what & ISC_FILE_ABSOLUTE) != 0) - tf = ISC_TF(tf && pathname[0] == '/'); - - if ((what & ISC_FILE_CURRENTDIR) != 0) - tf = ISC_TF(tf && pathname[0] == '.' && pathname[1] == '\0'); - - return (tf); + return (ISC_TF(file_stats(pathname, &stats) == ISC_R_SUCCESS)); } isc_boolean_t