From patchwork Tue Jan 8 17:27:24 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [02/13] libnsdb: nsdb_update_nsdb() doesn't create /var/lib/fedfs/nsdbcerts Date: Tue, 08 Jan 2013 07:27:24 -0000 From: Chuck Lever X-Patchwork-Id: 210449 Message-Id: <20130108172723.65133.57698.stgit@seurat.1015granger.net> To: fedfs-utils-devel@oss.oracle.com "nsdbparams update -f foo -t 1 nsdb.example.net" fails if the nsdbcerts directory does not already exist. Create it automatically. Signed-off-by: Chuck Lever --- src/libnsdb/nsdb.c | 7 +++++++ 1 files changed, 7 insertions(+), 0 deletions(-) diff --git a/src/libnsdb/nsdb.c b/src/libnsdb/nsdb.c index 3f10c4d..7ef39d3 100644 --- a/src/libnsdb/nsdb.c +++ b/src/libnsdb/nsdb.c @@ -563,6 +563,13 @@ nsdb_new_certfile(const char *certdata, const unsigned int certlen, goto out; } + if (mkdir(fedfs_nsdbcerts_dirname, FEDFS_BASE_DIRMODE) == -1) { + if (errno != EEXIST) { + xlog(L_ERROR, "Failed to create certfile directory: %m"); + return FEDFS_ERR_SVRFAULT; + } + } + fd = open(pathbuf, O_WRONLY | O_SYNC | O_CREAT | O_EXCL, S_IRUSR | S_IWUSR | S_IRGRP); if (fd == -1) {