[master] 94fe4da Try to create a file in our workdir early on and give a suggestion if it fails.

Poul-Henning Kamp phk at varnish-cache.org
Wed Jun 13 09:59:11 CEST 2012


commit 94fe4daba6b51a2e97eee5f9d4719a4123179d86
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date:   Wed Jun 13 07:58:43 2012 +0000

    Try to create a file in our workdir early on and give a suggestion
    if it fails.

diff --git a/bin/varnishd/mgt/mgt_main.c b/bin/varnishd/mgt/mgt_main.c
index 13799f9..88f8253 100644
--- a/bin/varnishd/mgt/mgt_main.c
+++ b/bin/varnishd/mgt/mgt_main.c
@@ -275,7 +275,7 @@ cli_stdin_close(void *priv)
 int
 main(int argc, char * const *argv)
 {
-	int o;
+	int o, fd;
 	unsigned C_flag = 0;
 	unsigned F_flag = 0;
 	const char *b_arg = NULL;
@@ -530,7 +530,7 @@ main(int argc, char * const *argv)
 	}
 
 	if (n_arg != NULL)
-		openlog(n_arg, LOG_PID, LOG_LOCAL0);
+		openlog(n_arg, LOG_PID, LOG_LOCAL0);	/* XXX: i_arg ? */
 	else
 		openlog("varnishd", LOG_PID, LOG_LOCAL0);
 
@@ -546,6 +546,17 @@ main(int argc, char * const *argv)
 		exit(1);
 	}
 
+	fd = open("_.testfile", O_RDWR|O_CREAT|O_EXCL, 0600);
+	if (fd < 0) {
+		fprintf(stderr, "Cannot create test-file in %s (%s)\n",
+		    dirname, strerror(errno));
+		fprintf(stderr,
+		    "Check permissions (or delete old directory)\n");
+		exit(1);
+	}
+	AZ(close(fd));
+	AZ(unlink("_.testfile"));
+
 	/* XXX: should this be relative to the -n arg ? */
 	if (P_arg && (pfh = VPF_Open(P_arg, 0644, NULL)) == NULL) {
 		perror(P_arg);



More information about the varnish-commit mailing list