Received: by 2002:a05:6a10:c604:0:0:0:0 with SMTP id y4csp2064014pxt; Sun, 8 Aug 2021 10:14:22 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwhGVPbylY2IiA3f04+Ygo5pO42EfEX6/Q5ApJqVA8DCdJXMFcB9syYDTq4x6sU+kwOGCzu X-Received: by 2002:a05:6402:1395:: with SMTP id b21mr24339268edv.119.1628442851515; Sun, 08 Aug 2021 10:14:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1628442851; cv=none; d=google.com; s=arc-20160816; b=I1tDEvAKSqlcaXaqVzgiQdlNV9oeU+NA5quU3JumDT4DdW9VvQU26C2r9Fe7SalhpH rCaXljxBYqQaVkFvQ8078/jfQPF4Y76y2e+jo3fP49tAl3e/7lU7fg9lWrRP9t5FRWXx rRkETH9ww/6C0I/2JfnQqZtmQqnLVqDttEv0b+gkGa1g0fO7GIGom7Y0Gs+cfw5dL1JF 4B3zZWceurnq/HaCc3vRc/qZfNwuc6tUMAI0sfsAFma94vp2/ycOwJlRSsyHhBPPl+fj 1qRvysduT2iJgdeT5ETBp1RT8GgbRj71MGwUXD7CWmXNkkUnEHSJ3F5s7wcmiB5ykm/5 83GA== 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=Xlxrd+J5tNKvjzFvH9Iy6uB+hdD7q4qwnYo/xQrkdJ4=; b=C/nYrQciB+uS9w43jxvfxmL3bmH9AM/LLMoFFd1dRquVXESgkrJOIsl//fQ1Soh52x elOGj0TE3fXKUnUf7D0LoQ8T5B4dl693r7Tm9Q09ibczeu3drZuK4ItSdWHQDtpfAi/9 3Y0Vzj/9a1unIiRISpSIxOFldEHiPwugVT3EGheYMvTXDFtue/dIulz3obDMA7QNL4Ww 2Ang5oPm/inp8ViAqpTQfzPJY8mjITF03njZDnTwl6ALPiHFekC43h61hFSF7sC5tG/+ jHNhhk1VxGC/tXh2NU3h5OuYj8oo9feJWNkA7lBL1yyYhsLnVKpSsKMTO/FrFA9GJ5PQ dNtw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=BtwW5Zl6; 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 x5si13794214eju.306.2021.08.08.10.13.48; Sun, 08 Aug 2021 10:14:11 -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=BtwW5Zl6; 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 S232225AbhHHQZq (ORCPT + 99 others); Sun, 8 Aug 2021 12:25:46 -0400 Received: from mail.kernel.org ([198.145.29.99]:47362 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232036AbhHHQZj (ORCPT ); Sun, 8 Aug 2021 12:25:39 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 04B2E61057; Sun, 8 Aug 2021 16:25:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1628439920; bh=yqPsetOw4W6bNgWR24S/rgdafRjACRvNO9i2APLG5Ro=; h=From:To:Subject:Date:In-Reply-To:References:From; b=BtwW5Zl6wIxOKHFKlHcsPRe+j0YTnRSwYl6E6kuEnVHwY4CBX48L8O0rugI7wyCYC UnlD/kWdvO4XtPIXqTb9wFag7zVQd+J2uBqrUWWzyXYo7l34TOngROP6s7SQhK15CC ky5BgKIX53TpuEKZmKIFlZ9O8/DntW5KQ//t2T6jHyh2ljsaRO9T+KnRJbQ8f0R3TE UHq3mHTu4YXURWwRjPI43ewlLrf73Cra+K38i6EMoOMJsyUr8tat/P1CqLlFLgi3Go XZf3P9HXbdpA910MyUK3rx5xNerwfViTPsPc+th1TeeFWtsn74GqakoahK2cdtspTH 7JxuJHSVoY2YA== Received: by pali.im (Postfix) id B983D1430; Sun, 8 Aug 2021 18:25:19 +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 14/20] jfs: Remove custom iso8859-1 implementation Date: Sun, 8 Aug 2021 18:24:47 +0200 Message-Id: <20210808162453.1653-15-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 When iocharset= mount option is not specified or when is set to iocharset=none then jfs driver uses its own custom iso8895-1 encoding implementation. NLS already provides iso8895-1 module, so use it instead of custom jfs iso8859-1 implementation. Signed-off-by: Pali Rohár --- fs/jfs/jfs_unicode.c | 14 +------------- fs/jfs/super.c | 29 +++++++++++++++++++---------- 2 files changed, 20 insertions(+), 23 deletions(-) diff --git a/fs/jfs/jfs_unicode.c b/fs/jfs/jfs_unicode.c index 0c1e9027245a..1d0f65d13b58 100644 --- a/fs/jfs/jfs_unicode.c +++ b/fs/jfs/jfs_unicode.c @@ -33,13 +33,8 @@ int jfs_strfromUCS_le(char *to, const __le16 * from, NLS_MAX_CHARSET_SIZE); if (charlen > 0) outlen += charlen; - else + else { to[outlen++] = '?'; - } - } else { - for (i = 0; (i < len) && from[i]; i++) { - if (unlikely(le16_to_cpu(from[i]) & 0xff00)) { - to[i] = '?'; if (unlikely(warn)) { warn--; warn_again--; @@ -49,12 +44,8 @@ int jfs_strfromUCS_le(char *to, const __le16 * from, printk(KERN_ERR "mount with iocharset=utf8 to access\n"); } - } - else - to[i] = (char) (le16_to_cpu(from[i])); } - outlen = i; } to[outlen] = 0; return outlen; @@ -84,9 +75,6 @@ static int jfs_strtoUCS(wchar_t * to, const unsigned char *from, int len, return charlen; } } - } else { - for (i = 0; (i < len) && from[i]; i++) - to[i] = (wchar_t) from[i]; } to[i] = 0; diff --git a/fs/jfs/super.c b/fs/jfs/super.c index 9030aeaf0f88..8ba2ac032292 100644 --- a/fs/jfs/super.c +++ b/fs/jfs/super.c @@ -231,7 +231,7 @@ static const match_table_t tokens = { }; static int parse_options(char *options, struct super_block *sb, s64 *newLVSize, - int *flag) + int *flag, int remount) { void *nls_map = (void *)-1; /* -1: no change; NULL: none */ char *p; @@ -263,14 +263,14 @@ static int parse_options(char *options, struct super_block *sb, s64 *newLVSize, case Opt_iocharset: if (nls_map && nls_map != (void *) -1) unload_nls(nls_map); - if (!strcmp(args[0].from, "none")) - nls_map = NULL; - else { + /* compatibility alias none means ISO-8859-1 */ + if (strcmp(args[0].from, "none") == 0) + nls_map = load_nls("iso8859-1"); + else nls_map = load_nls(args[0].from); - if (!nls_map) { - pr_err("JFS: charset not found\n"); - goto cleanup; - } + if (!nls_map) { + pr_err("JFS: charset not found\n"); + goto cleanup; } break; case Opt_resize: @@ -414,6 +414,15 @@ static int parse_options(char *options, struct super_block *sb, s64 *newLVSize, } } + if (!remount && nls_map == (void *) -1) { + /* Previously default NLS table was ISO-8859-1 */ + nls_map = load_nls("iso8859-1"); + if (!nls_map) { + pr_err("JFS: iso8859-1 charset not found\n"); + goto cleanup; + } + } + if (nls_map != (void *) -1) { /* Discard old (if remount) */ unload_nls(sbi->nls_tab); @@ -435,7 +444,7 @@ static int jfs_remount(struct super_block *sb, int *flags, char *data) int ret; sync_filesystem(sb); - if (!parse_options(data, sb, &newLVSize, &flag)) + if (!parse_options(data, sb, &newLVSize, &flag, 1)) return -EINVAL; if (newLVSize) { @@ -513,7 +522,7 @@ static int jfs_fill_super(struct super_block *sb, void *data, int silent) /* initialize the mount flag and determine the default error handler */ flag = JFS_ERR_REMOUNT_RO; - if (!parse_options((char *) data, sb, &newLVSize, &flag)) + if (!parse_options((char *) data, sb, &newLVSize, &flag, 0)) goto out_kfree; sbi->flag = flag; -- 2.20.1