ChangeLog, message.c:
message.c (safe_print): New function which prints strings, converting
non-printable characters using the '^' and M-notation. This function
is now used to print directory name entries and pathnames.
ChangeLog:
Update for release of E2fsprogs 1.14.
diff --git a/e2fsck/message.c b/e2fsck/message.c
index c839bbf..1e440c5 100644
--- a/e2fsck/message.c
+++ b/e2fsck/message.c
@@ -131,6 +131,32 @@
};
/*
+ * This function does "safe" printing. It will convert non-printable
+ * ASCII characters using '^' and M- notation.
+ */
+static void safe_print(const unsigned char *cp, int len)
+{
+ unsigned char ch;
+
+ if (len < 0)
+ len = strlen(cp);
+
+ while (len--) {
+ ch = *cp++;
+ if (ch > 128) {
+ fputs("M-", stdout);
+ ch -= 128;
+ }
+ if (ch < 32) {
+ fputc('^', stdout);
+ ch += 32;
+ }
+ fputc(ch, stdout);
+ }
+}
+
+
+/*
* This function prints a pathname, using the ext2fs_get_pathname
* function
*/
@@ -148,7 +174,7 @@
if (retval)
fputs("???", stdout);
else {
- fputs(path, stdout);
+ safe_print(path, -1);
ext2fs_free_mem((void **) &path);
}
}
@@ -267,7 +293,7 @@
len = EXT2_NAME_LEN;
if (len > dirent->rec_len)
len = dirent->rec_len;
- printf("%.*s", len, dirent->name);
+ safe_print(dirent->name, len);
break;
case 'r':
printf("%u", dirent->rec_len);