Received: by 2002:a05:6a10:8a4d:0:0:0:0 with SMTP id dn13csp47123pxb; Thu, 12 Aug 2021 10:26:58 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyYLt+9KAF9V1yzt7mxpWYMv6cz1Dc0zQBqu59wtHfIKyGqESjpkeSHArD8pkqh/dNjXXUy X-Received: by 2002:aa7:d3cc:: with SMTP id o12mr6612379edr.335.1628789218619; Thu, 12 Aug 2021 10:26:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1628789218; cv=none; d=google.com; s=arc-20160816; b=VsXlShiQJyf+WUAMvxRnbRZtIHIeph9RuaVTArtxUIteVHio5ODt+w/8EsZI3eDtdr VBU0MmRhg+o971tWtfd3yj/Ub4e8ViBuPHb17bstqjAsrW2Fqz41Skxbd8D6yjiW2zgl fGyhTJxmI7Blqy9RJYno9xUdn1/lUnKWKPRg90XpU+EO1idmA0HugdkVWFgTsmkUqQG/ cfaPpDHwM5mTNU+5dGbN6dRr3nTRxp2KjN67JCIO71FPuS7RGkwKYsMj4CWJZZAQSbAc 1/JgEQbh6OFY7YcsUmRo3wNoMR1lwFwx2Gdt49ebR+DZx0FwnfDnqSaJb/5iuKbu8+LF Mohg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature:dkim-signature; bh=1LOq+1RQ1bTZ6xSCL5P+LUHz6PeiGtFp6lwo2Lqqi7Q=; b=subIyFBsvm+Yb7s/u8H6PTVQMUZnTx134CyxWFUB92yNgI+LRsBspfcJC3DbV2Tlo/ dbm7pZNaYY27yh+3ohy49Mfk1dPgYOX18GlLGOGh5Zr9R77Dt98yMwqzVCfi/VZkL8fB 6emwHPG0i9sa+fkbfgwW8yQAYbGm2ek8Xe6UuKANjagvd2QanlTw2jM2bC5asLk5hm7B jzM6GwxvVhkTn5bUdZY0CZXMImLa907e64kDdsufeIIqqECJrcBCsktjFMeeCuO4bBlL Nw6YY3vQv4wvLdyOG2fJXpnViGew+NZGshn3HnQCmiKOZTDJQjj/dsn6tXBivzHcflAF 0hJA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=SyRasx6B; dkim=neutral (no key) header.i=@suse.cz; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id di5si334986ejc.672.2021.08.12.10.26.34; Thu, 12 Aug 2021 10:26:58 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=SyRasx6B; dkim=neutral (no key) header.i=@suse.cz; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237770AbhHLOSE (ORCPT + 99 others); Thu, 12 Aug 2021 10:18:04 -0400 Received: from smtp-out2.suse.de ([195.135.220.29]:35466 "EHLO smtp-out2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236547AbhHLOSD (ORCPT ); Thu, 12 Aug 2021 10:18:03 -0400 Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out2.suse.de (Postfix) with ESMTP id 4F2141FF47; Thu, 12 Aug 2021 14:17:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1628777857; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=1LOq+1RQ1bTZ6xSCL5P+LUHz6PeiGtFp6lwo2Lqqi7Q=; b=SyRasx6BYceomp5A+vWd4xR0dle1B5guJeUWfAt8MXCICkXDRM4Oz3QToHB6VB0i3wuklT rD1ODhLj1qp3Gxa/cBNEn2uynbbVSk3bEWm1MvgSMO1+bSW5Vz10g7cH5ayULBga1nLnI0 F5UXM0ya2H7/DIFqNTn5zZVy+6MCS1k= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1628777857; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=1LOq+1RQ1bTZ6xSCL5P+LUHz6PeiGtFp6lwo2Lqqi7Q=; b=GnzDUaCqYiTEgMmiYEgvAadtT34kHXqFeZpKyBC6BK2GN55zyPQnlN7MyWkUiuOme/CnH1 ZhReSiomtDrRUaDw== Received: from quack2.suse.cz (unknown [10.100.224.230]) by relay2.suse.de (Postfix) with ESMTP id 6B05DA3F4E; Thu, 12 Aug 2021 14:17:36 +0000 (UTC) Received: by quack2.suse.cz (Postfix, from userid 1000) id 46CF11F2BA7; Thu, 12 Aug 2021 16:17:36 +0200 (CEST) Date: Thu, 12 Aug 2021 16:17:36 +0200 From: Jan Kara To: Pali =?iso-8859-1?Q?Roh=E1r?= Cc: linux-fsdevel@vger.kernel.org, linux-ntfs-dev@lists.sourceforge.net, linux-cifs@vger.kernel.org, jfs-discussion@lists.sourceforge.net, linux-kernel@vger.kernel.org, Alexander Viro , Jan Kara , OGAWA Hirofumi , "Theodore Y . Ts'o" , Luis de Bethencourt , Salah Triki , Andrew Morton , Dave Kleikamp , Anton Altaparmakov , Pavel Machek , Marek =?iso-8859-1?Q?Beh=FAn?= , Christoph Hellwig Subject: Re: [RFC PATCH 03/20] udf: Fix iocharset=utf8 mount option Message-ID: <20210812141736.GE14675@quack2.suse.cz> References: <20210808162453.1653-1-pali@kernel.org> <20210808162453.1653-4-pali@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20210808162453.1653-4-pali@kernel.org> User-Agent: Mutt/1.10.1 (2018-07-13) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun 08-08-21 18:24:36, Pali Roh?r wrote: > Currently iocharset=utf8 mount option is broken. To use UTF-8 as iocharset, > it is required to use utf8 mount option. > > Fix iocharset=utf8 mount option to use be equivalent to the utf8 mount > option. > > If UTF-8 as iocharset is used then s_nls_map is set to NULL. So simplify > code around, remove UDF_FLAG_NLS_MAP and UDF_FLAG_UTF8 flags as to > distinguish between UTF-8 and non-UTF-8 it is needed just to check if > s_nls_map set to NULL or not. > > Signed-off-by: Pali Roh?r Thanks for the cleanup. It looks good. Feel free to add: Reviewed-by: Jan Kara Or should I take this patch through my tree? Honza > --- > fs/udf/super.c | 50 ++++++++++++++++++------------------------------ > fs/udf/udf_sb.h | 2 -- > fs/udf/unicode.c | 4 ++-- > 3 files changed, 21 insertions(+), 35 deletions(-) > > diff --git a/fs/udf/super.c b/fs/udf/super.c > index 2f83c1204e20..6e8c29107b04 100644 > --- a/fs/udf/super.c > +++ b/fs/udf/super.c > @@ -349,10 +349,10 @@ static int udf_show_options(struct seq_file *seq, struct dentry *root) > seq_printf(seq, ",lastblock=%u", sbi->s_last_block); > if (sbi->s_anchor != 0) > seq_printf(seq, ",anchor=%u", sbi->s_anchor); > - if (UDF_QUERY_FLAG(sb, UDF_FLAG_UTF8)) > - seq_puts(seq, ",utf8"); > - if (UDF_QUERY_FLAG(sb, UDF_FLAG_NLS_MAP) && sbi->s_nls_map) > + if (sbi->s_nls_map) > seq_printf(seq, ",iocharset=%s", sbi->s_nls_map->charset); > + else > + seq_puts(seq, ",iocharset=utf8"); > > return 0; > } > @@ -558,19 +558,24 @@ static int udf_parse_options(char *options, struct udf_options *uopt, > /* Ignored (never implemented properly) */ > break; > case Opt_utf8: > - uopt->flags |= (1 << UDF_FLAG_UTF8); > + if (!remount) { > + unload_nls(uopt->nls_map); > + uopt->nls_map = NULL; > + } > break; > case Opt_iocharset: > if (!remount) { > - if (uopt->nls_map) > - unload_nls(uopt->nls_map); > - /* > - * load_nls() failure is handled later in > - * udf_fill_super() after all options are > - * parsed. > - */ > + unload_nls(uopt->nls_map); > + uopt->nls_map = NULL; > + } > + /* When nls_map is not loaded then UTF-8 is used */ > + if (!remount && strcmp(args[0].from, "utf8") != 0) { > uopt->nls_map = load_nls(args[0].from); > - uopt->flags |= (1 << UDF_FLAG_NLS_MAP); > + if (!uopt->nls_map) { > + pr_err("iocharset %s not found\n", > + args[0].from); > + return 0; > + } > } > break; > case Opt_uforget: > @@ -2139,21 +2144,6 @@ static int udf_fill_super(struct super_block *sb, void *options, int silent) > if (!udf_parse_options((char *)options, &uopt, false)) > goto parse_options_failure; > > - if (uopt.flags & (1 << UDF_FLAG_UTF8) && > - uopt.flags & (1 << UDF_FLAG_NLS_MAP)) { > - udf_err(sb, "utf8 cannot be combined with iocharset\n"); > - goto parse_options_failure; > - } > - if ((uopt.flags & (1 << UDF_FLAG_NLS_MAP)) && !uopt.nls_map) { > - uopt.nls_map = load_nls_default(); > - if (!uopt.nls_map) > - uopt.flags &= ~(1 << UDF_FLAG_NLS_MAP); > - else > - udf_debug("Using default NLS map\n"); > - } > - if (!(uopt.flags & (1 << UDF_FLAG_NLS_MAP))) > - uopt.flags |= (1 << UDF_FLAG_UTF8); > - > fileset.logicalBlockNum = 0xFFFFFFFF; > fileset.partitionReferenceNum = 0xFFFF; > > @@ -2308,8 +2298,7 @@ static int udf_fill_super(struct super_block *sb, void *options, int silent) > error_out: > iput(sbi->s_vat_inode); > parse_options_failure: > - if (uopt.nls_map) > - unload_nls(uopt.nls_map); > + unload_nls(uopt.nls_map); > if (lvid_open) > udf_close_lvid(sb); > brelse(sbi->s_lvid_bh); > @@ -2359,8 +2348,7 @@ static void udf_put_super(struct super_block *sb) > sbi = UDF_SB(sb); > > iput(sbi->s_vat_inode); > - if (UDF_QUERY_FLAG(sb, UDF_FLAG_NLS_MAP)) > - unload_nls(sbi->s_nls_map); > + unload_nls(sbi->s_nls_map); > if (!sb_rdonly(sb)) > udf_close_lvid(sb); > brelse(sbi->s_lvid_bh); > diff --git a/fs/udf/udf_sb.h b/fs/udf/udf_sb.h > index 758efe557a19..4fa620543d30 100644 > --- a/fs/udf/udf_sb.h > +++ b/fs/udf/udf_sb.h > @@ -20,8 +20,6 @@ > #define UDF_FLAG_UNDELETE 6 > #define UDF_FLAG_UNHIDE 7 > #define UDF_FLAG_VARCONV 8 > -#define UDF_FLAG_NLS_MAP 9 > -#define UDF_FLAG_UTF8 10 > #define UDF_FLAG_UID_FORGET 11 /* save -1 for uid to disk */ > #define UDF_FLAG_GID_FORGET 12 > #define UDF_FLAG_UID_SET 13 > diff --git a/fs/udf/unicode.c b/fs/udf/unicode.c > index 5fcfa96463eb..622569007b53 100644 > --- a/fs/udf/unicode.c > +++ b/fs/udf/unicode.c > @@ -177,7 +177,7 @@ static int udf_name_from_CS0(struct super_block *sb, > return 0; > } > > - if (UDF_QUERY_FLAG(sb, UDF_FLAG_NLS_MAP)) > + if (UDF_SB(sb)->s_nls_map) > conv_f = UDF_SB(sb)->s_nls_map->uni2char; > else > conv_f = NULL; > @@ -285,7 +285,7 @@ static int udf_name_to_CS0(struct super_block *sb, > if (ocu_max_len <= 0) > return 0; > > - if (UDF_QUERY_FLAG(sb, UDF_FLAG_NLS_MAP)) > + if (UDF_SB(sb)->s_nls_map) > conv_f = UDF_SB(sb)->s_nls_map->char2uni; > else > conv_f = NULL; > -- > 2.20.1 > -- Jan Kara SUSE Labs, CR