From patchwork Mon Dec 5 13:03:37 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amir Goldstein X-Patchwork-Id: 9460981 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 3399A6022E for ; Mon, 5 Dec 2016 13:24:04 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 24D0324DA2 for ; Mon, 5 Dec 2016 13:24:04 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 195BD27BE5; Mon, 5 Dec 2016 13:24:04 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.3 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B3A1924DA2 for ; Mon, 5 Dec 2016 13:24:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751420AbcLENXl (ORCPT ); Mon, 5 Dec 2016 08:23:41 -0500 Received: from mail-wj0-f194.google.com ([209.85.210.194]:36274 "EHLO mail-wj0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751134AbcLENXj (ORCPT ); Mon, 5 Dec 2016 08:23:39 -0500 Received: by mail-wj0-f194.google.com with SMTP id j10so11937689wjb.3; Mon, 05 Dec 2016 05:23:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=uIBhW4aLztsovP8SwNMo7riM43+0tmPgA5Tvlp197JQ=; b=qe8NXVRQ3lBK2nfoM4cvSUXLn0vqrSd21CKdqaM2xDyNARHdKsfuvUXaJK1566G0rk 5jGkmfBq+iFCc3GRi8L4jCROU9hXz+I16K97AuiNxxGpegkBTTyGZp6FlCruWrkvYJ7U J+fuiK1GtZgowRWgziY7wU+iPPIgor7GejAJvXdWXZqSwJRuhqQZBMPxQvjpWZOaer55 v0pfn20i4eMk15TB4s0Bfct9Iz2aXU9NdPvWSEzmO+bVn0fjQY9xYZTCu14EjCt3P0Ew 4qrPzZwyN0FKRYyVPrqI1nS19cfZ4PqAJXvTLvfgGb61ZHQo84ZEAYYz7TJuhYeyH0f2 llWQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=uIBhW4aLztsovP8SwNMo7riM43+0tmPgA5Tvlp197JQ=; b=aw622xD9lL89Do8evzWI3pCTwYu757xOSmQah2fX5wOwYWgKbLo2NGIZQMBci1dQEb Gc6O7imOuo9wFChma3HJOPmzszLEVRnMSGK1UOmdAY0pTWEBWhsQivAHGJciRsv7k4IE efc3AIc4xWwOxi50pMgpi0hNpBe0BRu9aMf4KTRByqjn9IkXWjxsZ1Vpk8xbLLrslRHW +RrDODBq8k2tvg1Li14bA8Yc2A/u1vOrchfs7at1BHudmcGsdNsvszzwGS55XMSs8On1 g8C7S/Qzybq6kb3zzhov23PUdtGxmS0Q2aOwxMPWtravIDWDKRotCXaYlRPMidWVFe7o uRfQ== X-Gm-Message-State: AKaTC02Kn1DRCNeZXXFMYP84X71FykKeQ8CmAjtvoqnvEwbCqsrNKZQnDcvr5R/X4ZBAFQ== X-Received: by 10.194.137.15 with SMTP id qe15mr55883937wjb.16.1480943037003; Mon, 05 Dec 2016 05:03:57 -0800 (PST) Received: from amir-VirtualBox.ctera.local (bzq-82-81-193-202.cablep.bezeqint.net. [82.81.193.202]) by smtp.gmail.com with ESMTPSA id w18sm38157wme.9.2016.12.05.05.03.55 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 05 Dec 2016 05:03:56 -0800 (PST) From: Amir Goldstein To: Dave Chinner Cc: Eryu Guan , 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 Message-Id: <1480943017-6175-1-git-send-email-amir73il@gmail.com> X-Mailer: git-send-email 2.7.4 Sender: fstests-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: fstests@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 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 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 --- 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