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: 9486699 X-Mozilla-Keys: nonjunk Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on sandeen.net X-Spam-Level: X-Spam-Status: No, score=-6.4 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_HI,RCVD_IN_SORBS_SPAM, RP_MATCHES_RCVD, T_DKIM_INVALID autolearn=ham autolearn_force=no version=3.4.0 X-Spam-HP: BAYES_00=-1.9,DKIM_ADSP_CUSTOM_MED=0.001,DKIM_SIGNED=0.1, FREEMAIL_FORGED_FROMDOMAIN=0.001,FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.001,RCVD_IN_DNSWL_HI=-5, RCVD_IN_SORBS_SPAM=0.5,RP_MATCHES_RCVD=-0.1,T_DKIM_INVALID=0.01 X-Original-To: sandeen@sandeen.net Delivered-To: sandeen@sandeen.net Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by sandeen.net (Postfix) with ESMTP id 0D8BF479AEF for ; Mon, 5 Dec 2016 07:23:06 -0600 (CST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751485AbcLENXl (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: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org 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