From: Amir Goldstein <amir73il@gmail.com>
To: Eryu Guan <eguan@redhat.com>
Cc: Jeff Layton <jlayton@poochiereds.net>,
"J . Bruce Fields" <bfields@fieldses.org>,
Miklos Szeredi <miklos@szeredi.hu>,
fstests@vger.kernel.org, linux-fsdevel@vger.kernel.org,
linux-unionfs@vger.kernel.org
Subject: [PATCH 1/7] open_by_handle: add filename to error reports
Date: Thu, 2 Nov 2017 12:15:33 +0200 [thread overview]
Message-ID: <1509617739-15744-2-git-send-email-amir73il@gmail.com> (raw)
In-Reply-To: <1509617739-15744-1-git-send-email-amir73il@gmail.com>
This makes it easier to understand which of the tests
failed when testing on overlay lower and upper files.
Signed-off-by: Amir Goldstein <amir73il@gmail.com>
---
src/open_by_handle.c | 23 +++++++++++++++--------
1 file changed, 15 insertions(+), 8 deletions(-)
diff --git a/src/open_by_handle.c b/src/open_by_handle.c
index 63ebdac..52973c6 100644
--- a/src/open_by_handle.c
+++ b/src/open_by_handle.c
@@ -156,7 +156,7 @@ int main(int argc, char **argv)
sprintf(fname2, "%s/link%06d", test_dir, i);
fd = open(fname, O_RDWR | O_CREAT | O_TRUNC, 0644);
if (fd < 0) {
- printf("Warning (%s,%d), open(%s) failed.\n", __FILE__, __LINE__, fname);
+ strcat(fname, ": open");
perror(fname);
return EXIT_FAILURE;
}
@@ -164,7 +164,8 @@ int main(int argc, char **argv)
/* blow up leftovers hardlinks if they exist */
ret = unlink(fname2);
if (ret < 0 && errno != ENOENT) {
- perror("unlink");
+ strcat(fname2, ": unlink");
+ perror(fname2);
return EXIT_FAILURE;
}
}
@@ -178,7 +179,8 @@ int main(int argc, char **argv)
handle[i].fh.handle_bytes = MAX_HANDLE_SZ;
ret = name_to_handle_at(AT_FDCWD, fname, &handle[i].fh, &mount_id, 0);
if (ret < 0) {
- perror("name_to_handle");
+ strcat(fname, ": name_to_handle");
+ perror(fname);
return EXIT_FAILURE;
}
}
@@ -193,7 +195,8 @@ int main(int argc, char **argv)
sprintf(fname2, "%s/link%06d", test_dir, i);
ret = link(fname, fname2);
if (ret < 0) {
- perror("link");
+ strcat(fname2, ": link");
+ perror(fname2);
return EXIT_FAILURE;
}
}
@@ -204,14 +207,16 @@ int main(int argc, char **argv)
sprintf(fname2, "%s/link%06d", test_dir, i);
ret = unlink(fname);
if (ret < 0) {
- perror("unlink");
+ strcat(fname, ": unlink");
+ perror(fname);
return EXIT_FAILURE;
}
/* with -d flag, delete the hardlink if it exists */
if (!nlink)
ret = unlink(fname2);
if (ret < 0 && errno != ENOENT) {
- perror("unlink");
+ strcat(fname2, ": unlink");
+ perror(fname2);
return EXIT_FAILURE;
}
}
@@ -246,11 +251,13 @@ int main(int argc, char **argv)
} else if (!nlink && fd < 0 && (errno == ENOENT || errno == ESTALE)) {
continue;
}
+ sprintf(fname, "%s/file%06d", test_dir, i);
if (fd >= 0) {
- printf("open_by_handle(%d) opened an unlinked file!\n", i);
+ printf("open_by_handle(%s) opened an unlinked file!\n", fname);
close(fd);
} else {
- printf("open_by_handle(%d) returned %d incorrectly on %s file!\n", i, errno,
+ printf("open_by_handle(%s) returned %d incorrectly on %s file!\n",
+ fname, errno,
nlink ? "a linked" : "an unlinked");
}
failed++;
--
2.7.4
next prev parent reply other threads:[~2017-11-02 10:14 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-11-02 10:15 [PATCH 0/7] More NFS file handle unit tests Amir Goldstein
2017-11-02 10:15 ` Amir Goldstein [this message]
2017-11-02 10:15 ` [PATCH 2/7] open_by_handle: test file handles of renamed files Amir Goldstein
2017-11-08 4:10 ` Eryu Guan
2017-11-08 5:07 ` Eryu Guan
2017-11-08 6:11 ` Amir Goldstein
2017-11-02 10:15 ` [PATCH 3/7] open_by_handle: test content of open file handle Amir Goldstein
2017-11-02 10:15 ` [PATCH 4/7] open_by_handle: test directory " Amir Goldstein
2017-11-02 10:15 ` [PATCH 5/7] open_by_handle: test file handles of open files Amir Goldstein
2017-11-02 10:15 ` [PATCH 6/7] generic/426: factor out helper functions Amir Goldstein
2017-11-02 10:15 ` [PATCH 7/7] fstests: add test with more open by file handle use cases Amir Goldstein
2017-11-03 12:22 ` [PATCH 0/7] More NFS file handle unit tests Jeff Layton
2017-11-04 23:23 ` Jeff Layton
2017-11-07 19:54 ` J . Bruce Fields
2017-11-07 20:05 ` J . Bruce Fields
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=1509617739-15744-2-git-send-email-amir73il@gmail.com \
--to=amir73il@gmail.com \
--cc=bfields@fieldses.org \
--cc=eguan@redhat.com \
--cc=fstests@vger.kernel.org \
--cc=jlayton@poochiereds.net \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-unionfs@vger.kernel.org \
--cc=miklos@szeredi.hu \
/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