summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorNikolay Borisov <[email protected]>2016-08-16 23:00:16 +0300
committerBrian Behlendorf <[email protected]>2016-08-16 15:30:20 -0700
commit8658115c19f84b30d68402c32a33a2157c97e4f1 (patch)
treec26f5c5515bec93c6e365798a62e5c283c149a01 /tests
parentd9eea113f8b8988a8ec4f9c73b717c7311322348 (diff)
Fix do_link portion of ctime test
From the man page of dirname: " Both dirname() and basename() may modify the contents of path, so it may be desirable to pass a copy when calling one of these functions." And in fact on linux using dirname actually changes the contents of the passed parameter as evident from the following failure when running the ctime test: link(/root/zfs-mount, /root/zfs-mount/link_file) Fix this by creating a copy of the input parameter and passing that to dirname, thus not compromising the original parameter, allowing the creation of hard link to succeed. Signed-off-by: Nikolay Borisov <[email protected]> Signed-off-by: Brian Behlendorf <[email protected]> Closes #4977
Diffstat (limited to 'tests')
-rw-r--r--tests/zfs-tests/tests/functional/ctime/ctime_001_pos.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/tests/zfs-tests/tests/functional/ctime/ctime_001_pos.c b/tests/zfs-tests/tests/functional/ctime/ctime_001_pos.c
index 0c0615ff5..e1b244ee9 100644
--- a/tests/zfs-tests/tests/functional/ctime/ctime_001_pos.c
+++ b/tests/zfs-tests/tests/functional/ctime/ctime_001_pos.c
@@ -145,17 +145,19 @@ do_link(const char *pfile)
{
int ret = 0;
char link_file[BUFSIZ] = { 0 };
+ char pfile_copy[BUFSIZ] = { 0 };
char *dname;
if (pfile == NULL) {
return (-1);
}
+ strcpy(pfile_copy, pfile);
/*
* Figure out source file directory name, and create
* the link file in the same directory.
*/
- dname = dirname((char *)pfile);
+ dname = dirname((char *)pfile_copy);
(void) snprintf(link_file, BUFSIZ, "%s/%s", dname, "link_file");
if (link(pfile, link_file) == -1) {