public inbox for fstests@vger.kernel.org
 help / color / mirror / Atom feed
From: Amir Goldstein <amir73il@gmail.com>
To: Eryu Guan <guaneryu@gmail.com>
Cc: fstests@vger.kernel.org
Subject: [PATCH] open_by_handle: fix name of directory in error messages
Date: Fri, 24 Aug 2018 07:27:55 +0300	[thread overview]
Message-ID: <1535084875-22879-1-git-send-email-amir73il@gmail.com> (raw)

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().

Signed-off-by: Amir Goldstein <amir73il@gmail.com>
---
 src/open_by_handle.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/src/open_by_handle.c b/src/open_by_handle.c
index 36f2b07..4fdfacd 100644
--- a/src/open_by_handle.c
+++ b/src/open_by_handle.c
@@ -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) {
-- 
2.7.4

                 reply	other threads:[~2018-08-24  7:58 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1535084875-22879-1-git-send-email-amir73il@gmail.com \
    --to=amir73il@gmail.com \
    --cc=fstests@vger.kernel.org \
    --cc=guaneryu@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox