From owner-svn-src-all@FreeBSD.ORG Thu Sep 25 22:22:43 2014 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id E236316F; Thu, 25 Sep 2014 22:22:43 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id CDB2AA7E; Thu, 25 Sep 2014 22:22:43 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id s8PMMhxK036174; Thu, 25 Sep 2014 22:22:43 GMT (envelope-from delphij@FreeBSD.org) Received: (from delphij@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id s8PMMh2L036173; Thu, 25 Sep 2014 22:22:43 GMT (envelope-from delphij@FreeBSD.org) Message-Id: <201409252222.s8PMMh2L036173@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: delphij set sender to delphij@FreeBSD.org using -f From: Xin LI Date: Thu, 25 Sep 2014 22:22:43 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r272139 - head/contrib/hyperv/tools X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 25 Sep 2014 22:22:44 -0000 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++)