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
This commit is contained in:
Xin LI 2014-09-25 22:22:43 +00:00
parent dde47d8bbc
commit be930504be
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=272139

View File

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