mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2024-12-25 18:59:33 +03:00
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 <n.borisov.lkml@gmail.com> Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov> Closes #4977
This commit is contained in:
parent
d9eea113f8
commit
8658115c19
@ -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) {
|
||||
|
Loading…
Reference in New Issue
Block a user