From: Rahul Bedarkar Date: Wed, 27 Jul 2016 16:47:53 +0000 (+0530) Subject: utils: os_unix: Use access() for checking file existence X-Git-Tag: hostap_2_6~141 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a2072a29b9cece5a710871f1d0c1bf1d25e3a712;p=thirdparty%2Fhostap.git utils: os_unix: Use access() for checking file existence Trying to open file for checking file existence seems to be too much. Instead use access system call which is meant for the same. Signed-off-by: Rahul Bedarkar --- diff --git a/src/utils/os_unix.c b/src/utils/os_unix.c index 0118d9816..65c6fa412 100644 --- a/src/utils/os_unix.c +++ b/src/utils/os_unix.c @@ -435,11 +435,7 @@ char * os_readfile(const char *name, size_t *len) int os_file_exists(const char *fname) { - FILE *f = fopen(fname, "rb"); - if (f == NULL) - return 0; - fclose(f); - return 1; + return access(fname, F_OK) == 0; }