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/.
This commit is contained in:
parent
8735863465
commit
76423e6e3c
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=216379
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user