$OpenBSD: patch-src_util_c,v 1.8 2014/07/11 15:49:58 dcoppa Exp $

commit c159fc4197ad06d603ba404add501ac02d76c64f
Author: Michael Stapelberg <michael@stapelberg.de>
Date:   Fri Jun 27 09:04:51 2014 +0200

Bugfix: create the directory for storing the restart state

--- src/util.c.orig	Sun Jun 15 19:12:43 2014
+++ src/util.c	Fri Jul 11 16:39:36 2014
@@ -249,6 +249,15 @@ char *store_restart_layout(void) {
         filename = resolve_tilde(config.restart_state_path);
     }
 
+    /* create the directory, it could have been cleaned up before restarting or
+     * may not exist at all in case it was user-specified. */
+    char *filenamecopy = sstrdup(filename);
+    char *base = dirname(filenamecopy);
+    DLOG("Creating \"%s\" for storing the restart layout\n", base);
+    if (!mkdirp(base))
+        ELOG("Could not create \"%s\" for storing the restart layout, layout will be lost.\n", base);
+    free(filenamecopy);
+
     int fd = open(filename, O_WRONLY | O_CREAT | O_TRUNC, S_IRUSR | S_IWUSR);
     if (fd == -1) {
         perror("open()");
