blkid: add -d option to print non-printable chars
Reported-by: laborer2008 laborer <laborer2008@gmail.com> Signed-off-by: Karel Zak <kzak@redhat.com>
This commit is contained in:
parent
741a5b1085
commit
36a74e1b45
|
@ -16,7 +16,7 @@ blkid \- locate/print block device attributes
|
|||
.IR uuid
|
||||
|
||||
.B blkid
|
||||
.RB [ \-ghlv ]
|
||||
.RB [ \-dghlv ]
|
||||
.RB [ \-c
|
||||
.IR file ]
|
||||
.RB [ \-w
|
||||
|
@ -84,6 +84,11 @@ If you want to start with a clean cache (i.e. don't report devices previously
|
|||
scanned but not necessarily available at this time), specify
|
||||
.IR /dev/null .
|
||||
.TP
|
||||
.B \-d
|
||||
Don't encode non-printing characters. The non-printing characters are encoded
|
||||
by ^ and M- notation by default. Note that \fB-o udev\fR output format uses
|
||||
a diffrent encoding and this encoding cannot be disabled.
|
||||
.TP
|
||||
.B \-g
|
||||
Perform a garbage collection pass on the blkid cache to remove
|
||||
devices which no longer exist.
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue