Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

unicode: clean up the Kconfig symbol confusion

Turn the CONFIG_UNICODE symbol into a tristate that generates some always
built in code and remove the confusing CONFIG_UNICODE_UTF8_DATA symbol.

Note that a lot of the IS_ENABLED() checks could be turned from cpp
statements into normal ifs, but this change is intended to be fairly
mechanic, so that should be cleaned up later.

Fixes: 2b3d04787012 ("unicode: Add utf8-data module")
Reported-by: Linus Torvalds <torvalds@linux-foundation.org>
Reviewed-by: Eric Biggers <ebiggers@google.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Gabriel Krisman Bertazi <krisman@collabora.com>

authored by

Christoph Hellwig and committed by
Gabriel Krisman Bertazi
5298d4bf 6661224e

+60 -66
+1 -1
fs/Makefile
··· 94 94 obj-$(CONFIG_NFSD) += nfsd/ 95 95 obj-$(CONFIG_LOCKD) += lockd/ 96 96 obj-$(CONFIG_NLS) += nls/ 97 - obj-$(CONFIG_UNICODE) += unicode/ 97 + obj-y += unicode/ 98 98 obj-$(CONFIG_SYSV_FS) += sysv/ 99 99 obj-$(CONFIG_SMBFS_COMMON) += smbfs_common/ 100 100 obj-$(CONFIG_CIFS) += cifs/
+7 -7
fs/ext4/ext4.h
··· 2485 2485 #ifdef CONFIG_FS_ENCRYPTION 2486 2486 struct fscrypt_str crypto_buf; 2487 2487 #endif 2488 - #ifdef CONFIG_UNICODE 2488 + #if IS_ENABLED(CONFIG_UNICODE) 2489 2489 struct fscrypt_str cf_name; 2490 2490 #endif 2491 2491 }; ··· 2721 2721 struct ext4_group_desc *gdp); 2722 2722 ext4_fsblk_t ext4_inode_to_goal_block(struct inode *); 2723 2723 2724 - #ifdef CONFIG_UNICODE 2724 + #if IS_ENABLED(CONFIG_UNICODE) 2725 2725 extern int ext4_fname_setup_ci_filename(struct inode *dir, 2726 2726 const struct qstr *iname, 2727 2727 struct ext4_filename *fname); ··· 2754 2754 2755 2755 ext4_fname_from_fscrypt_name(fname, &name); 2756 2756 2757 - #ifdef CONFIG_UNICODE 2757 + #if IS_ENABLED(CONFIG_UNICODE) 2758 2758 err = ext4_fname_setup_ci_filename(dir, iname, fname); 2759 2759 #endif 2760 2760 return err; ··· 2773 2773 2774 2774 ext4_fname_from_fscrypt_name(fname, &name); 2775 2775 2776 - #ifdef CONFIG_UNICODE 2776 + #if IS_ENABLED(CONFIG_UNICODE) 2777 2777 err = ext4_fname_setup_ci_filename(dir, &dentry->d_name, fname); 2778 2778 #endif 2779 2779 return err; ··· 2790 2790 fname->usr_fname = NULL; 2791 2791 fname->disk_name.name = NULL; 2792 2792 2793 - #ifdef CONFIG_UNICODE 2793 + #if IS_ENABLED(CONFIG_UNICODE) 2794 2794 kfree(fname->cf_name.name); 2795 2795 fname->cf_name.name = NULL; 2796 2796 #endif ··· 2806 2806 fname->disk_name.name = (unsigned char *) iname->name; 2807 2807 fname->disk_name.len = iname->len; 2808 2808 2809 - #ifdef CONFIG_UNICODE 2809 + #if IS_ENABLED(CONFIG_UNICODE) 2810 2810 err = ext4_fname_setup_ci_filename(dir, iname, fname); 2811 2811 #endif 2812 2812 ··· 2822 2822 2823 2823 static inline void ext4_fname_free_filename(struct ext4_filename *fname) 2824 2824 { 2825 - #ifdef CONFIG_UNICODE 2825 + #if IS_ENABLED(CONFIG_UNICODE) 2826 2826 kfree(fname->cf_name.name); 2827 2827 fname->cf_name.name = NULL; 2828 2828 #endif
+1 -1
fs/ext4/hash.c
··· 290 290 int ext4fs_dirhash(const struct inode *dir, const char *name, int len, 291 291 struct dx_hash_info *hinfo) 292 292 { 293 - #ifdef CONFIG_UNICODE 293 + #if IS_ENABLED(CONFIG_UNICODE) 294 294 const struct unicode_map *um = dir->i_sb->s_encoding; 295 295 int r, dlen; 296 296 unsigned char *buff;
+6 -6
fs/ext4/namei.c
··· 1317 1317 dx_set_count(entries, count + 1); 1318 1318 } 1319 1319 1320 - #ifdef CONFIG_UNICODE 1320 + #if IS_ENABLED(CONFIG_UNICODE) 1321 1321 /* 1322 1322 * Test whether a case-insensitive directory entry matches the filename 1323 1323 * being searched for. If quick is set, assume the name being looked up ··· 1428 1428 f.crypto_buf = fname->crypto_buf; 1429 1429 #endif 1430 1430 1431 - #ifdef CONFIG_UNICODE 1431 + #if IS_ENABLED(CONFIG_UNICODE) 1432 1432 if (parent->i_sb->s_encoding && IS_CASEFOLDED(parent) && 1433 1433 (!IS_ENCRYPTED(parent) || fscrypt_has_encryption_key(parent))) { 1434 1434 if (fname->cf_name.name) { ··· 1800 1800 } 1801 1801 } 1802 1802 1803 - #ifdef CONFIG_UNICODE 1803 + #if IS_ENABLED(CONFIG_UNICODE) 1804 1804 if (!inode && IS_CASEFOLDED(dir)) { 1805 1805 /* Eventually we want to call d_add_ci(dentry, NULL) 1806 1806 * for negative dentries in the encoding case as ··· 2308 2308 if (fscrypt_is_nokey_name(dentry)) 2309 2309 return -ENOKEY; 2310 2310 2311 - #ifdef CONFIG_UNICODE 2311 + #if IS_ENABLED(CONFIG_UNICODE) 2312 2312 if (sb_has_strict_encoding(sb) && IS_CASEFOLDED(dir) && 2313 2313 sb->s_encoding && utf8_validate(sb->s_encoding, &dentry->d_name)) 2314 2314 return -EINVAL; ··· 3126 3126 ext4_fc_track_unlink(handle, dentry); 3127 3127 retval = ext4_mark_inode_dirty(handle, dir); 3128 3128 3129 - #ifdef CONFIG_UNICODE 3129 + #if IS_ENABLED(CONFIG_UNICODE) 3130 3130 /* VFS negative dentries are incompatible with Encoding and 3131 3131 * Case-insensitiveness. Eventually we'll want avoid 3132 3132 * invalidating the dentries here, alongside with returning the ··· 3231 3231 retval = __ext4_unlink(handle, dir, &dentry->d_name, d_inode(dentry)); 3232 3232 if (!retval) 3233 3233 ext4_fc_track_unlink(handle, dentry); 3234 - #ifdef CONFIG_UNICODE 3234 + #if IS_ENABLED(CONFIG_UNICODE) 3235 3235 /* VFS negative dentries are incompatible with Encoding and 3236 3236 * Case-insensitiveness. Eventually we'll want avoid 3237 3237 * invalidating the dentries here, alongside with returning the
+5 -5
fs/ext4/super.c
··· 1302 1302 kfree(sbi->s_blockgroup_lock); 1303 1303 fs_put_dax(sbi->s_daxdev); 1304 1304 fscrypt_free_dummy_policy(&sbi->s_dummy_enc_policy); 1305 - #ifdef CONFIG_UNICODE 1305 + #if IS_ENABLED(CONFIG_UNICODE) 1306 1306 utf8_unload(sb->s_encoding); 1307 1307 #endif 1308 1308 kfree(sbi); ··· 1962 1962 {Opt_err, 0, 0} 1963 1963 }; 1964 1964 1965 - #ifdef CONFIG_UNICODE 1965 + #if IS_ENABLED(CONFIG_UNICODE) 1966 1966 static const struct ext4_sb_encodings { 1967 1967 __u16 magic; 1968 1968 char *name; ··· 3609 3609 return 0; 3610 3610 } 3611 3611 3612 - #ifndef CONFIG_UNICODE 3612 + #if !IS_ENABLED(CONFIG_UNICODE) 3613 3613 if (ext4_has_feature_casefold(sb)) { 3614 3614 ext4_msg(sb, KERN_ERR, 3615 3615 "Filesystem with casefold feature cannot be " ··· 4613 4613 if (err < 0) 4614 4614 goto failed_mount; 4615 4615 4616 - #ifdef CONFIG_UNICODE 4616 + #if IS_ENABLED(CONFIG_UNICODE) 4617 4617 if (ext4_has_feature_casefold(sb) && !sb->s_encoding) { 4618 4618 const struct ext4_sb_encodings *encoding_info; 4619 4619 struct unicode_map *encoding; ··· 5517 5517 if (sbi->s_chksum_driver) 5518 5518 crypto_free_shash(sbi->s_chksum_driver); 5519 5519 5520 - #ifdef CONFIG_UNICODE 5520 + #if IS_ENABLED(CONFIG_UNICODE) 5521 5521 utf8_unload(sb->s_encoding); 5522 5522 #endif 5523 5523
+4 -4
fs/ext4/sysfs.c
··· 309 309 EXT4_ATTR_FEATURE(encryption); 310 310 EXT4_ATTR_FEATURE(test_dummy_encryption_v2); 311 311 #endif 312 - #ifdef CONFIG_UNICODE 312 + #if IS_ENABLED(CONFIG_UNICODE) 313 313 EXT4_ATTR_FEATURE(casefold); 314 314 #endif 315 315 #ifdef CONFIG_FS_VERITY ··· 317 317 #endif 318 318 EXT4_ATTR_FEATURE(metadata_csum_seed); 319 319 EXT4_ATTR_FEATURE(fast_commit); 320 - #if defined(CONFIG_UNICODE) && defined(CONFIG_FS_ENCRYPTION) 320 + #if IS_ENABLED(CONFIG_UNICODE) && defined(CONFIG_FS_ENCRYPTION) 321 321 EXT4_ATTR_FEATURE(encrypted_casefold); 322 322 #endif 323 323 ··· 329 329 ATTR_LIST(encryption), 330 330 ATTR_LIST(test_dummy_encryption_v2), 331 331 #endif 332 - #ifdef CONFIG_UNICODE 332 + #if IS_ENABLED(CONFIG_UNICODE) 333 333 ATTR_LIST(casefold), 334 334 #endif 335 335 #ifdef CONFIG_FS_VERITY ··· 337 337 #endif 338 338 ATTR_LIST(metadata_csum_seed), 339 339 ATTR_LIST(fast_commit), 340 - #if defined(CONFIG_UNICODE) && defined(CONFIG_FS_ENCRYPTION) 340 + #if IS_ENABLED(CONFIG_UNICODE) && defined(CONFIG_FS_ENCRYPTION) 341 341 ATTR_LIST(encrypted_casefold), 342 342 #endif 343 343 NULL,
+5 -5
fs/f2fs/dir.c
··· 16 16 #include "xattr.h" 17 17 #include <trace/events/f2fs.h> 18 18 19 - #ifdef CONFIG_UNICODE 19 + #if IS_ENABLED(CONFIG_UNICODE) 20 20 extern struct kmem_cache *f2fs_cf_name_slab; 21 21 #endif 22 22 ··· 79 79 int f2fs_init_casefolded_name(const struct inode *dir, 80 80 struct f2fs_filename *fname) 81 81 { 82 - #ifdef CONFIG_UNICODE 82 + #if IS_ENABLED(CONFIG_UNICODE) 83 83 struct super_block *sb = dir->i_sb; 84 84 85 85 if (IS_CASEFOLDED(dir)) { ··· 174 174 kfree(fname->crypto_buf.name); 175 175 fname->crypto_buf.name = NULL; 176 176 #endif 177 - #ifdef CONFIG_UNICODE 177 + #if IS_ENABLED(CONFIG_UNICODE) 178 178 if (fname->cf_name.name) { 179 179 kmem_cache_free(f2fs_cf_name_slab, fname->cf_name.name); 180 180 fname->cf_name.name = NULL; ··· 208 208 return f2fs_find_target_dentry(&d, fname, max_slots); 209 209 } 210 210 211 - #ifdef CONFIG_UNICODE 211 + #if IS_ENABLED(CONFIG_UNICODE) 212 212 /* 213 213 * Test whether a case-insensitive directory entry matches the filename 214 214 * being searched for. ··· 266 266 { 267 267 struct fscrypt_name f; 268 268 269 - #ifdef CONFIG_UNICODE 269 + #if IS_ENABLED(CONFIG_UNICODE) 270 270 if (fname->cf_name.name) { 271 271 struct qstr cf = FSTR_TO_QSTR(&fname->cf_name); 272 272
+1 -1
fs/f2fs/f2fs.h
··· 487 487 */ 488 488 struct fscrypt_str crypto_buf; 489 489 #endif 490 - #ifdef CONFIG_UNICODE 490 + #if IS_ENABLED(CONFIG_UNICODE) 491 491 /* 492 492 * For casefolded directories: the casefolded name, but it's left NULL 493 493 * if the original name is not valid Unicode, if the directory is both
+1 -1
fs/f2fs/hash.c
··· 105 105 return; 106 106 } 107 107 108 - #ifdef CONFIG_UNICODE 108 + #if IS_ENABLED(CONFIG_UNICODE) 109 109 if (IS_CASEFOLDED(dir)) { 110 110 /* 111 111 * If the casefolded name is provided, hash it instead of the
+2 -2
fs/f2fs/namei.c
··· 561 561 goto out_iput; 562 562 } 563 563 out_splice: 564 - #ifdef CONFIG_UNICODE 564 + #if IS_ENABLED(CONFIG_UNICODE) 565 565 if (!inode && IS_CASEFOLDED(dir)) { 566 566 /* Eventually we want to call d_add_ci(dentry, NULL) 567 567 * for negative dentries in the encoding case as ··· 622 622 goto fail; 623 623 } 624 624 f2fs_delete_entry(de, page, dir, inode); 625 - #ifdef CONFIG_UNICODE 625 + #if IS_ENABLED(CONFIG_UNICODE) 626 626 /* VFS negative dentries are incompatible with Encoding and 627 627 * Case-insensitiveness. Eventually we'll want avoid 628 628 * invalidating the dentries here, alongside with returning the
+2 -2
fs/f2fs/recovery.c
··· 46 46 47 47 static struct kmem_cache *fsync_entry_slab; 48 48 49 - #ifdef CONFIG_UNICODE 49 + #if IS_ENABLED(CONFIG_UNICODE) 50 50 extern struct kmem_cache *f2fs_cf_name_slab; 51 51 #endif 52 52 ··· 149 149 if (err) 150 150 return err; 151 151 f2fs_hash_filename(dir, fname); 152 - #ifdef CONFIG_UNICODE 152 + #if IS_ENABLED(CONFIG_UNICODE) 153 153 /* Case-sensitive match is fine for recovery */ 154 154 kmem_cache_free(f2fs_cf_name_slab, fname->cf_name.name); 155 155 fname->cf_name.name = NULL;
+5 -5
fs/f2fs/super.c
··· 256 256 va_end(args); 257 257 } 258 258 259 - #ifdef CONFIG_UNICODE 259 + #if IS_ENABLED(CONFIG_UNICODE) 260 260 static const struct f2fs_sb_encodings { 261 261 __u16 magic; 262 262 char *name; ··· 1218 1218 return -EINVAL; 1219 1219 } 1220 1220 #endif 1221 - #ifndef CONFIG_UNICODE 1221 + #if !IS_ENABLED(CONFIG_UNICODE) 1222 1222 if (f2fs_sb_has_casefold(sbi)) { 1223 1223 f2fs_err(sbi, 1224 1224 "Filesystem with casefold feature cannot be mounted without CONFIG_UNICODE"); ··· 1578 1578 f2fs_destroy_iostat(sbi); 1579 1579 for (i = 0; i < NR_PAGE_TYPE; i++) 1580 1580 kvfree(sbi->write_io[i]); 1581 - #ifdef CONFIG_UNICODE 1581 + #if IS_ENABLED(CONFIG_UNICODE) 1582 1582 utf8_unload(sb->s_encoding); 1583 1583 #endif 1584 1584 kfree(sbi); ··· 3861 3861 3862 3862 static int f2fs_setup_casefold(struct f2fs_sb_info *sbi) 3863 3863 { 3864 - #ifdef CONFIG_UNICODE 3864 + #if IS_ENABLED(CONFIG_UNICODE) 3865 3865 if (f2fs_sb_has_casefold(sbi) && !sbi->sb->s_encoding) { 3866 3866 const struct f2fs_sb_encodings *encoding_info; 3867 3867 struct unicode_map *encoding; ··· 4412 4412 for (i = 0; i < NR_PAGE_TYPE; i++) 4413 4413 kvfree(sbi->write_io[i]); 4414 4414 4415 - #ifdef CONFIG_UNICODE 4415 + #if IS_ENABLED(CONFIG_UNICODE) 4416 4416 utf8_unload(sb->s_encoding); 4417 4417 sb->s_encoding = NULL; 4418 4418 #endif
+5 -5
fs/f2fs/sysfs.c
··· 192 192 static ssize_t encoding_show(struct f2fs_attr *a, 193 193 struct f2fs_sb_info *sbi, char *buf) 194 194 { 195 - #ifdef CONFIG_UNICODE 195 + #if IS_ENABLED(CONFIG_UNICODE) 196 196 struct super_block *sb = sbi->sb; 197 197 198 198 if (f2fs_sb_has_casefold(sbi)) ··· 756 756 #ifdef CONFIG_FS_ENCRYPTION 757 757 F2FS_FEATURE_RO_ATTR(encryption); 758 758 F2FS_FEATURE_RO_ATTR(test_dummy_encryption_v2); 759 - #ifdef CONFIG_UNICODE 759 + #if IS_ENABLED(CONFIG_UNICODE) 760 760 F2FS_FEATURE_RO_ATTR(encrypted_casefold); 761 761 #endif 762 762 #endif /* CONFIG_FS_ENCRYPTION */ ··· 775 775 F2FS_FEATURE_RO_ATTR(verity); 776 776 #endif 777 777 F2FS_FEATURE_RO_ATTR(sb_checksum); 778 - #ifdef CONFIG_UNICODE 778 + #if IS_ENABLED(CONFIG_UNICODE) 779 779 F2FS_FEATURE_RO_ATTR(casefold); 780 780 #endif 781 781 F2FS_FEATURE_RO_ATTR(readonly); ··· 886 886 #ifdef CONFIG_FS_ENCRYPTION 887 887 ATTR_LIST(encryption), 888 888 ATTR_LIST(test_dummy_encryption_v2), 889 - #ifdef CONFIG_UNICODE 889 + #if IS_ENABLED(CONFIG_UNICODE) 890 890 ATTR_LIST(encrypted_casefold), 891 891 #endif 892 892 #endif /* CONFIG_FS_ENCRYPTION */ ··· 905 905 ATTR_LIST(verity), 906 906 #endif 907 907 ATTR_LIST(sb_checksum), 908 - #ifdef CONFIG_UNICODE 908 + #if IS_ENABLED(CONFIG_UNICODE) 909 909 ATTR_LIST(casefold), 910 910 #endif 911 911 ATTR_LIST(readonly),
+5 -5
fs/libfs.c
··· 1379 1379 (inode->i_op == &empty_dir_inode_operations); 1380 1380 } 1381 1381 1382 - #ifdef CONFIG_UNICODE 1382 + #if IS_ENABLED(CONFIG_UNICODE) 1383 1383 /* 1384 1384 * Determine if the name of a dentry should be casefolded. 1385 1385 * ··· 1473 1473 }; 1474 1474 #endif 1475 1475 1476 - #if defined(CONFIG_FS_ENCRYPTION) && defined(CONFIG_UNICODE) 1476 + #if defined(CONFIG_FS_ENCRYPTION) && IS_ENABLED(CONFIG_UNICODE) 1477 1477 static const struct dentry_operations generic_encrypted_ci_dentry_ops = { 1478 1478 .d_hash = generic_ci_d_hash, 1479 1479 .d_compare = generic_ci_d_compare, ··· 1508 1508 #ifdef CONFIG_FS_ENCRYPTION 1509 1509 bool needs_encrypt_ops = dentry->d_flags & DCACHE_NOKEY_NAME; 1510 1510 #endif 1511 - #ifdef CONFIG_UNICODE 1511 + #if IS_ENABLED(CONFIG_UNICODE) 1512 1512 bool needs_ci_ops = dentry->d_sb->s_encoding; 1513 1513 #endif 1514 - #if defined(CONFIG_FS_ENCRYPTION) && defined(CONFIG_UNICODE) 1514 + #if defined(CONFIG_FS_ENCRYPTION) && IS_ENABLED(CONFIG_UNICODE) 1515 1515 if (needs_encrypt_ops && needs_ci_ops) { 1516 1516 d_set_d_op(dentry, &generic_encrypted_ci_dentry_ops); 1517 1517 return; ··· 1523 1523 return; 1524 1524 } 1525 1525 #endif 1526 - #ifdef CONFIG_UNICODE 1526 + #if IS_ENABLED(CONFIG_UNICODE) 1527 1527 if (needs_ci_ops) { 1528 1528 d_set_d_op(dentry, &generic_ci_dentry_ops); 1529 1529 return;
+5 -13
fs/unicode/Kconfig
··· 3 3 # UTF-8 normalization 4 4 # 5 5 config UNICODE 6 - bool "UTF-8 normalization and casefolding support" 6 + tristate "UTF-8 normalization and casefolding support" 7 7 help 8 8 Say Y here to enable UTF-8 NFD normalization and NFD+CF casefolding 9 - support. 10 - 11 - config UNICODE_UTF8_DATA 12 - tristate "UTF-8 normalization and casefolding tables" 13 - depends on UNICODE 14 - default UNICODE 15 - help 16 - This contains a large table of case foldings, which can be loaded as 17 - a separate module if you say M here. To be on the safe side stick 18 - to the default of Y. Saying N here makes no sense, if you do not want 19 - utf8 casefolding support, disable CONFIG_UNICODE instead. 9 + support. If you say M here the large table of case foldings will 10 + be a separate loadable module that gets requested only when a file 11 + system actually use it. 20 12 21 13 config UNICODE_NORMALIZATION_SELFTEST 22 14 tristate "Test UTF-8 normalization support" 23 - depends on UNICODE_UTF8_DATA 15 + depends on UNICODE
+4 -2
fs/unicode/Makefile
··· 1 1 # SPDX-License-Identifier: GPL-2.0 2 2 3 - obj-$(CONFIG_UNICODE) += unicode.o 3 + ifneq ($(CONFIG_UNICODE),) 4 + obj-y += unicode.o 5 + endif 6 + obj-$(CONFIG_UNICODE) += utf8data.o 4 7 obj-$(CONFIG_UNICODE_NORMALIZATION_SELFTEST) += utf8-selftest.o 5 - obj-$(CONFIG_UNICODE_UTF8_DATA) += utf8data.o 6 8 7 9 unicode-y := utf8-norm.o utf8-core.o 8 10
+1 -1
include/linux/fs.h
··· 1490 1490 #ifdef CONFIG_FS_VERITY 1491 1491 const struct fsverity_operations *s_vop; 1492 1492 #endif 1493 - #ifdef CONFIG_UNICODE 1493 + #if IS_ENABLED(CONFIG_UNICODE) 1494 1494 struct unicode_map *s_encoding; 1495 1495 __u16 s_encoding_flags; 1496 1496 #endif