summaryrefslogtreecommitdiff
path: root/e2fsck/message.c
diff options
context:
space:
mode:
authorTheodore Ts'o <tytso@mit.edu>1999-01-09 16:32:31 +0000
committerTheodore Ts'o <tytso@mit.edu>1999-01-09 16:32:31 +0000
commit9e51eca782b8e17a1ec87944ccbeac94c7c8e2a1 (patch)
treebf671b7d35d53882a0a27f39243c90042bbb4a3c /e2fsck/message.c
parent40fa8cc9b03a8f25e7cb9ddc100e15f868cc3863 (diff)
downloade2fsprogs-9e51eca782b8e17a1ec87944ccbeac94c7c8e2a1.tar.gz
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.
Diffstat (limited to 'e2fsck/message.c')
-rw-r--r--e2fsck/message.c30
1 files changed, 28 insertions, 2 deletions
diff --git a/e2fsck/message.c b/e2fsck/message.c
index c839bbf2..1e440c5c 100644
--- a/e2fsck/message.c
+++ b/e2fsck/message.c
@@ -131,6 +131,32 @@ static const char *special_inode_name[] =
};
/*
+ * 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 @@ static void print_pathname(ext2_filsys fs, ino_t dir, ino_t ino)
if (retval)
fputs("???", stdout);
else {
- fputs(path, stdout);
+ safe_print(path, -1);
ext2fs_free_mem((void **) &path);
}
}
@@ -267,7 +293,7 @@ static _INLINE_ void expand_dirent_expression(char ch,
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);