Commit 71bae255 authored by Daniel Salzman's avatar Daniel Salzman

libdnssec: replace fs_mkdir with make_dir from contrib

parent 10c86c51
......@@ -283,8 +283,6 @@ src/libdnssec/shared/bignum.h
src/libdnssec/shared/binary_wire.h
src/libdnssec/shared/dname.c
src/libdnssec/shared/dname.h
src/libdnssec/shared/fs.c
src/libdnssec/shared/fs.h
src/libdnssec/shared/hex.c
src/libdnssec/shared/hex.h
src/libdnssec/shared/keyid_gnutls.c
......
......@@ -11,8 +11,6 @@ libshared_la_SOURCES = \
libdnssec/shared/binary_wire.h \
libdnssec/shared/dname.c \
libdnssec/shared/dname.h \
libdnssec/shared/fs.c \
libdnssec/shared/fs.h \
libdnssec/shared/hex.c \
libdnssec/shared/hex.h \
libdnssec/shared/keyid_gnutls.c \
......
......@@ -22,9 +22,9 @@
#include <sys/stat.h>
#include <sys/types.h>
#include "contrib/files.h"
#include "libdnssec/binary.h"
#include "libdnssec/error.h"
#include "libdnssec/shared/fs.h"
#include "libdnssec/key.h"
#include "libdnssec/keystore.h"
#include "libdnssec/keystore/internal.h"
......@@ -161,7 +161,7 @@ static int pkcs8_dir_init(void *handle, const char *path)
return DNSSEC_EINVAL;
}
return fs_mkdir(path, DIR_INIT_MODE, true);
return make_dir(path, DIR_INIT_MODE, true);
}
static int pkcs8_dir_open(void *_handle, const char *config)
......
/* Copyright (C) 2018 CZ.NIC, z.s.p.o. <knot-dns@labs.nic.cz>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#include <assert.h>
#include <stdbool.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>
#include "libdnssec/error.h"
int fs_mkdir(const char *path, mode_t mode, bool ignore_existing)
{
if (mkdir(path, mode) == 0) {
return DNSSEC_EOK;
}
if (!ignore_existing || errno != EEXIST) {
return dnssec_errno_to_error(errno);
}
assert(errno == EEXIST);
struct stat st = { 0 };
if (stat(path, &st) != 0) {
return dnssec_errno_to_error(errno);
}
if (!S_ISDIR(st.st_mode)) {
return dnssec_errno_to_error(ENOTDIR);
}
return DNSSEC_EOK;
}
/* Copyright (C) 2018 CZ.NIC, z.s.p.o. <knot-dns@labs.nic.cz>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#pragma once
#include <stdbool.h>
#include <sys/types.h>
/*!
* Equivalent to mkdir(2), can succeed if the directory already exists.
*/
int fs_mkdir(const char *path, mode_t mode, bool ignore_existing);
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment