From patchwork Wed Dec 6 15:10:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Konstantin Komarov X-Patchwork-Id: 174624 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:bcd1:0:b0:403:3b70:6f57 with SMTP id r17csp4169998vqy; Wed, 6 Dec 2023 07:11:26 -0800 (PST) X-Google-Smtp-Source: AGHT+IFxgCtrxxKM8PQRSICN4UbyqWNM9Uob3kciFAlwDn4PF9moF+ZNu4JddXCIZordB09WP3+c X-Received: by 2002:a05:6a20:4308:b0:187:a4df:4e57 with SMTP id h8-20020a056a20430800b00187a4df4e57mr872947pzk.20.1701875485653; Wed, 06 Dec 2023 07:11:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701875485; cv=none; d=google.com; s=arc-20160816; b=CYUu301kUtm5klNh9aVLXZ/7hKeqZ+kKo7j2rHn/zWswdJ03BNI+9W2fXHRyxuJ4lX sZF5aQgbYm6ILVxuhd2Ckc63waugt2zXYmfPx/6lDKwwsUU4g+lHjaG/bIw+2wq6R9on ic1mzNO9AwCoSbzI+qgsbM1DvFtEh796o8OICZt0JtAHrA6Wm2ufb28MfozxziTr0pay hPEZhFaf5U3WvlJVGr5z/VxZW2bmZDPX5ey/XpIqiBGwnwuwGU7WG+LBb2ns9AV4Hf4L noFNjlBj0OqiTBI/g1yceEXsu93zJZRQYLGosWBO20sSDzKG3Typ9oxUyyk19t4t/9xZ H2rA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:references :cc:to:from:content-language:subject:user-agent:mime-version:date :message-id:dkim-signature; bh=mAuuCGMqlStfHaypyBJ9iLMuzcr3BmzULzMWMwWTRuE=; fh=P7I85FIabZcM8ojWdeG8ABpTZepe/Xtte9jKWDfUHBM=; b=IWA0UVGpdN5YXg7E1H4UVSRZQCk8SYZf+ANw7SeUIXaFr3bwWNVh021/tQQ2RAZtYk OuurRsc/JSBMjbBGdyj2dEERPLKlYy0Kv2U7OBZGup1shxSJR3P4NDIOoq3EkBAZbB81 erWwvnnEotx96JgQvsHfRHtVzAJSuwN87YmWAwD32ONecEJsE0/XXsejeZRxb+8P7oe6 bmXAZgRCYWBUvtvrFlEIXfDjMrk4UwhpyRVmBF0g8LrH9ufmBdKd7cczEc/QqsxSFtej DeL50xaHsnb+57bieJU9La9iQuqRfXuO71aQ9qOWL7i5tVTLwWLrc4NMidRM04N8s34o yaiA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@paragon-software.com header.s=mail header.b=bLupnkpL; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=paragon-software.com Received: from pete.vger.email (pete.vger.email. [23.128.96.36]) by mx.google.com with ESMTPS id fd34-20020a056a002ea200b006be04b8c3basi89838pfb.178.2023.12.06.07.11.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Dec 2023 07:11:25 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) client-ip=23.128.96.36; Authentication-Results: mx.google.com; dkim=pass header.i=@paragon-software.com header.s=mail header.b=bLupnkpL; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=paragon-software.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id DF89F81BFCC1; Wed, 6 Dec 2023 07:11:21 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1379097AbjLFPLJ (ORCPT + 99 others); Wed, 6 Dec 2023 10:11:09 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55940 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1379221AbjLFPKs (ORCPT ); Wed, 6 Dec 2023 10:10:48 -0500 Received: from relayaws-01.paragon-software.com (relayaws-01.paragon-software.com [35.157.23.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 096DCD5B; Wed, 6 Dec 2023 07:10:54 -0800 (PST) Received: from dlg2.mail.paragon-software.com (vdlg-exch-02.paragon-software.com [172.30.1.105]) by relayaws-01.paragon-software.com (Postfix) with ESMTPS id 751C91E1A; Wed, 6 Dec 2023 15:04:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paragon-software.com; s=mail; t=1701875068; bh=mAuuCGMqlStfHaypyBJ9iLMuzcr3BmzULzMWMwWTRuE=; h=Date:Subject:From:To:CC:References:In-Reply-To; b=bLupnkpLf7fzkUc2Zt5omBwLubjPcPeYPgaJ3tqLEQExUyjSso2/GDYWv58+hM9Zd fhwCheq3GPFBlwishCkRPuzN547xVQMTB6CcNxkddptzAQzbiVxJDeavPAQdzRFKtx 4XYrwbbISqytrtKzvacmxjfRMfH0G33BplXtpoVE= Received: from [172.16.192.129] (192.168.211.144) by vdlg-exch-02.paragon-software.com (172.30.1.105) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.7; Wed, 6 Dec 2023 18:10:52 +0300 Message-ID: <8cb671f9-252b-443b-a903-ca62c9097533@paragon-software.com> Date: Wed, 6 Dec 2023 18:10:52 +0300 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: [PATCH 04/16] fs/ntfs3: Correct hard links updating when dealing with DOS neams Content-Language: en-US From: Konstantin Komarovc To: CC: , References: <00fd1558-fda5-421b-be43-7de69e32cb4e@paragon-software.com> In-Reply-To: <00fd1558-fda5-421b-be43-7de69e32cb4e@paragon-software.com> X-Originating-IP: [192.168.211.144] X-ClientProxiedBy: vobn-exch-01.paragon-software.com (172.30.72.13) To vdlg-exch-02.paragon-software.com (172.30.1.105) X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on pete.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (pete.vger.email [0.0.0.0]); Wed, 06 Dec 2023 07:11:22 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1784545788917595049 X-GMAIL-MSGID: 1784545788917595049 Signed-off-by: Konstantin Komarov ---  fs/ntfs3/record.c | 16 ++++++++++++++--  1 file changed, 14 insertions(+), 2 deletions(-)      used -= asize; diff --git a/fs/ntfs3/record.c b/fs/ntfs3/record.c index 53629b1f65e9..7b6423584eae 100644 --- a/fs/ntfs3/record.c +++ b/fs/ntfs3/record.c @@ -535,8 +535,20 @@ bool mi_remove_attr(struct ntfs_inode *ni, struct mft_inode *mi,          return false;      if (ni && is_attr_indexed(attr)) { -        le16_add_cpu(&ni->mi.mrec->hard_links, -1); -        ni->mi.dirty = true; +        u16 links = le16_to_cpu(ni->mi.mrec->hard_links); +        struct ATTR_FILE_NAME *fname = +            attr->type != ATTR_NAME ? +                NULL : +                resident_data_ex(attr, +                         SIZEOF_ATTRIBUTE_FILENAME); +        if (fname && fname->type == FILE_NAME_DOS) { +            /* Do not decrease links count deleting DOS name. */ +        } else if (!links) { +            /* minor error. Not critical. */ +        } else { +            ni->mi.mrec->hard_links = cpu_to_le16(links - 1); +            ni->mi.dirty = true; +        }      }