From patchwork Wed Mar 21 03:40:04 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 10298495 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 0AFD8600CC for ; Wed, 21 Mar 2018 03:40:13 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EEEDC295F1 for ; Wed, 21 Mar 2018 03:40:12 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E225829621; Wed, 21 Mar 2018 03:40:12 +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.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI, T_DKIM_INVALID, UNPARSEABLE_RELAY 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 3BDC1295F1 for ; Wed, 21 Mar 2018 03:40:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752064AbeCUDkL (ORCPT ); Tue, 20 Mar 2018 23:40:11 -0400 Received: from aserp2130.oracle.com ([141.146.126.79]:40958 "EHLO aserp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751970AbeCUDkL (ORCPT ); Tue, 20 Mar 2018 23:40:11 -0400 Received: from pps.filterd (aserp2130.oracle.com [127.0.0.1]) by aserp2130.oracle.com (8.16.0.22/8.16.0.22) with SMTP id w2L3WEQx027472; Wed, 21 Mar 2018 03:40:07 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=subject : from : to : cc : date : message-id : in-reply-to : references : mime-version : content-type : content-transfer-encoding; s=corp-2017-10-26; bh=CTQhmyB38xvjfwf5XagVxMqhZvLuYbkcR2KBhcl25BQ=; b=FD3GlOnR6lgwvFJcw/Ejsy+XnTm7lUI4MscOc948eQPQ9I/mvUppoWtCPkkDgh4nMCDI Ji3wTA6mbh1AdTZElyrXOh2C0CNjGPM2Fbi2EUFdz0r5qZL35/hwJ6XXI6/Vb4C69dt6 4Zpeigcp4wpI2tlTUTaHmqbzbTthqANW8aV+GViV+AOwbUKxNPlNlVER711V8Q6mbcj8 ZTwd7dW1keYa3StW9OX1aDrfdALO0+7kNC+gwZ+WGKz2yn0UdCjqG6Vcr9wKL9SQqm+y nrKahTHnRp4Yt37XPhNLU0ZWtU9izj4D4ItxVk6hjldr3Fy1cWZGVr2BPloOZBESJbnc Ow== Received: from userv0021.oracle.com (userv0021.oracle.com [156.151.31.71]) by aserp2130.oracle.com with ESMTP id 2gufjqr0gw-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 21 Mar 2018 03:40:07 +0000 Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by userv0021.oracle.com (8.14.4/8.14.4) with ESMTP id w2L3e5a9023566 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 21 Mar 2018 03:40:06 GMT Received: from abhmp0007.oracle.com (abhmp0007.oracle.com [141.146.116.13]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id w2L3e5fA018448; Wed, 21 Mar 2018 03:40:05 GMT Received: from localhost (/10.159.242.221) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Tue, 20 Mar 2018 20:40:05 -0700 Subject: [PATCH 04/14] xfs_scrub: communicate name problems via flagset instead of booleans From: "Darrick J. Wong" To: sandeen@redhat.com, darrick.wong@oracle.com Cc: linux-xfs@vger.kernel.org Date: Tue, 20 Mar 2018 20:40:04 -0700 Message-ID: <152160360472.8288.12725342216863079202.stgit@magnolia> In-Reply-To: <152160358015.8288.2700156777231657519.stgit@magnolia> References: <152160358015.8288.2700156777231657519.stgit@magnolia> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=8838 signatures=668695 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=2 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1711220000 definitions=main-1803200127 Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Darrick J. Wong Use an unsigned int to pass around name error flags instead of booleans. Signed-off-by: Darrick J. Wong Reviewed-by: Eric Sandeen --- scrub/unicrash.c | 43 ++++++++++++++++++++++++++++++------------- 1 file changed, 30 insertions(+), 13 deletions(-) -- To unsubscribe from this list: send the line "unsubscribe linux-xfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/scrub/unicrash.c b/scrub/unicrash.c index 10d7c14..3538a60 100644 --- a/scrub/unicrash.c +++ b/scrub/unicrash.c @@ -77,6 +77,14 @@ struct unicrash { #define UNICRASH_SZ(nr) (sizeof(struct unicrash) + \ (nr * sizeof(struct name_entry *))) +/* Things to complain about in Unicode naming. */ + +/* + * Multiple names resolve to the same normalized string and therefore render + * identically. + */ +#define UNICRASH_NOT_UNIQUE (1 << 0) + /* * We only care about validating utf8 collisions if the underlying * system configuration says we're using utf8. If the language @@ -256,7 +264,7 @@ unicrash_complain( struct unicrash *uc, const char *descr, const char *what, - bool unique, + unsigned int badflags, const char *name, uint8_t *uniname) { @@ -266,11 +274,20 @@ unicrash_complain( bad1 = string_escape(name); bad2 = string_escape((char *)uniname); - if (!unique) + /* + * Two names that normalize to the same string will render + * identically even though the filesystem considers them unique + * names. "cafe\xcc\x81" and "caf\xc3\xa9" have different byte + * sequences, but they both appear as "café". + */ + if (badflags & UNICRASH_NOT_UNIQUE) { str_warn(uc->ctx, descr, -_("Duplicate normalized Unicode name \"%s\" found in %s."), - bad1, what); +_("Unicode name \"%s\" in %s renders identically to \"%s\"."), + bad1, what, bad2); + goto out; + } +out: free(bad1); free(bad2); } @@ -291,7 +308,7 @@ unicrash_add( struct unicrash *uc, uint8_t *uniname, xfs_ino_t ino, - bool *unique) + unsigned int *badflags) { struct name_entry *ne; struct name_entry *x; @@ -304,8 +321,9 @@ unicrash_add( hash = unicrash_hashname(uniname, uninamelen); bucket = hash % uc->nr_buckets; for (nep = &uc->buckets[bucket], ne = *nep; ne != NULL; ne = x) { - if (u8_strcmp(uniname, ne->uniname) == 0) { - *unique = uc->compare_ino ? ne->ino == ino : false; + if (u8_strcmp(uniname, ne->uniname) == 0 && + (uc->compare_ino ? ino != ne->ino : true)) { + *badflags |= UNICRASH_NOT_UNIQUE; return true; } nep = &ne->next; @@ -321,7 +339,6 @@ unicrash_add( x->uninamelen = uninamelen; memcpy(x->uniname, uniname, uninamelen + 1); *nep = x; - *unique = true; return true; } @@ -336,19 +353,19 @@ __unicrash_check_name( xfs_ino_t ino) { uint8_t uniname[(NAME_MAX * 2) + 1]; + unsigned int badflags = 0; bool moveon; - bool unique; memset(uniname, 0, (NAME_MAX * 2) + 1); unicrash_normalize(name, uniname, NAME_MAX * 2); - moveon = unicrash_add(uc, uniname, ino, &unique); + moveon = unicrash_add(uc, uniname, ino, &badflags); if (!moveon) return false; - if (unique) - return true; + if (badflags) + unicrash_complain(uc, descr, namedescr, badflags, name, + uniname); - unicrash_complain(uc, descr, namedescr, unique, name, uniname); return true; }