From patchwork Mon May 14 10:29:20 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Su Yue X-Patchwork-Id: 10397865 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 5A4CC6038F for ; Mon, 14 May 2018 10:23:55 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 482C9290D5 for ; Mon, 14 May 2018 10:23:55 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3CEE1290D9; Mon, 14 May 2018 10:23:55 +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=-7.9 required=2.0 tests=BAYES_00, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI 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 B01B5290D5 for ; Mon, 14 May 2018 10:23:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752323AbeENKXx (ORCPT ); Mon, 14 May 2018 06:23:53 -0400 Received: from mail.cn.fujitsu.com ([183.91.158.132]:3707 "EHLO heian.cn.fujitsu.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752266AbeENKXc (ORCPT ); Mon, 14 May 2018 06:23:32 -0400 X-IronPort-AV: E=Sophos;i="5.43,368,1503331200"; d="scan'208";a="39890908" Received: from bogon (HELO cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 14 May 2018 18:23:30 +0800 Received: from G08CNEXCHPEKD03.g08.fujitsu.local (unknown [10.167.33.85]) by cn.fujitsu.com (Postfix) with ESMTP id C29594B34D47 for ; Mon, 14 May 2018 18:23:28 +0800 (CST) Received: from archlinux.g08.fujitsu.local (10.167.226.31) by G08CNEXCHPEKD03.g08.fujitsu.local (10.167.33.89) with Microsoft SMTP Server (TLS) id 14.3.399.0; Mon, 14 May 2018 18:23:32 +0800 From: Su Yue To: CC: Subject: [PATCH 1/3] btrfs-progs: check: check symlinks with append/immutable flags Date: Mon, 14 May 2018 18:29:20 +0800 Message-ID: <20180514102922.8840-2-suy.fnst@cn.fujitsu.com> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180514102922.8840-1-suy.fnst@cn.fujitsu.com> References: <20180514102922.8840-1-suy.fnst@cn.fujitsu.com> MIME-Version: 1.0 X-Originating-IP: [10.167.226.31] X-yoursite-MailScanner-ID: C29594B34D47.A98EA X-yoursite-MailScanner: Found to be clean X-yoursite-MailScanner-From: suy.fnst@cn.fujitsu.com Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Define new macro I_ERR_ODD_INODE_FLAGS to represents odd inode flags. Symlinks should never have append/immutable flags. While processing inodes, if found a symlink with append/immutable flags, mark the inode record with I_ERR_ODD_INODE_FLAGS. This is for original mode. Signed-off-by: Su Yue --- check/main.c | 7 +++++++ check/mode-original.h | 1 + 2 files changed, 8 insertions(+) diff --git a/check/main.c b/check/main.c index 68da994f7ae0..f5f52c406046 100644 --- a/check/main.c +++ b/check/main.c @@ -576,6 +576,8 @@ static void print_inode_error(struct btrfs_root *root, struct inode_record *rec) fprintf(stderr, ", link count wrong"); if (errors & I_ERR_FILE_EXTENT_ORPHAN) fprintf(stderr, ", orphan file extent"); + if (errors & I_ERR_ODD_INODE_FLAGS) + fprintf(stderr, ", odd inode flags"); fprintf(stderr, "\n"); /* Print the orphan extents if needed */ if (errors & I_ERR_FILE_EXTENT_ORPHAN) @@ -805,6 +807,7 @@ static int process_inode_item(struct extent_buffer *eb, { struct inode_record *rec; struct btrfs_inode_item *item; + u64 flags; rec = active_node->current; BUG_ON(rec->ino != key->objectid || rec->refs > 1); @@ -822,6 +825,10 @@ static int process_inode_item(struct extent_buffer *eb, rec->found_inode_item = 1; if (rec->nlink == 0) rec->errors |= I_ERR_NO_ORPHAN_ITEM; + flags = btrfs_inode_flags(eb, item); + if (rec->imode & BTRFS_FT_SYMLINK && + flags & (BTRFS_INODE_IMMUTABLE | BTRFS_INODE_APPEND)) + rec->errors = I_ERR_ODD_INODE_FLAGS; maybe_free_inode_rec(&active_node->inode_cache, rec); return 0; } diff --git a/check/mode-original.h b/check/mode-original.h index 368de692fdd1..13cfa5b9e1b3 100644 --- a/check/mode-original.h +++ b/check/mode-original.h @@ -186,6 +186,7 @@ struct file_extent_hole { #define I_ERR_LINK_COUNT_WRONG (1 << 13) #define I_ERR_FILE_EXTENT_ORPHAN (1 << 14) #define I_ERR_FILE_EXTENT_TOO_LARGE (1 << 15) +#define I_ERR_ODD_INODE_FLAGS (1 << 16) struct inode_record { struct list_head backrefs;