blkid: add pretty output, document -L incompatibility with e2fsprogs

... sad story, I have temporary disabled pretty-output code
in very early version of blkid.c in u-l-ng. (It was also in
time when pretty-output was very new feature in e2fsprogs.)

Unfortunately, the -L option (shortcut to "-o list") in u-l-ng version
was reused for for any other functionality few months later.... this
stupid thing was released in u-l-ng 2.15 and 2.16 without any negative
feedback from users.

It means the blkid from u-l-ng is not backwardly compatible with
the original version from e2fsprogs. The -L option has a different
meaning there.

I'm sorry about this bug...

This patch:

  * enable pretty-output (-o line)
  * add a note about incompatibility between u-l-ng and e2fsprogs
    to blkid.8 man page

Signed-off-by: Karel Zak <kzak@redhat.com>
This commit is contained in:
Karel Zak 2009-10-14 02:17:27 +02:00
parent acf6ab6f67
commit 2d71a92941
3 changed files with 27 additions and 15 deletions

View File

@ -35,6 +35,7 @@ endif
if BUILD_LIBBLKID
sbin_PROGRAMS += blkid findfs wipefs
dist_man_MANS += blkid.8 findfs.8 wipefs.8
blkid_SOURCES = blkid.c $(top_srcdir)/lib/ismounted.c
blkid_LDADD = $(ul_libblkid_la)
blkid_CFLAGS = -I$(ul_libblkid_srcdir)
findfs_LDADD = $(ul_libblkid_la)

View File

@ -96,7 +96,13 @@ Look up one device that uses the label (same as: -l -o device -t
LABEL=<label>). This look up method is able to reliable use /dev/disk/by-label
udev symlinks (depends on setting in /etc/blkid.conf). Avoid to use the
symlinks directly. It is not reliable to use the symlinks without verification.
The \fB-L\fR option is portable and works on systems with and without udev.
The \fB-L\fR option works on systems with and without udev.
Unfortunately, the original
.B blkid(8)
from e2fsprogs use the \fB-L\fR option as a
synonym to the \fB-o list\fR option. For better portability use "-l -o device
-t LABEL=<label>" and "-o list" in your scripts rather than -L option.
.TP
.B \-u " list "
Restrict probing functions to defined (comma separated) list of "usage" types.
@ -130,10 +136,12 @@ print all tags (the default)
print the value of the tags
.TP
.B list
print the devices in a user-friendly format
print the devices in a user-friendly format, this output format is unsupported
for low-level probing (\fB-p\fR)
.TP
.B device
print the device name only
print the device name only, this output format is always enabled for \fB-L\fR
and \fB-U\fR options
.TP
.B udev
vol_id compatible mode; usable in udev rules

View File

@ -40,6 +40,8 @@ extern int optind;
#include <blkid.h>
#include "ismounted.h"
const char *progname = "blkid";
static void print_version(FILE *out)
@ -186,16 +188,12 @@ static void pretty_print_line(const char *device, const char *fs_type,
static void pretty_print_dev(blkid_dev dev)
{
fprintf(stderr, "pretty print not implemented yet\n");
#ifdef NOT_IMPLEMENTED
blkid_tag_iterate iter;
const char *type, *value, *devname;
const char *uuid = "", *fs_type = "", *label = "";
char *cp;
int len, mount_flags;
char mtpt[80];
errcode_t retval;
int retval;
if (dev == NULL) {
pretty_print_line("device", "fs_type", "label",
@ -224,20 +222,18 @@ static void pretty_print_dev(blkid_dev dev)
/* Get the mount point */
mtpt[0] = 0;
retval = ext2fs_check_mount_point(devname, &mount_flags,
mtpt, sizeof(mtpt));
retval = check_mount_point(devname, &mount_flags, mtpt, sizeof(mtpt));
if (retval == 0) {
if (mount_flags & EXT2_MF_MOUNTED) {
if (mount_flags & MF_MOUNTED) {
if (!mtpt[0])
strcpy(mtpt, "(mounted, mtpt unknown)");
} else if (mount_flags & EXT2_MF_BUSY)
} else if (mount_flags & MF_BUSY)
strcpy(mtpt, "(in use)");
else
strcpy(mtpt, "(not mounted)");
}
pretty_print_line(devname, fs_type, label, mtpt, uuid);
#endif
}
static void print_udev_format(const char *name, const char *value, size_t sz)
@ -544,8 +540,14 @@ int main(int argc, char **argv)
}
err = 2;
if (output_format & OUTPUT_PRETTY_LIST)
if (eval == 0 && output_format & OUTPUT_PRETTY_LIST) {
if (lowprobe) {
fprintf(stderr, "The low-level probing mode does not "
"support 'list' output format\n");
exit(4);
}
pretty_print_dev(NULL);
}
if (lowprobe) {
/*
@ -554,7 +556,8 @@ int main(int argc, char **argv)
blkid_probe pr;
if (!numdev) {
fprintf(stderr, "The low-probe option requires a device\n");
fprintf(stderr, "The low-level probing mode "
"requires a device\n");
exit(4);
}
pr = blkid_new_probe();