From: Eric Sandeen <sandeen@sandeen.net>
To: xfs mailing list <xfs@oss.sgi.com>
Subject: [PATCH] xfstests: resolve symlinked devices to real paths
Date: Tue, 08 Jun 2010 15:03:39 -0500 [thread overview]
Message-ID: <4C0EA21B.8020703@sandeen.net> (raw)
If you try running xfstests on lvm volumes which are symlinks,
it'll fail to run several tests because our _require_scratch
framework ultimately uses lstat not stat, and does not think
the lvm device (which is usually a symlink to a dm-X device)
is a block device. Sigh.
Last try at this - just resolve any symlinked devicenames
into their realpath(3) in common.config.
This actually seems to work.
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
---
diff --git a/common.config b/common.config
index 926846b..e5b2483 100644
--- a/common.config
+++ b/common.config
@@ -208,6 +208,15 @@ else
known_hosts
fi
+# Scripts just don't deal well with symlinked devices
+if [ -L $TEST_DEV ]; then
+ TEST_DEV=`src/realpath $TEST_DEV`
+fi
+
+if [ -L $SCRATCH_DEV ]; then
+ SCRATCH_DEV=`src/realpath $SCRATCH_DEV`
+fi
+
echo $TEST_DEV | grep -q ":" > /dev/null 2>&1
if [ ! -b "$TEST_DEV" -a "$?" != "0" ]; then
echo "common.config: Error: \$TEST_DEV ($TEST_DEV) is not a block device or a NFS filesystem"
diff --git a/src/Makefile b/src/Makefile
index 976133d..2399853 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -10,7 +10,8 @@ TARGETS = dirstress fill fill2 getpagesize holes lstat64 \
mmapcat append_reader append_writer dirperf metaperf \
devzero feature alloc fault fstest t_access_root \
godown resvtest writemod makeextents itrash rename \
- multi_open_unlink dmiperf unwritten_sync genhashnames t_holes
+ multi_open_unlink dmiperf unwritten_sync genhashnames t_holes \
+ realpath
LINUX_TARGETS = xfsctl bstat t_mtab getdevicesize preallo_rw_pattern_reader \
preallo_rw_pattern_writer ftrunc trunc fs_perms testx looptest \
diff --git a/src/realpath.c b/src/realpath.c
new file mode 100644
index 0000000..997b1aa
--- /dev/null
+++ b/src/realpath.c
@@ -0,0 +1,32 @@
+#include <limits.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+
+/*
+ * Simple wrapper around realpath(3) to get absolute path
+ * to a device name; many xfstests scripts don't cope well
+ * with symlinked devices due to differences in /proc/mounts,
+ * /etc/mtab, mount output, etc.
+ */
+
+int main(int argc, char *argv[])
+{
+ char path[PATH_MAX];
+ char resolved_path[PATH_MAX];
+
+ if (argc != 2) {
+ printf("Usage: %s <filename>\n", argv[0]);
+ return 1;
+ }
+
+ strncpy(path, argv[1], PATH_MAX-1);
+
+ if (!realpath(path, resolved_path)) {
+ perror("Failed to resolve path for %s");
+ return 1;
+ }
+
+ printf("%s\n", resolved_path);
+ return 0;
+}
_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs
next reply other threads:[~2010-06-08 20:01 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-06-08 20:03 Eric Sandeen [this message]
2012-10-26 16:46 ` xfstests: resolve symlinked devices to real paths Rich Johnston
2012-11-19 3:26 ` [PATCH] xfstests: fix to build src/realpath and the correct the existence of target devices sat
2012-11-19 3:55 ` Wanlong Gao
2012-11-20 4:06 ` Eric Sandeen
2012-11-20 4:30 ` sat
2012-11-20 5:28 ` Eric Sandeen
2012-11-20 13:53 ` Rich Johnston
2012-11-20 14:05 ` Eric Sandeen
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=4C0EA21B.8020703@sandeen.net \
--to=sandeen@sandeen.net \
--cc=xfs@oss.sgi.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