Author: delphij
Date: Thu Sep 25 22:22:43 2014
New Revision: 272139
URL: http://svnweb.freebsd.org/changeset/base/272139

Log:
  Being able to access a path do not necessarily mean we have access
  to a directory. So instead of doing this, we just call mkdir(2)
  directly and test if the returned value is 0 or errno is EISDIR.
  
  Reported by:  Coverity
  CID:          1238925
  MFC after:    1 week

Modified:
  head/contrib/hyperv/tools/hv_kvp_daemon.c

Modified: head/contrib/hyperv/tools/hv_kvp_daemon.c
==============================================================================
--- head/contrib/hyperv/tools/hv_kvp_daemon.c   Thu Sep 25 22:15:10 2014        
(r272138)
+++ head/contrib/hyperv/tools/hv_kvp_daemon.c   Thu Sep 25 22:22:43 2014        
(r272139)
@@ -284,12 +284,10 @@ kvp_file_init(void)
        int i;
        int alloc_unit = sizeof(struct kvp_record) * ENTRIES_PER_BLOCK;
 
-       if (access("/var/db/hyperv/pool", F_OK)) {
-               if (mkdir("/var/db/hyperv/pool",
-                   S_IRUSR | S_IWUSR | S_IROTH)) {
-                       KVP_LOG(LOG_ERR, " Failed to create 
/var/db/hyperv/pool\n");
-                       exit(EXIT_FAILURE);
-               }
+       if (mkdir("/var/db/hyperv/pool", S_IRUSR | S_IWUSR | S_IROTH) < 0 &&
+           errno != EISDIR) {
+               KVP_LOG(LOG_ERR, " Failed to create /var/db/hyperv/pool\n");
+               exit(EXIT_FAILURE);
        }
 
        for (i = 0; i < HV_KVP_POOL_COUNT; i++)
_______________________________________________
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"

Reply via email to