From patchwork Thu May 11 06:55:07 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amir Goldstein X-Patchwork-Id: 9721029 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 8AE7D60364 for ; Thu, 11 May 2017 06:55:04 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7FDAF2866A for ; Thu, 11 May 2017 06:55:04 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 74A8A2866D; Thu, 11 May 2017 06:55: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 1699E2866A for ; Thu, 11 May 2017 06:55:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754559AbdEKGzD (ORCPT ); Thu, 11 May 2017 02:55:03 -0400 Received: from mail-wr0-f196.google.com ([209.85.128.196]:36565 "EHLO mail-wr0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754534AbdEKGy7 (ORCPT ); Thu, 11 May 2017 02:54:59 -0400 Received: by mail-wr0-f196.google.com with SMTP id v42so2098662wrc.3; Wed, 10 May 2017 23:54:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=s35Ez5tYerwF+vhKUxI5k4WmnWCTV2dotPrsOW05Zao=; b=e2loGWaK5/sr9vfELUBhRDFu9cyHJcyK2U3tNSz9HWeCtzAgHz7cUl48Q6jUKRrqnF PFwPtG7J4qBcPMtcgfwIVEr40pV3E8+f8bHsUS9MC45c+h/GFQl3xr+Y+L1N4CZgjaKv pb3lR1LixrjNaOkRg7oDTDsDxequBR04zYGpfsKLes/OOjssgHRX/2ZQw+jW3c9QUZwe 0IaaK51Wm7xJ8AoMgux7fN6UWIUMudo1y5VfBZUuzzQIM9LQ3idcg2kCtAnTRVk8O06a qMmOVeGeR3GAWQPALbzA2Y5ZB9DSPhprQiN6h4rAp1JJV6L4h8THIWOBnV4tWhAlFiPQ uohQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=s35Ez5tYerwF+vhKUxI5k4WmnWCTV2dotPrsOW05Zao=; b=jKCG3YTDmZ/dbH6IuvDktMiUk8vCuTGmCXACj1SuucM+P2ec4cU9Fzp7eCmjRorTI4 A+FsdkU3uINJSu+ai0yqeusFWU6C5I5G3cqCLcsY9MwSkpSnLKR9ImI19z+Eh6JzB351 u+rNS2HnPpOuVP4tTNAEIeZL+GziqLdmeARNAwUPdvn6NtSzXYMDFHJQRNctQFACdWYC TuNvH0asFEgCrE/W2s6HDzhiOMJhjkmIzqpfo3WaeuaJDmlZR97Jq304adPSvEJfuybQ uAXY9wA2toFic+KHoK8YEd5yGphu1u7BAWo8k8zYrmaaoGTLBB1/mtAxlL+3NYYf6ELs uy3A== X-Gm-Message-State: AODbwcCApvuFToPdjv2oxvpqylgIacmEE4piUvVo3+YktcS2eVNRnusC 3YE9rYeDnltBHw== X-Received: by 10.223.130.201 with SMTP id 67mr5946141wrc.106.1494485697944; Wed, 10 May 2017 23:54:57 -0700 (PDT) Received: from amir-VirtualBox.ctera.local (bzq-166-168-31-246.red.bezeqint.net. [31.168.166.246]) by smtp.gmail.com with ESMTPSA id j126sm1281825wmd.29.2017.05.10.23.54.56 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 10 May 2017 23:54:57 -0700 (PDT) From: Amir Goldstein To: Eryu Guan Cc: Miklos Szeredi , Xiong Zhou , linux-unionfs@vger.kernel.org, fstests@vger.kernel.org Subject: [PATCH 1/4] src/t_dir_type: support filtering by inode number Date: Thu, 11 May 2017 09:55:07 +0300 Message-Id: <1494485710-2400-2-git-send-email-amir73il@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1494485710-2400-1-git-send-email-amir73il@gmail.com> References: <1494485710-2400-1-git-send-email-amir73il@gmail.com> Sender: fstests-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: fstests@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP usage: t_dir_type Signed-off-by: Amir Goldstein --- doc/auxiliary-programs.txt | 7 +++++++ src/t_dir_type.c | 11 ++++++++--- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/doc/auxiliary-programs.txt b/doc/auxiliary-programs.txt index 2e2060a..21ef118 100644 --- a/doc/auxiliary-programs.txt +++ b/doc/auxiliary-programs.txt @@ -18,6 +18,7 @@ Contents: - af_unix -- Create an AF_UNIX socket - open_by_handle -- open_by_handle_at syscall exercise - stat_test -- statx syscall exercise + - t_dir_type -- print directory entries and their file type - xfs_io -- General I/O operation exercise @@ -48,6 +49,12 @@ stat_test _require_statx +t_dir_type + + The t_dir_type program exercises the getdents64() system call. + It prints directory entry names returned from getdents64() and + thier d_type, optionally filtered by type or by inode number. + xfs_io The xfs_io program can be found in the xfsprogs package and can be used diff --git a/src/t_dir_type.c b/src/t_dir_type.c index 344bef8..76aaa9b 100644 --- a/src/t_dir_type.c +++ b/src/t_dir_type.c @@ -19,9 +19,10 @@ /* * t_dir_type * - * print directory entries, optionally filtered by d_type + * print directory entries and their file type, optionally filtered by d_type + * or by inode number. * - * ./t_dir_type [u|f|d|c|b|l|p|s|w] + * ./t_dir_type [u|f|d|c|b|l|p|s|w|] */ #include @@ -67,6 +68,7 @@ main(int argc, char *argv[]) struct linux_dirent64 *d; int bpos; int type = -1; /* -1 means all types */ + uint64_t ino = 0; int ret = 1; fd = open(argv[1], O_RDONLY | O_DIRECTORY); @@ -82,6 +84,8 @@ main(int argc, char *argv[]) if (DT_CHAR(type) == t) break; /* no match ends up with type = -1 */ + if (type < 0) + ino = atoll(argv[2]); } for ( ; ; ) { @@ -96,7 +100,8 @@ main(int argc, char *argv[]) for (bpos = 0; bpos < nread;) { d = (struct linux_dirent64 *) (buf + bpos); - if (type < 0 || type == (int)d->d_type) { + if ((type < 0 || type == (int)d->d_type) && + (!ino || ino == d->d_ino)) { ret = 0; printf("%s %c\n", d->d_name, DT_CHAR(d->d_type)); }