From patchwork Mon Dec 5 07:04:45 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amir Goldstein X-Patchwork-Id: 9460479 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 689A160231 for ; Mon, 5 Dec 2016 07:05:11 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 54E5025250 for ; Mon, 5 Dec 2016 07:05:11 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 499BF26247; Mon, 5 Dec 2016 07:05:11 +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 DF86125250 for ; Mon, 5 Dec 2016 07:05:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751439AbcLEHFK (ORCPT ); Mon, 5 Dec 2016 02:05:10 -0500 Received: from mail-wj0-f193.google.com ([209.85.210.193]:35168 "EHLO mail-wj0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751059AbcLEHFJ (ORCPT ); Mon, 5 Dec 2016 02:05:09 -0500 Received: by mail-wj0-f193.google.com with SMTP id he10so23451972wjc.2; Sun, 04 Dec 2016 23:05:08 -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=qKJu2AaH6Io3Fv1IsFS94lbZPS1Vvow5eg7c1Bk+IuA=; b=zAIKMgg+zuS8hudSO0pn5z5cx1uONC6trLPPBs02pb6lCdXbYLj6HcoljPnzv3yZYm FvESBoAkwfTQR20i8MZMFBA2krjbpOPNS/HPpdQ9U7velLp2XHtlK5F5Ijq9xzUu/fwH BUsc9CA+E+DlKvohV5RomEeYFPQBTXH1Rjb519tglZ3eMccmw+b1eXSP9T5CrbxbUZlm ObRjbFh/DEVRFuUWFBhw8eG2GvO1K/YJdlWyb9jsSyO5dLt43mof/WR2TS6CFMmmPbyF mMIIHW7QqhDze0PzsVQ8vpJ/iXppASpC9bEKVVCsmFq/eQcbVGao0Rj/IuPFLRFViUGP 2NXw== 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=qKJu2AaH6Io3Fv1IsFS94lbZPS1Vvow5eg7c1Bk+IuA=; b=N0EZlV9l1v5XjzRAr0vCewUM2IIg9NdLS50EVu3Qxw/vLZBkw7R7Cq96f9D4H0wH9M s0VEhM2QByFFVQBDrMO4tK5L3d0WFUllyjWwvAJ0bTOLv0vl0n0I9A9dPnlow+jIYulT 114wXiIPUoiEvLad+wcOFCBNIbNXKQUWoBDlrRoj9fVrwSbZC0xWMirkpksThzLJqxvR 25UqMZHtA4CQi48KanQ3Yf/wNpu0Ku2l6ugs3FHmu0SVdQ48P+CdhkEomBM9or3L3fTy EWl1H8aUSrd3BTttyCdNbR6VBza9jn+i5r7/xzRpSzy2MtwD16IMThvukCnPQfhwJ5C8 wZQQ== X-Gm-Message-State: AKaTC000m0ptr42399o9rT7DEM78Loumrgij/eGhwtwHMIcC2htGaHKNCzA1Kz+zc1YuZw== X-Received: by 10.194.205.73 with SMTP id le9mr49278541wjc.31.1480921507845; Sun, 04 Dec 2016 23:05:07 -0800 (PST) Received: from amir-VirtualBox.Home (bzq-79-177-89-54.red.bezeqint.net. [79.177.89.54]) by smtp.gmail.com with ESMTPSA id l2sm18799168wji.7.2016.12.04.23.05.05 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 04 Dec 2016 23:05:06 -0800 (PST) From: Amir Goldstein To: Dave Chinner Cc: Eryu Guan , linux-xfs@vger.kernel.org, fstests@vger.kernel.org Subject: [PATCH] xfs_io: support -c without args Date: Mon, 5 Dec 2016 09:04:45 +0200 Message-Id: <1480921485-14888-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 given in the file args list. This feature creates ambiguity when trying to execute commands such as "open" and "file" from command line. When running xfs_io -c without any file args, xfs_io exits without doing anything. This behavior is undocumented and does not make much sense either. Change the behavior in the case where no file args are given in command line to execute every command exactly once, exactly as if the commands where executed from an interactive shell. This enables writing proper xfs_io scripts in command line, which include "open" and "file" commands. Signed-off-by: Amir Goldstein --- io/init.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/io/init.c b/io/init.c index a9191cf..785eb05 100644 --- a/io/init.c +++ b/io/init.c @@ -91,7 +91,7 @@ init_commands(void) } static int -init_args_command( +per_file_args_command( int index) { if (index >= filecount) @@ -101,6 +101,13 @@ init_args_command( } static int +do_once_args_command( + int index) +{ + return !index; +} + +static int init_check_command( const cmdinfo_t *ct) { @@ -214,7 +221,12 @@ init( } init_commands(); - add_args_command(init_args_command); + /* + * If file args exist, execute all commands for every file. + * Otherwise, execute every command once exactly as in interactive mode. + */ + add_args_command(filecount ? per_file_args_command : + do_once_args_command); add_check_command(init_check_command); }