summaryrefslogtreecommitdiffstats
path: root/misc-utils/blkid.c
diff options
context:
space:
mode:
authorKarel Zak2011-03-29 11:44:29 +0200
committerKarel Zak2011-03-29 11:44:29 +0200
commit36a74e1b450f95767671df44bee9c73f21e2dec5 (patch)
treef551854699ee8e92ec41703a693dc5d56bcca5b5 /misc-utils/blkid.c
parentpartx: add fallback for openat() to be usable on old systems (diff)
downloadkernel-qcow2-util-linux-36a74e1b450f95767671df44bee9c73f21e2dec5.tar.gz
kernel-qcow2-util-linux-36a74e1b450f95767671df44bee9c73f21e2dec5.tar.xz
kernel-qcow2-util-linux-36a74e1b450f95767671df44bee9c73f21e2dec5.zip
blkid: add -d option to print non-printable chars
Reported-by: laborer2008 laborer <laborer2008@gmail.com> Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'misc-utils/blkid.c')
-rw-r--r--misc-utils/blkid.c24
1 files changed, 16 insertions, 8 deletions
diff --git a/misc-utils/blkid.c b/misc-utils/blkid.c
index ca8083bfa..c8c95b6b1 100644
--- a/misc-utils/blkid.c
+++ b/misc-utils/blkid.c
@@ -45,6 +45,8 @@ extern int optind;
const char *progname = "blkid";
+int raw_chars;
+
static void print_version(FILE *out)
{
fprintf(out, "%s from %s (libblkid %s, %s)\n",
@@ -66,6 +68,7 @@ static void usage(int error)
" %1$s -i [-s <tag>] [-o <format>] <dev> ...\n\n"
"Options:\n"
" -c <file> cache file (default: /etc/blkid.tab, /dev/null = none)\n"
+ " -d don't encode non-printing characters\n"
" -h print this usage message and exit\n"
" -g garbage collect the blkid cache\n"
" -o <format> output format; can be one of:\n"
@@ -104,13 +107,15 @@ static void safe_print(const char *cp, int len)
while (len--) {
ch = *cp++;
- if (ch > 128) {
- fputs("M-", stdout);
- ch -= 128;
- }
- if ((ch < 32) || (ch == 0x7f)) {
- fputc('^', stdout);
- ch ^= 0x40; /* ^@, ^A, ^B; ^? for DEL */
+ if (!raw_chars) {
+ if (ch > 128) {
+ fputs("M-", stdout);
+ ch -= 128;
+ }
+ if ((ch < 32) || (ch == 0x7f)) {
+ fputc('^', stdout);
+ ch ^= 0x40; /* ^@, ^A, ^B; ^? for DEL */
+ }
}
fputc(ch, stdout);
}
@@ -685,7 +690,7 @@ int main(int argc, char **argv)
show[0] = NULL;
- while ((c = getopt (argc, argv, "c:f:ghilL:n:o:O:ps:S:t:u:U:w:v")) != EOF)
+ while ((c = getopt (argc, argv, "c:df:ghilL:n:o:O:ps:S:t:u:U:w:v")) != EOF)
switch (c) {
case 'c':
if (optarg && !*optarg)
@@ -695,6 +700,9 @@ int main(int argc, char **argv)
if (!write)
write = read;
break;
+ case 'd':
+ raw_chars = 1;
+ break;
case 'L':
eval++;
search_value = strdup(optarg);