Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 11 Dec 2010 16:06:52 +0000 (UTC)
From:      Pawel Jakub Dawidek <pjd@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r216379 - head/tools/regression/sockets/sendfile
Message-ID:  <201012111606.oBBG6qUS011509@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: pjd
Date: Sat Dec 11 16:06:52 2010
New Revision: 216379
URL: http://svn.freebsd.org/changeset/base/216379

Log:
  Allow to specify path to a file we want to test with sendfile(2).
  This allows to specify selected file system and not only /tmp/.

Modified:
  head/tools/regression/sockets/sendfile/sendfile.c

Modified: head/tools/regression/sockets/sendfile/sendfile.c
==============================================================================
--- head/tools/regression/sockets/sendfile/sendfile.c	Sat Dec 11 13:35:25 2010	(r216378)
+++ head/tools/regression/sockets/sendfile/sendfile.c	Sat Dec 11 16:06:52 2010	(r216379)
@@ -35,6 +35,7 @@
 
 #include <err.h>
 #include <errno.h>
+#include <fcntl.h>
 #include <limits.h>
 #include <md5.h>
 #include <signal.h>
@@ -408,7 +409,7 @@ cleanup(void)
 }
 
 int
-main(void)
+main(int argc, char *argv[])
 {
 	char *page_buffer;
 	int pagesize;
@@ -422,8 +423,20 @@ main(void)
 		FAIL_ERR("malloc")
 	bzero(page_buffer, TEST_PAGES * pagesize);
 
-	snprintf(path, PATH_MAX, "/tmp/sendfile.XXXXXXXXXXXX");
-	file_fd = mkstemp(path);
+	if (argc == 1) {
+		snprintf(path, PATH_MAX, "/tmp/sendfile.XXXXXXXXXXXX");
+		file_fd = mkstemp(path);
+		if (file_fd == -1)
+			FAIL_ERR("mkstemp");
+	} else if (argc == 2) {
+		(void)strlcpy(path, argv[1], sizeof(path));
+		file_fd = open(path, O_CREAT | O_TRUNC | O_RDWR, 0600);
+		if (file_fd == -1)
+			FAIL_ERR("open");
+	} else {
+		FAIL("usage: sendfile [path]");
+	}
+
 	atexit(cleanup);
 
 	len = write(file_fd, page_buffer, TEST_PAGES * pagesize);



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201012111606.oBBG6qUS011509>