From 35ce354fa5688625961a62fae8d26f826b015593 Mon Sep 17 00:00:00 2001 From: Sebastien Buisson Date: Tue, 19 Oct 2021 13:06:02 +0200 Subject: [PATCH] LU-13717 sec: process Lustre enc inodes as normal enc inodes Lustre encrypted inodes have the EXT4_ENCRYPT_FL flag set on disk. This makes it possible for e2fsprogs to consider them as normal encrypted inodes. But as Lustre encrypted inodes may contain illegal characters in their names, it is also needed to escape non-printable characters in linkEA. Signed-off-by: Sebastien Buisson Change-Id: Iaf495f399e38e3ca7914b92059607d4babc1ad43 Reviewed-on: https://review.whamcloud.com/45212 Tested-by: jenkins Tested-by: Maloo Reviewed-by: Andreas Dilger --- debugfs/xattrs.c | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/debugfs/xattrs.c b/debugfs/xattrs.c index 4ebf6a0..e1fd2e8 100644 --- a/debugfs/xattrs.c +++ b/debugfs/xattrs.c @@ -247,6 +247,22 @@ static int print_lmastr(FILE *f, void *name, void *value, size_t value_len) return 0; } +static void print_name(FILE *f, const char *cp, int len) +{ + unsigned char ch; + + while (len--) { + ch = *cp++; + if (!isprint(ch) || ch == '\\') { + if (f) + fprintf(f, "\\x%02x", ch); + } else { + if (f) + fputc(ch, f); + } + } +} + static int print_linkea(FILE *f, void *name, void *value, size_t value_len) { struct link_ea_header *leh = value; @@ -285,9 +301,10 @@ static int print_linkea(FILE *f, void *name, void *value, size_t value_len) memcpy(&pfid, &lee->lee_parent_fid, sizeof(pfid)); fid_be_to_cpu(&pfid, &pfid); - fprintf(f, "%s idx=%u parent="DFID" name='%.*s'\n", - i == 0 ? "linkea:" : " ", i, PFID(&pfid), - reclen - (int)sizeof(*lee), lee->lee_name); + fprintf(f, "%s idx=%u parent="DFID" name='", + i == 0 ? "linkea:" : " ", i, PFID(&pfid)); + print_name(f, lee->lee_name, reclen - (int)sizeof(*lee)); + fprintf(f, "'\n"); lee = (struct link_ea_entry *)((char *)lee + reclen); value_len -= reclen; -- 1.8.3.1