svn commit: r272139 - head/contrib/hyperv/tools

Xin LI delphij at FreeBSD.org
Thu Sep 25 22:22:44 UTC 2014


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++)


More information about the svn-src-all mailing list