Received: by 2002:a05:6a10:c604:0:0:0:0 with SMTP id y4csp2041843pxt; Sun, 8 Aug 2021 09:30:55 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyv56g2A52km08F1wZAgUiCgXtm6NgvlT1jETJK4cSUhdphYxPBkb2kU7R+iOXEtDjdubPR X-Received: by 2002:a17:906:9b1:: with SMTP id q17mr18420214eje.546.1628440255736; Sun, 08 Aug 2021 09:30:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1628440255; cv=none; d=google.com; s=arc-20160816; b=0H43Jry060NN8pNoFmhmuR/NKkWwJbf/p2RazAGTPLYfUk7EBxtrYYZHUy+dzk/Bv4 7yZH2BGQ1l2PyEjx88Esj8JOt73nVgj1jmiSvB/N+jisUiorEq94yKM0wwWWsHsbTvDF RZXPLEcJ1rsOZgOjlzGd9SNAT54j0RzBW/i4TPc4whKXOuHU/HebVRff55IvmMnEZyXe RT6URKcS9NqPZsRVEI4F67kxLpCUEnA/LmvBHDEZPwu1AUta/OUvpNRX+ty5x6lXaQaW hFMyjbdrTl4MUHGUXmDjRI6AfhN1UbT4AFV713JU9cnnD1v4lJ6X++nN6aoukKmYx1BJ tIlQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=raAtZLZdnuRwQE3OPsmR+SoF9ZBtFUvo4c6wVs21y38=; b=p4hHjLNPrRkMvCK8WtKmJ09UWF/vrNXmphcvRCf4J7liZzqZBdLulANy6vbuf3N/1j V88aQ+238ppAc07xUg8NXLPkr8Aot9y4EqDqssUEA4Q81R10pdXvzlh5npZzPm4Mbh5i 1xFeH6/+IfppQw3laQ609GoPGFAta8xQYrPphQ8kk1m47OTsBtGb8/vmNs3Ac6CgpDbA y3QXUNxNtHU9cqggMiGkXKlRFzY+TbmmeOU/IjEnpVO7tkawXh3S7NYkTMhMnKeBv2P8 Cbkr8fic7Z7Fa7ULOZlG7N690tVwdcSXLCMLvXdZVCcza6t377Uv+VGNBXP69JlyqO+A X4eg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=fObJDeUq; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id dp6si7580296ejc.675.2021.08.08.09.30.32; Sun, 08 Aug 2021 09:30:55 -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=@kernel.org header.s=k20201202 header.b=fObJDeUq; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232643AbhHHQ0Y (ORCPT + 99 others); Sun, 8 Aug 2021 12:26:24 -0400 Received: from mail.kernel.org ([198.145.29.99]:47316 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231811AbhHHQZg (ORCPT ); Sun, 8 Aug 2021 12:25:36 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 73D1E61076; Sun, 8 Aug 2021 16:25:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1628439916; bh=GasSH2ltMgihtrZxt7291SJqZTLmkcU1VpHCFgltNrc=; h=From:To:Subject:Date:In-Reply-To:References:From; b=fObJDeUqrX89ga6U+We2XUcAs9Qg9tGiJvGfL2aHjzN8jvbfNi2YtyJNibOcXef5D 9yj4H7y8NNTAWGHsv7/iCq9oha194D9Am4Ok1EUzFLI7aixGqjUy9A81j2CyCWiSZ7 wmQ/HGHZSK8aVbnAMs1IU1+f7W00lBFzNdOJLD3lC7NWrsMjtgPKKmhP8ySlOJPZrO WKmNOP2mwxlqbfwZjEO9ABZqLxFs/JLQbGdjupM5CbvqTGMCEuw1Y4zwg+6HhVbSOJ /DFMGe6bvCEy6VgtccycuXSakiQvXW+EpHyRCysn4qElmP9afGuyG02zq/jqyRpOb7 Cza5BOQTz6nkg== Received: by pali.im (Postfix) id 9217115B0; Sun, 8 Aug 2021 18:25:14 +0200 (CEST) From: =?UTF-8?q?Pali=20Roh=C3=A1r?= To: 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 , =?UTF-8?q?Marek=20Beh=C3=BAn?= , Christoph Hellwig Subject: [RFC PATCH 04/20] isofs: joliet: Fix iocharset=utf8 mount option Date: Sun, 8 Aug 2021 18:24:37 +0200 Message-Id: <20210808162453.1653-5-pali@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210808162453.1653-1-pali@kernel.org> References: <20210808162453.1653-1-pali@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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_iocharset is set to NULL. So simplify code around, remove s_utf8 field as to distinguish between UTF-8 and non-UTF-8 it is needed just to check if s_nls_iocharset is set to NULL or not. Signed-off-by: Pali Rohár --- fs/isofs/inode.c | 27 +++++++++++++-------------- fs/isofs/isofs.h | 1 - fs/isofs/joliet.c | 4 +--- 3 files changed, 14 insertions(+), 18 deletions(-) diff --git a/fs/isofs/inode.c b/fs/isofs/inode.c index 21edc423b79f..678e2c51b855 100644 --- a/fs/isofs/inode.c +++ b/fs/isofs/inode.c @@ -155,7 +155,6 @@ struct iso9660_options{ unsigned int overriderockperm:1; unsigned int uid_set:1; unsigned int gid_set:1; - unsigned int utf8:1; unsigned char map; unsigned char check; unsigned int blocksize; @@ -356,7 +355,6 @@ static int parse_options(char *options, struct iso9660_options *popt) popt->gid = GLOBAL_ROOT_GID; popt->uid = GLOBAL_ROOT_UID; popt->iocharset = NULL; - popt->utf8 = 0; popt->overriderockperm = 0; popt->session=-1; popt->sbsector=-1; @@ -389,10 +387,13 @@ static int parse_options(char *options, struct iso9660_options *popt) case Opt_cruft: popt->cruft = 1; break; +#ifdef CONFIG_JOLIET case Opt_utf8: - popt->utf8 = 1; + kfree(popt->iocharset); + popt->iocharset = kstrdup("utf8", GFP_KERNEL); + if (!popt->iocharset) + return 0; break; -#ifdef CONFIG_JOLIET case Opt_iocharset: kfree(popt->iocharset); popt->iocharset = match_strdup(&args[0]); @@ -495,7 +496,6 @@ static int isofs_show_options(struct seq_file *m, struct dentry *root) if (sbi->s_nocompress) seq_puts(m, ",nocompress"); if (sbi->s_overriderockperm) seq_puts(m, ",overriderockperm"); if (sbi->s_showassoc) seq_puts(m, ",showassoc"); - if (sbi->s_utf8) seq_puts(m, ",utf8"); if (sbi->s_check) seq_printf(m, ",check=%c", sbi->s_check); if (sbi->s_mapping) seq_printf(m, ",map=%c", sbi->s_mapping); @@ -518,9 +518,10 @@ static int isofs_show_options(struct seq_file *m, struct dentry *root) seq_printf(m, ",fmode=%o", sbi->s_fmode); #ifdef CONFIG_JOLIET - if (sbi->s_nls_iocharset && - strcmp(sbi->s_nls_iocharset->charset, CONFIG_NLS_DEFAULT) != 0) + if (sbi->s_nls_iocharset) seq_printf(m, ",iocharset=%s", sbi->s_nls_iocharset->charset); + else + seq_puts(m, ",iocharset=utf8"); #endif return 0; } @@ -863,14 +864,13 @@ static int isofs_fill_super(struct super_block *s, void *data, int silent) sbi->s_nls_iocharset = NULL; #ifdef CONFIG_JOLIET - if (joliet_level && opt.utf8 == 0) { + if (joliet_level) { char *p = opt.iocharset ? opt.iocharset : CONFIG_NLS_DEFAULT; - sbi->s_nls_iocharset = load_nls(p); - if (! sbi->s_nls_iocharset) { - /* Fail only if explicit charset specified */ - if (opt.iocharset) + if (strcmp(p, "utf8") != 0) { + sbi->s_nls_iocharset = opt.iocharset ? + load_nls(opt.iocharset) : load_nls_default(); + if (!sbi->s_nls_iocharset) goto out_freesbi; - sbi->s_nls_iocharset = load_nls_default(); } } #endif @@ -886,7 +886,6 @@ static int isofs_fill_super(struct super_block *s, void *data, int silent) sbi->s_gid = opt.gid; sbi->s_uid_set = opt.uid_set; sbi->s_gid_set = opt.gid_set; - sbi->s_utf8 = opt.utf8; sbi->s_nocompress = opt.nocompress; sbi->s_overriderockperm = opt.overriderockperm; /* diff --git a/fs/isofs/isofs.h b/fs/isofs/isofs.h index 055ec6c586f7..dcdc191ed183 100644 --- a/fs/isofs/isofs.h +++ b/fs/isofs/isofs.h @@ -44,7 +44,6 @@ struct isofs_sb_info { unsigned char s_session; unsigned int s_high_sierra:1; unsigned int s_rock:2; - unsigned int s_utf8:1; unsigned int s_cruft:1; /* Broken disks with high byte of length * containing junk */ unsigned int s_nocompress:1; diff --git a/fs/isofs/joliet.c b/fs/isofs/joliet.c index be8b6a9d0b92..c0f04a1e7f69 100644 --- a/fs/isofs/joliet.c +++ b/fs/isofs/joliet.c @@ -41,14 +41,12 @@ uni16_to_x8(unsigned char *ascii, __be16 *uni, int len, struct nls_table *nls) int get_joliet_filename(struct iso_directory_record * de, unsigned char *outname, struct inode * inode) { - unsigned char utf8; struct nls_table *nls; unsigned char len = 0; - utf8 = ISOFS_SB(inode->i_sb)->s_utf8; nls = ISOFS_SB(inode->i_sb)->s_nls_iocharset; - if (utf8) { + if (!nls) { len = utf16s_to_utf8s((const wchar_t *) de->name, de->name_len[0] >> 1, UTF16_BIG_ENDIAN, outname, PAGE_SIZE); -- 2.20.1