From: Jan Kara <jack@suse.com>
To: fstests@vger.kernel.org
Cc: linux-ext4@vger.kernel.org, Jan Kara <jack@suse.com>
Subject: [PATCH 3/4] common: Add function for selecting from different output files
Date: Wed, 4 Nov 2015 17:31:37 +0100 [thread overview]
Message-ID: <1446654698-23577-4-git-send-email-jack@suse.com> (raw)
In-Reply-To: <1446654698-23577-1-git-send-email-jack@suse.com>
Add function for selection of different output files. The idea is that
in config file ($seq.cfg) there are several lines like:
feat1,feat2: suffix
The function is passed a feature string (or uses MOUNT_OPTIONS if no
argument is passed) and selects output file with a suffix for which all
features are present in the feature string. If there is no matching
line, output with 'default' suffix is selected.
Signed-off-by: Jan Kara <jack@suse.com>
---
common/rc | 41 +++++++++++++++++++++++++++++++++++++++++
1 file changed, 41 insertions(+)
diff --git a/common/rc b/common/rc
index adf1edf64d8d..543780c92c59 100644
--- a/common/rc
+++ b/common/rc
@@ -3142,6 +3142,47 @@ get_block_size()
echo `stat -f -c %S $1`
}
+_select_output()
+{
+ if [ $# -eq 0 ]; then
+ FEATURES=${MOUNT_OPTIONS##"-o "}
+ else
+ FEATURES=$1
+ fi
+
+ export FEATURES
+ seqfull=$SRC_DIR/$seqnum
+ perl -e '
+ my %feathash;
+ my $feature, $result, $suffix, $opts;
+
+ foreach $feature (split(/,/, $ENV{"FEATURES"})) {
+ $feathash{$feature} = 1;
+ }
+ $result = "default";
+ while (<>) {
+ my $found = 1;
+
+ chomp;
+ ($opts, $suffix) = split(/ *: */);
+ foreach my $opt (split(/,/, $opts)) {
+ if (!exists($feathash{$opt})) {
+ $found = 0;
+ last;
+ }
+ }
+ if ($found == 1) {
+ $result = $suffix;
+ last;
+ }
+ }
+ print $result
+ ' <$seqfull.cfg | {
+ read SUFFIX
+ ln -fs $seq.out.$SUFFIX $seqfull.out
+ }
+}
+
init_rc
################################################################################
--
2.1.4
next prev parent reply other threads:[~2015-11-04 16:31 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-11-04 16:31 [PATCH 0/4] Output selection, improvements for ext4/001 Jan Kara
2015-11-04 16:31 ` [PATCH 1/4] _filter_fiemap: Avoid awk interval regexps Jan Kara
2015-11-04 16:31 ` [PATCH 2/4] ext4/001: Update output Jan Kara
2015-11-04 16:31 ` Jan Kara [this message]
2015-11-16 21:29 ` [PATCH 3/4] common: Add function for selecting from different output files Dave Chinner
2015-11-18 15:37 ` Jan Kara
2015-11-04 16:31 ` [PATCH 4/4] ext4/001: Select different output based on mount options Jan Kara
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=1446654698-23577-4-git-send-email-jack@suse.com \
--to=jack@suse.com \
--cc=fstests@vger.kernel.org \
--cc=linux-ext4@vger.kernel.org \
/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;
as well as URLs for NNTP newsgroup(s).