public inbox for fstests@vger.kernel.org
 help / color / mirror / Atom feed
From: Amir Goldstein <amir73il@gmail.com>
To: Dave Chinner <david@fromorbit.com>
Cc: Eryu Guan <eguan@redhat.com>,
	linux-xfs@vger.kernel.org, fstests@vger.kernel.org
Subject: [PATCH v2] xfs_io: support -c "open foo" command
Date: Mon,  5 Dec 2016 15:03:37 +0200	[thread overview]
Message-ID: <1480943017-6175-1-git-send-email-amir73il@gmail.com> (raw)

There is an undocumented and possibly unused feature in xfs_io
where all commands are executed per file in the file args list.

This feature creates ambiguity when trying to execute commands
such as "open" and "file" from command line and result in an
endless loop in the command loop code.

Also, when running xfs_io -c <cmd> without any file args, xfs_io
exits without doing anything. This behavior is also undocumented
and makes very little sense.

Change the behavior of xfs_io to execute each command specified
with -c <cmd> exactly once, regardless of the number of files in
the file args list.

This enables writing proper xfs_io scripts in command line, which
include "open" and "file" commands.

This change does not modify the behavior of xfs_io in the most
commonly used case of single file argument in command line and
no "open" and "file" commands in command line.

Signed-off-by: Amir Goldstein <amir73il@gmail.com>
---
 io/init.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

v2:
- Fix the case of multiple file args

v1:
- Fix the case of zero file args

diff --git a/io/init.c b/io/init.c
index a9191cf..82b6700 100644
--- a/io/init.c
+++ b/io/init.c
@@ -90,14 +90,15 @@ init_commands(void)
 	cowextsize_init();
 }
 
+/*
+ * Return true for first call and false for the next call,
+ * to execute each command once.
+ */
 static int
 init_args_command(
 	int	index)
 {
-	if (index >= filecount)
-		return 0;
-	file = &filetable[index++];
-	return index;
+	return !index;
 }
 
 static int
-- 
2.7.4


             reply	other threads:[~2016-12-05 13:23 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-12-05 13:03 Amir Goldstein [this message]
2016-12-05 14:19 ` [PATCH v2] xfs_io: support -c "open foo" command Eric Sandeen
2016-12-05 15:19   ` Amir Goldstein
2016-12-05 15:26     ` Eric Sandeen
2016-12-05 15:39       ` Amir Goldstein
2016-12-05 22:15         ` Dave Chinner
2016-12-06  5:24           ` Amir Goldstein
2016-12-06 23:25             ` Dave Chinner
2016-12-07  4:21               ` Amir Goldstein

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=1480943017-6175-1-git-send-email-amir73il@gmail.com \
    --to=amir73il@gmail.com \
    --cc=david@fromorbit.com \
    --cc=eguan@redhat.com \
    --cc=fstests@vger.kernel.org \
    --cc=linux-xfs@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