xfstests: use stat not lstat when examining devices
PATCH 1/1 xfstests: use stat not lstat when examining devices
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.
It seems a little crummy to cut and paste lstat64.c to stat64.c but then adding an "-L" option to lstat64 to -not- stat the link seems all bass-ackwards.
We need something like this, but I'm open to suggestions of a better implementation. Even /usr/bin/stat -l may suffice, I don't know why we roll our own lstat64 binary.
---
common.rc +1 -1
@@ -584,7 +584,7 @@ _is_block_dev() exit 1 fi - [ -b $1 ] && src/lstat64 $1 | $AWK_PROG '/Device type:/ { print $9 }' + [ -b $1 ] && src/stat64 $1 | $AWK_PROG '/Device type:/ { print $9 }' } # Do a command, log it to $seq.full, optionally test return status
src/Makefile +1 -1
@@ -5,7 +5,7 @@ TOPDIR = .. include $(TOPDIR)/include/builddefs -TARGETS = dirstress fill fill2 getpagesize holes lstat64 \ +TARGETS = dirstress fill fill2 getpagesize holes stat64 lstat64 \ nametest permname randholes runas truncfile usemem \ mmapcat append_reader append_writer dirperf metaperf \ devzero feature alloc fault fstest t_access_root \
src/stat64.c new file +195 -0
195 lines not on this page · raw message
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
PATCH v2 1/1 xfstests: use stat not lstat when examining devices
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.
Adding a -l option to lstat64 in order to call stat not lstat, and stat the target of the link, should be a simple fix.
---
common.rc +1 -1
@@ -584,7 +584,7 @@ _is_block_dev() exit 1 fi - [ -b $1 ] && src/lstat64 $1 | $AWK_PROG '/Device type:/ { print $9 }' + [ -b $1 ] && src/lstat64 -l $1 | $AWK_PROG '/Device type:/ { print $9 }' } # Do a command, log it to $seq.full, optionally test return status
src/lstat64.c +11 -3
@@ -49,7 +49,7 @@ timesince(long timesec)void usage (void ) { -fprintf (stderr,"Usage: lstat64 [-t] filename ...\n" ); +fprintf (stderr,"Usage: lstat64 [-tl] filename ...\n" );exit (1 ); }
@@ -59,13 +59,18 @@ main(int argc, char **argv)struct stat64 sbuf;int i, c;int terse_flag =0 ; +int follow_flag =0 ; -while ((c =getopt (argc, argv,"t" )) !=EOF ) { +while ((c =getopt (argc, argv,"tl" )) !=EOF ) {switch (c) {case 't' : terse_flag =1 ;break ; +case 'l' : + follow_flag =1 ; +break ; +case '?' :usage (); }
@@ -79,7 +84,10 @@ main(int argc, char **argv)for (i = optind; i < argc; i++) {char mode[] ="----------" ; -if (lstat64 (argv[i], &sbuf) <0 ) { +if (!follow_flag &&lstat64 (argv[i], &sbuf) <0 ) { +perror (argv[i]); +continue ; + }else if (follow_flag &&stat64 (argv[i], &sbuf) <0 ) {perror (argv[i]);continue ; }
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
PATCH v3 1/1 xfstests: use stat not lstat when examining devices
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.
Just calling stat(1) with -L to follow the link should suffice.
---
common.rc +1 -1
@@ -584,7 +584,7 @@ _is_block_dev() exit 1 fi - [ -b $1 ] && src/lstat64 $1 | $AWK_PROG '/Device type:/ { print $9 }' + [ -b $1 ] && stat -L $1 | $AWK_PROG '/Device type:/ { print $9 }' } # Do a command, log it to $seq.full, optionally test return status
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
Quoted 8 lines · Eric Sandeen
If you try running xfstests on lvm volumes which are symlinks, it'll fail to run several tests because our
_require_scratchframework 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.Just calling stat(1) with -L to follow the link should suffice.
I wonder whether we'll find stat(1) output ever varies enough to affect this.
But otherwise this looks good to me.
Quoted 17 lines
Signed-off-by Eric Sandeen <[email protected]>---
common.rc +1
-1@@ -584,7 +584,7 @@ _is_block_dev() exit 1 fi - [ -b $1 ] && src/lstat64 $1 | $AWK_PROG '/Device type:/ { print $9 }' + [ -b $1 ] && stat -L $1 | $AWK_PROG '/Device type:/ { print $9 }' } # Do a command, log it to $seq.full, optionally test return status
Quoted 4 lines
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
Quoted 10 lines · Alex Elder
Quoted 8 lines · Eric Sandeen
If you try running xfstests on lvm volumes which are symlinks, it'll fail to run several tests because our
_require_scratchframework 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.Just calling stat(1) with -L to follow the link should suffice.
Quoted 8 lines
I wonder whether we'll find stat(1) output ever varies enough to affect this.
But otherwise this looks good to me.
Reviewed-by Alex Elder <[email protected]>Quoted 1 line
Signed-off-by Eric Sandeen <[email protected]>
Sorry, after all that I'm retracting this patch. mount, /proc/mounts, /etc/mtab etc just get very confused when using symlinked devices, at least as xfstests wants to use them.
For now I'll just make my uber-harness resolve symlinks to the real device (maybe that could be done in xfstests at some point)
-Eric
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs