Skip to contentSkip to conversation

xfstests: resolve symlinked devices to real paths

PATCH In review Eric Sandeen 4 participants 9 messages Jun 8, 2010 – Nov 20, 2012

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 xfstests: resolve symlinked devices to real paths

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.

---

common.config +9 -0
index 926846b..e5b2483 100644
@@ -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"
src/Makefile +2 -1
index 976133d..2399853 100644
@@ -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 \
src/realpath.c new file +32 -0
new file mode 100644
index 0000000..997b1aa
@@ -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
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs

Reviewed-by on v1 1/1
#1 lore raw

common.config

Quoted 20 lines · Eric Sandeen

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.

---

common.config +0 -0
index 926846b..e5b2483 100644

Looks good

Eric,

This patch has been committed to git://oss.sgi.com/xfs/cmds/xfstests, master branch, commit ID d5ea873f.

Thanks
--Rich

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs

#2 lore raw

PATCH 1/1 xfstests: fix to build src/realpath and the correct the existence of target devices

Hi Rich, Eric

Quoted 24 lines · Rich Johnston

common.config

Quoted 20 lines · Eric Sandeen

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.

---

common.config +0 -0
index 926846b..e5b2483 100644

Looks good

Quoted 5 lines

Eric,

This patch has been committed to git://oss.sgi.com/xfs/cmds/xfstests, master branch, commit ID d5ea873f.

From: Satoru Takeuchi <[email protected]>

Commit d5ea873f is not the same as the the following original Eric's patch.

http://oss.sgi.com/archives/xfs/2010-06/msg00080.html

It does not modify src/Makefile and realpath is never compiled.

In addition, [ -L $TEST_DEV ]' and [ -L $SCRATCH_DEV ]' always returns 0 if $TEST_DEV or $SCRATCH_DEV are not defined.

Cc Eric Sandeen <[email protected]>
Cc Rich Johnston <[email protected]>
---
 common.config |    4 ++--
 src/Makefile  |    2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)
common.config +2 -2
index 585b150..3240ee9 100644
@@ -221,11 +221,11 @@ else
 fi
 
 # Scripts just don't deal well with symlinked devices
-if [ -L $TEST_DEV ]; then
+if [ -L "$TEST_DEV" ]; then
         TEST_DEV=`src/realpath $TEST_DEV`
 fi
 
-if [ -L $SCRATCH_DEV ]; then
+if [ -L "$SCRATCH_DEV" ]; then
         SCRATCH_DEV=`src/realpath $SCRATCH_DEV`
 fi
 
src/Makefile +1 -1
index f7362a2..9f7281d 100644
@@ -11,7 +11,7 @@ TARGETS = dirstress fill fill2 getpagesize holes lstat64 \
        devzero feature alloc fault fstest t_access_root \
        godown resvtest writemod makeextents itrash rename \
        multi_open_unlink dmiperf unwritten_sync genhashnames t_holes \
-       t_mmap_writev
+       t_mmap_writev realpath
 
 LINUX_TARGETS = xfsctl bstat t_mtab getdevicesize preallo_rw_pattern_reader \
        preallo_rw_pattern_writer ftrunc trunc fs_perms testx looptest \
Signature · 7 lines
1.7.7.6


_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
Reviewed-by on v1 1/1
#3 lore raw

Re: [PATCH] xfstests: fix to build src/realpath and the correct the existence of target devices

Quoted 39 lines · sat

Hi Rich, Eric

Quoted 24 lines · Rich Johnston

common.config

Quoted 20 lines · Eric Sandeen

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.

---

common.config +0 -0
index 926846b..e5b2483 100644

Looks good

Quoted 5 lines

Eric,

This patch has been committed to git://oss.sgi.com/xfs/cmds/xfstests, master branch, commit ID d5ea873f.

From: Satoru Takeuchi <[email protected]>

Commit d5ea873f is not the same as the the following original Eric's patch.

http://oss.sgi.com/archives/xfs/2010-06/msg00080.html

Quoted 8 lines

It does not modify src/Makefile and realpath is never compiled.

In addition, [ -L $TEST_DEV ]' and [ -L $SCRATCH_DEV ]' always returns 0 if $TEST_DEV or $SCRATCH_DEV are not defined.

Cc Eric Sandeen <[email protected]>
Cc Rich Johnston <[email protected]>
Quoted 30 lines
---
 common.config |    4 ++--
 src/Makefile  |    2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)
common.config +2 -2
index 585b150..3240ee9 100644
@@ -221,11 +221,11 @@ else
 fi
 
 # Scripts just don't deal well with symlinked devices
-if [ -L $TEST_DEV ]; then
+if [ -L "$TEST_DEV" ]; then
         TEST_DEV=`src/realpath $TEST_DEV`
 fi
 
-if [ -L $SCRATCH_DEV ]; then
+if [ -L "$SCRATCH_DEV" ]; then
         SCRATCH_DEV=`src/realpath $SCRATCH_DEV`
 fi
 
src/Makefile +0 -0
index f7362a2..9f7281d 100644

src/Makefile TARGETS = dirstress fill fill2 getpagesize holes lstat64 \ · line 17

Quoted 8 lines
src/Makefile +1 -1
@@ -11,7 +11,7 @@ TARGETS = dirstress fill fill2 getpagesize holes lstat64 \
        devzero feature alloc fault fstest t_access_root \
        godown resvtest writemod makeextents itrash rename \
        multi_open_unlink dmiperf unwritten_sync genhashnames t_holes \
-       t_mmap_writev
+       t_mmap_writev realpath
 
 LINUX_TARGETS = xfsctl bstat t_mtab getdevicesize preallo_rw_pattern_reader \
        preallo_rw_pattern_writer ftrunc trunc fs_perms testx looptest \

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs

author Reviewed-by on v1 1/1
#4 lore raw

Re: [PATCH] xfstests: fix to build src/realpath and the correct the existence of target devices

In reply to sat
Quoted 33 lines · sat

Hi Rich, Eric

Quoted 24 lines · Rich Johnston

common.config

Quoted 20 lines · Eric Sandeen

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.

---

common.config +0 -0
index 926846b..e5b2483 100644

Looks good

Quoted 5 lines

Eric,

This patch has been committed to git://oss.sgi.com/xfs/cmds/xfstests, master branch, commit ID d5ea873f.

Quoted 7 lines

From: Satoru Takeuchi <[email protected]>

Commit d5ea873f is not the same as the the following original Eric's patch.

http://oss.sgi.com/archives/xfs/2010-06/msg00080.html

It does not modify src/Makefile and realpath is never compiled.

Yep, whoops. Merge error . . .?

Quoted 2 lines

In addition, [ -L $TEST_DEV ]' and [ -L $SCRATCH_DEV ]' always returns 0 if $TEST_DEV or $SCRATCH_DEV are not defined.

Well, I don't think ./check will get very far with an undefined TEST_DEV or SCRATCH_DEV, but better this way, thanks.

Quoted 33 lines
Cc Eric Sandeen <[email protected]>
Cc Rich Johnston <[email protected]>
---
 common.config |    4 ++--
 src/Makefile  |    2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)
common.config +2 -2
index 585b150..3240ee9 100644
@@ -221,11 +221,11 @@ else
 fi
 
 # Scripts just don't deal well with symlinked devices
-if [ -L $TEST_DEV ]; then
+if [ -L "$TEST_DEV" ]; then
         TEST_DEV=`src/realpath $TEST_DEV`
 fi
 
-if [ -L $SCRATCH_DEV ]; then
+if [ -L "$SCRATCH_DEV" ]; then
         SCRATCH_DEV=`src/realpath $SCRATCH_DEV`
 fi
 
src/Makefile +0 -0
index f7362a2..9f7281d 100644

src/Makefile TARGETS = dirstress fill fill2 getpagesize holes lstat64 \ · line 17

Quoted 8 lines
src/Makefile +1 -1
@@ -11,7 +11,7 @@ TARGETS = dirstress fill fill2 getpagesize holes lstat64 \
        devzero feature alloc fault fstest t_access_root \
        godown resvtest writemod makeextents itrash rename \
        multi_open_unlink dmiperf unwritten_sync genhashnames t_holes \
-       t_mmap_writev
+       t_mmap_writev realpath
 
 LINUX_TARGETS = xfsctl bstat t_mtab getdevicesize preallo_rw_pattern_reader \
        preallo_rw_pattern_writer ftrunc trunc fs_perms testx looptest \

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs

#5 lore raw

Re: [PATCH] xfstests: fix to build src/realpath and the correct the existence of target devices

Quoted 42 lines · Eric Sandeen
Quoted 33 lines · sat

Hi Rich, Eric

Quoted 24 lines · Rich Johnston

common.config

Quoted 20 lines · Eric Sandeen

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.

---

common.config +0 -0
index 926846b..e5b2483 100644

Looks good

Quoted 5 lines

Eric,

This patch has been committed to git://oss.sgi.com/xfs/cmds/xfstests, master branch, commit ID d5ea873f.

Quoted 7 lines

From: Satoru Takeuchi <[email protected]>

Commit d5ea873f is not the same as the the following original Eric's patch.

http://oss.sgi.com/archives/xfs/2010-06/msg00080.html

It does not modify src/Makefile and realpath is never compiled.

Quoted 7 lines

Yep, whoops. Merge error . . .?

Quoted 2 lines

In addition, [ -L $TEST_DEV ]' and [ -L $SCRATCH_DEV ]' always returns 0 if $TEST_DEV or $SCRATCH_DEV are not defined.

Well, I don't think ./check will get very far with an undefined TEST_DEV or SCRATCH_DEV, but better this way, thanks.

I think so too. But setting $SCRATCH_DEV is optional anyaway (refer to README). I forgot to specify $SCRATCH_DEV and found this problem.

Satoru

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs

#6 lore raw

Re: [PATCH] xfstests: fix to build src/realpath and the correct the existence of target devices

Quoted 45 lines · sat
Quoted 44 lines · Eric Sandeen
Quoted 33 lines · sat

Hi Rich, Eric

Quoted 24 lines · Rich Johnston

common.config

Quoted 20 lines · Eric Sandeen

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.

---

common.config +0 -0
index 926846b..e5b2483 100644

Looks good

Quoted 5 lines

Eric,

This patch has been committed to git://oss.sgi.com/xfs/cmds/xfstests, master branch, commit ID d5ea873f.

Quoted 7 lines

From: Satoru Takeuchi <[email protected]>

Commit d5ea873f is not the same as the the following original Eric's patch.

http://oss.sgi.com/archives/xfs/2010-06/msg00080.html

It does not modify src/Makefile and realpath is never compiled.

Yep, whoops. Merge error . . .?

Quoted 8 lines
Quoted 5 lines
Quoted 2 lines

In addition, [ -L $TEST_DEV ]' and [ -L $SCRATCH_DEV ]' always returns 0 if $TEST_DEV or $SCRATCH_DEV are not defined.

Well, I don't think ./check will get very far with an undefined TEST_DEV or SCRATCH_DEV, but better this way, thanks.

I think so too. But setting $SCRATCH_DEV is optional anyaway (refer to README). I forgot to specify $SCRATCH_DEV and found this problem.

Ah, right - yes, that's perfectly valid, sorry. Not thinking straight :)

-Eric

Quoted 3 lines

Satoru

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs

#7 lore raw

Re: [PATCH] xfstests: fix to build src/realpath and the correct the existence of target devices

Quoted 38 lines · Eric Sandeen
Quoted 37 lines · sat
Quoted 36 lines · Eric Sandeen
Quoted 35 lines · sat

Hi Rich, Eric

Quoted 24 lines · Rich Johnston

common.config

Quoted 20 lines · Eric Sandeen

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.

---

common.config +0 -0
index 926846b..e5b2483 100644

Looks good

Quoted 5 lines

Eric,

This patch has been committed to git://oss.sgi.com/xfs/cmds/xfstests, master branch, commit ID d5ea873f.

From: Satoru Takeuchi <[email protected]>

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 5 lines

Commit d5ea873f is not the same as the the following original Eric's patch.

http://oss.sgi.com/archives/xfs/2010-06/msg00080.html

It does not modify src/Makefile and realpath is never compiled.

Yep, whoops. Merge error . . .?

Yes sorry my bad.

Quoted 7 lines
Quoted 7 lines
Quoted 6 lines
Quoted 3 lines

In addition, [ -L $TEST_DEV ]' and [ -L $SCRATCH_DEV ]' always returns 0 if $TEST_DEV or $SCRATCH_DEV are not defined.

Well, I don't think ./check will get very far with an undefined TEST_DEV or SCRATCH_DEV, but better this way, thanks.

Quoted 6 lines
Quoted 2 lines

I think so too. But setting $SCRATCH_DEV is optional anyaway (refer to README). I forgot to specify $SCRATCH_DEV and found this problem.

Ah, right - yes, that's perfectly valid, sorry. Not thinking straight :)

-Eric

Eric, do you have time to correct these 2 errors or do want me submit a patch?

Quoted 5 lines
Quoted 4 lines

Satoru

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs

#8 lore raw

Re: [PATCH] xfstests: fix to build src/realpath and the correct the existence of target devices

Quoted 56 lines · Rich Johnston
Quoted 38 lines · Eric Sandeen
Quoted 37 lines · sat
Quoted 36 lines · Eric Sandeen
Quoted 35 lines · sat

Hi Rich, Eric

Quoted 24 lines · Rich Johnston

common.config

Quoted 20 lines · Eric Sandeen

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.

---

common.config +0 -0
index 926846b..e5b2483 100644

Looks good

Quoted 5 lines

Eric,

This patch has been committed to git://oss.sgi.com/xfs/cmds/xfstests, master branch, commit ID d5ea873f.

From: Satoru Takeuchi <[email protected]>

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 5 lines

Commit d5ea873f is not the same as the the following original Eric's patch.

http://oss.sgi.com/archives/xfs/2010-06/msg00080.html

It does not modify src/Makefile and realpath is never compiled.

Yep, whoops. Merge error . . .?

Yes sorry my bad.

Quoted 7 lines
Quoted 7 lines
Quoted 6 lines
Quoted 3 lines

In addition, [ -L $TEST_DEV ]' and [ -L $SCRATCH_DEV ]' always returns 0 if $TEST_DEV or $SCRATCH_DEV are not defined.

Well, I don't think ./check will get very far with an undefined TEST_DEV or SCRATCH_DEV, but better this way, thanks.

Quoted 9 lines
Quoted 6 lines
Quoted 2 lines

I think so too. But setting $SCRATCH_DEV is optional anyaway (refer to README). I forgot to specify $SCRATCH_DEV and found this problem.

Ah, right - yes, that's perfectly valid, sorry. Not thinking straight :)

-Eric

Eric, do you have time to correct these 2 errors or do want me submit a patch?

Satoru had submitted the patch and it has 2 reviews on list, just look up-thread. :)

Eric

Quoted 7 lines
Quoted 5 lines
Quoted 4 lines

Satoru

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs