Skip to content

Commit

Permalink
fs/jfs: Use common ucs2 upper case table
Browse files Browse the repository at this point in the history
Use the UCS-2 upper case tables from nls, that are shared
with smb.

This code in JFS is hard to test, so we're only reusing the
same tables (which are identical), not trying to reuse the
rest of the helper functions.

Signed-off-by: Dr. David Alan Gilbert <linux@treblig.org>
Reviewed-by: Dave Kleikamp <dave.kleikamp@oracle.com>
Signed-off-by: Steve French <stfrench@microsoft.com>
  • Loading branch information
Dr. David Alan Gilbert authored and Steve French committed Aug 30, 2023
1 parent de54845 commit f3a9b37
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 147 deletions.
1 change: 1 addition & 0 deletions fs/jfs/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
config JFS_FS
tristate "JFS filesystem support"
select NLS
select NLS_UCS2_UTILS
select CRC32
select LEGACY_DIRECT_IO
help
Expand Down
2 changes: 1 addition & 1 deletion fs/jfs/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jfs-y := super.o file.o inode.o namei.o jfs_mount.o jfs_umount.o \
jfs_xtree.o jfs_imap.o jfs_debug.o jfs_dmap.o \
jfs_unicode.o jfs_dtree.o jfs_inode.o jfs_discard.o \
jfs_extent.o symlink.o jfs_metapage.o \
jfs_logmgr.o jfs_txnmgr.o jfs_uniupr.o \
jfs_logmgr.o jfs_txnmgr.o \
resize.o xattr.o ioctl.o

jfs-$(CONFIG_JFS_POSIX_ACL) += acl.o
17 changes: 5 additions & 12 deletions fs/jfs/jfs_unicode.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,9 @@

#include <linux/slab.h>
#include <asm/byteorder.h>
#include "../nls/nls_ucs2_data.h"
#include "jfs_types.h"

typedef struct {
wchar_t start;
wchar_t end;
signed char *table;
} UNICASERANGE;

extern signed char UniUpperTable[512];
extern UNICASERANGE UniUpperRange[];
extern int get_UCSname(struct component_name *, struct dentry *);
extern int jfs_strfromUCS_le(char *, const __le16 *, int, struct nls_table *);

Expand Down Expand Up @@ -107,12 +100,12 @@ static inline wchar_t *UniStrncpy_from_le(wchar_t * ucs1, const __le16 * ucs2,
*/
static inline wchar_t UniToupper(wchar_t uc)
{
UNICASERANGE *rp;
const struct UniCaseRange *rp;

if (uc < sizeof(UniUpperTable)) { /* Latin characters */
return uc + UniUpperTable[uc]; /* Use base tables */
if (uc < sizeof(NlsUniUpperTable)) { /* Latin characters */
return uc + NlsUniUpperTable[uc]; /* Use base tables */
} else {
rp = UniUpperRange; /* Use range tables */
rp = NlsUniUpperRange; /* Use range tables */
while (rp->start) {
if (uc < rp->start) /* Before start of range */
return uc; /* Uppercase = input */
Expand Down
121 changes: 0 additions & 121 deletions fs/jfs/jfs_uniupr.c

This file was deleted.

15 changes: 15 additions & 0 deletions fs/nls/nls_ucs2_data.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/* SPDX-License-Identifier: GPL-2.0-or-later */

#ifndef _NLS_UCS2_DATA_H
#define _NLS_UCS2_DATA_H

struct UniCaseRange {
wchar_t start;
wchar_t end;
signed char *table;
};

extern signed char NlsUniUpperTable[512];
extern const struct UniCaseRange NlsUniUpperRange[];

#endif /* _NLS_UCS2_DATA_H */
14 changes: 1 addition & 13 deletions fs/nls/nls_ucs2_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#include <linux/types.h>
#include <linux/nls.h>
#include <linux/unicode.h>
#include "nls_ucs2_data.h"

/*
* Windows maps these to the user defined 16 bit Unicode range since they are
Expand All @@ -40,19 +41,6 @@
#define UNI_PIPE ((__u16)('|' + 0xF000))
#define UNI_SLASH ((__u16)('\\' + 0xF000))

#ifndef UNICASERANGE_DEFINED
struct UniCaseRange {
wchar_t start;
wchar_t end;
signed char *table;
};
#endif /* UNICASERANGE_DEFINED */

#ifndef UNIUPR_NOUPPER
extern signed char NlsUniUpperTable[512];
extern const struct UniCaseRange NlsUniUpperRange[];
#endif /* UNIUPR_NOUPPER */

/*
* UniStrcat: Concatenate the second string to the first
*
Expand Down

0 comments on commit f3a9b37

Please sign in to comment.