Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 25 Sep 2014 22:22:43 +0000 (UTC)
From:      Xin LI <delphij@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r272139 - head/contrib/hyperv/tools
Message-ID:  <201409252222.s8PMMh2L036173@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
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++)



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201409252222.s8PMMh2L036173>