Skip to contentSkip to conversation

unicode: Expose available encodings in sysfs

PATCH New Gabriel Krisman Bertazi 1 participant 1 message Apr 21, 2020

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH v3 1/1 unicode: Expose available encodings in sysfs

A filesystem configuration utility has no way to detect which filename encodings are supported by the running kernel. This means, for instance, mkfs has no way to tell if the generated filesystem will be mountable in the current kernel or not. Also, users have no easy way to know if they can update the encoding in their filesystems and still have something functional in the end.

This exposes details of the encodings available in the unicode subsystem to fill that gap.

Changes since v2:
- Change sysfs topology (Ezequiel)
- Add end period (Ezequiel)
- change module_init to fs_initcall (Ezequiel)
Changes since v1:
- Make init functions static. (lkp)

---
 Documentation/ABI/testing/sysfs-fs-unicode |  6 +++
 fs/unicode/utf8-core.c                     | 55 ++++++++++++++++++++++
 fs/unicode/utf8n.h                         |  4 ++
 3 files changed, 65 insertions(+)
 create mode 100644 Documentation/ABI/testing/sysfs-fs-unicode
Documentation/ABI/testing/sysfs-fs-unicode new file +6 -0
new file mode 100644
index 000000000000..b56e0dda6550
@@ -0,0 +1,6 @@
+What:		/sys/fs/unicode/<encoding>/latest_version
+Date:		April 2020
+Contact:	Gabriel Krisman Bertazi <[email protected]>
+Description:
+		The latest version of the Unicode Standard supported by
+		this encoding in this kernel.
fs/unicode/utf8-core.c +55 -0

65 lines not on this page · raw message

fs/unicode/utf8n.h +4 -0
index 0acd530c2c79..a14fa1e2f4c8 100644
@@ -21,6 +21,10 @@
 	 ((unsigned int)(MIN) << UNICODE_MIN_SHIFT) |	\
 	 ((unsigned int)(REV)))
 
+#define UNICODE_AGE_MAJ(x) ((x) >> UNICODE_MAJ_SHIFT & 0xff)
+#define UNICODE_AGE_MIN(x) ((x) >> UNICODE_MIN_SHIFT & 0xff)
+#define UNICODE_AGE_REV(x) ((x) & 0xff)
+
 /* Highest unicode version supported by the data tables. */
 extern int utf8version_is_supported(u8 maj, u8 min, u8 rev);
 extern int utf8version_latest(void);
Signature · 1 line
2.26.1