From: Gabriel Krisman Bertazi <krisman@collabora.com>
To: tytso@mit.edu
Cc: linux-ext4@vger.kernel.org, kernel@collabora.com,
Gabriel Krisman Bertazi <krisman@collabora.com>
Subject: [PATCH] e2p: Print encoding information in superblock dump
Date: Tue, 4 Dec 2018 16:16:09 -0500 [thread overview]
Message-ID: <20181204211609.27477-1-krisman@collabora.com> (raw)
Display encoding related fields when printing superblock in places like
dumpe2fs or debugfs.
Signed-off-by: Gabriel Krisman Bertazi <krisman@collabora.com>
---
lib/e2p/e2p.h | 1 +
lib/e2p/encoding.c | 10 ++++++++++
lib/e2p/ls.c | 44 ++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 55 insertions(+)
diff --git a/lib/e2p/e2p.h b/lib/e2p/e2p.h
index cc2dbf39bfeb..f4cf2d611f2c 100644
--- a/lib/e2p/e2p.h
+++ b/lib/e2p/e2p.h
@@ -84,3 +84,4 @@ int e2p_string2encmode(char *string);
int e2p_str2encoding(const char *string);
int e2p_get_encoding_flags(int encoding);
int e2p_str2encoding_flags(int encoding, char *param, __u16 *flags);
+char *e2p_encoding2string(int encoding);
diff --git a/lib/e2p/encoding.c b/lib/e2p/encoding.c
index 88433310a1dd..6edc41a78964 100644
--- a/lib/e2p/encoding.c
+++ b/lib/e2p/encoding.c
@@ -61,6 +61,16 @@ int e2p_str2encoding(const char *string)
return -EINVAL;
}
+char *e2p_encoding2string(int encoding)
+{
+ int i;
+
+ for (i = 0; i < ARRAY_SIZE(ext4_encoding_map); i++)
+ if (ext4_encoding_map[i].encoding_magic == encoding)
+ return ext4_encoding_map[i].name;
+ return NULL;
+}
+
int e2p_get_encoding_flags(int encoding)
{
int i;
diff --git a/lib/e2p/ls.c b/lib/e2p/ls.c
index a7586e094da1..bb1fc8aa94da 100644
--- a/lib/e2p/ls.c
+++ b/lib/e2p/ls.c
@@ -142,6 +142,36 @@ static void print_mntopts(struct ext2_super_block * s, FILE *f)
#endif
}
+static void print_encoding_flags(int encoding, __u16 flags, FILE *f)
+{
+ int flags_found = 0;
+
+ fputs("Filename encoding flags: ", f);
+ if (flags & EXT4_ENC_STRICT_MODE_FL) {
+ fputs(" strict", f);
+ flags_found++;
+ }
+
+ if (encoding == EXT4_ENC_UTF8_11_0) {
+ if (flags & EXT4_UTF8_NORMALIZATION_TYPE_NFKD)
+ fputs(" NFKD", f);
+ else
+ fputs(" Unnormalized", f);
+ flags_found++;
+
+ if (flags & EXT4_UTF8_CASEFOLD_TYPE_NFKDCF)
+ fputs(" NFKDCF", f);
+ else
+ fputs(" toUpper", f);
+ flags_found++;
+ }
+
+ if (flags_found)
+ fputs("\n", f);
+ else
+ fputs(" (none)\n", f);
+}
+
static void print_super_flags(struct ext2_super_block * s, FILE *f)
{
int flags_found = 0;
@@ -457,6 +487,20 @@ void list_super2(struct ext2_super_block * sb, FILE *f)
*quota_sb_inump(sb, qtype));
}
+ if (ext2fs_has_feature_fname_encoding(sb)) {
+ str = e2p_encoding2string(sb->s_encoding);
+ if (str) {
+ fprintf(f, "Filename encoding: %s\n", str);
+ print_encoding_flags(sb->s_encoding,
+ sb->s_encoding_flags, f);
+ } else {
+ fprintf(f, "Filename encoding: Unknown (%hu)\n",
+ sb->s_encoding);
+ fprintf(f, "Filename encoding flags: 0x%hX\n",
+ sb->s_encoding_flags);
+ }
+ }
+
if (ext2fs_has_feature_metadata_csum(sb)) {
fprintf(f, "Checksum type: %s\n",
checksum_type(sb->s_checksum_type));
--
2.20.0.rc2
next reply other threads:[~2018-12-04 21:16 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-12-04 21:16 Gabriel Krisman Bertazi [this message]
2018-12-08 18:36 ` [PATCH] e2p: Print encoding information in superblock dump Theodore Y. Ts'o
2018-12-10 21:05 ` Gabriel Krisman Bertazi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20181204211609.27477-1-krisman@collabora.com \
--to=krisman@collabora.com \
--cc=kernel@collabora.com \
--cc=linux-ext4@vger.kernel.org \
--cc=tytso@mit.edu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).