Skip to contentSkip to conversation

open_by_handle: fix name of directory in error messages

PATCH New Amir Goldstein 1 participant 1 message Aug 24, 2018

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 open_by_handle: fix name of directory in error messages

dirname() modifies the string in dname, but we use that string in error messages later on to print the test dir name. Make another copy of test_dir for passing to dirname().

---
 src/open_by_handle.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
src/open_by_handle.c +4 -2
index 36f2b07..4fdfacd 100644
@@ -123,6 +123,7 @@ int main(int argc, char **argv)
 	int	fd;
 	int	ret = 0;
 	int	failed = 0;
+	char	mname[PATH_MAX];
 	char	dname[PATH_MAX];
 	char	fname[PATH_MAX];
 	char	fname2[PATH_MAX];
@@ -240,9 +241,10 @@ int main(int argc, char **argv)
 	 *    the dentry cache and the use of -ip flag combination would not
 	 *    allow testing decode of dir file handle in cold dcache scenario.
 	 */
+	strcpy(dname, test_dir);
 	if (parent && !in_fd) {
-		strcpy(dname, test_dir);
-		mount_dir = dirname(dname);
+		strcpy(mname, test_dir);
+		mount_dir = dirname(mname);
 		if (create)
 			ret = mkdir(test_dir, 0700);
 		if (ret < 0 && errno != EEXIST) {
Signature · 1 line
2.7.4