Signed-off-by: Karel Zak <kzak@xxxxxxxxxx> --- mount/Makefile.am | 8 ++-- mount/fsprobe.h | 12 +++++ mount/fsprobe_blkid.c | 111 ++++++++++++++++++++++++++++++++++++++++++++ mount/fstab.c | 2 +- mount/mount.c | 2 +- mount/mount_blkid.c | 111 -------------------------------------------- mount/mount_blkid.h | 12 ----- mount/mount_guess_fstype.c | 2 +- mount/swapon.c | 2 +- 9 files changed, 131 insertions(+), 131 deletions(-) diff --git a/mount/Makefile.am b/mount/Makefile.am index 95db3dd..930a0bf 100644 --- a/mount/Makefile.am +++ b/mount/Makefile.am @@ -7,13 +7,13 @@ sbin_PROGRAMS = losetup swapon man_MANS = fstab.5 mount.8 swapoff.8 swapon.8 umount.8 losetup.8 MNTHDRS = fstab.h linux_fs.h mount_mntent.h mount_constants.h my_dev_t.h \ - mount_paths.h get_label_uuid.h lomount.h mount_blkid.h \ + mount_paths.h get_label_uuid.h lomount.h fsprobe.h \ mount_guess_fstype.h realpath.h xmalloc.h \ getusername.h loop.h mount_by_label.h mount_guess_rootdev.h \ sundries.h mount_SOURCES = mount.c fstab.c sundries.c xmalloc.c realpath.c mount_mntent.c \ - get_label_uuid.c mount_by_label.c mount_blkid.c mount_guess_fstype.c \ + get_label_uuid.c mount_by_label.c fsprobe_blkid.c mount_guess_fstype.c \ getusername.c \ lomount.c \ $(MNTHDRS) @@ -22,7 +22,7 @@ mount_LDADD = $(top_srcdir)/lib/libenv.a $(top_srcdir)/lib/libsetproctitle.a mount_CFLAGS = $(SUID_CFLAGS) umount_SOURCES = umount.c fstab.c sundries.c xmalloc.c realpath.c mount_mntent.c \ - getusername.c get_label_uuid.c mount_by_label.c mount_blkid.c \ + getusername.c get_label_uuid.c mount_by_label.c fsprobe_blkid.c \ lomount.c \ $(MNTHDRS) @@ -30,7 +30,7 @@ umount_LDADD = $(top_srcdir)/lib/libenv.a umount_CFLAGS = $(SUID_CFLAGS) swapon_SOURCES = swapon.c xmalloc.c \ - get_label_uuid.c mount_by_label.c mount_blkid.c \ + get_label_uuid.c mount_by_label.c fsprobe_blkid.c \ swap_constants.h realpath.c losetup_SOURCES = lomount.c loop.h lomount.h diff --git a/mount/fsprobe.h b/mount/fsprobe.h new file mode 100644 index 0000000..c96ff8c --- /dev/null +++ b/mount/fsprobe.h @@ -0,0 +1,12 @@ +#ifdef HAVE_LIBBLKID +#include <blkid/blkid.h> +extern blkid_cache blkid; +#endif + +extern void mount_blkid_get_cache(void); +extern void mount_blkid_put_cache(void); +extern const char *mount_get_devname_by_uuid(const char *uuid); +extern const char *mount_get_devname_by_label(const char *label); +extern const char *mount_get_volume_label_by_spec(const char *spec); +extern const char *mount_get_devname(const char *spec); +extern const char *mount_get_devname_for_mounting(const char *spec); diff --git a/mount/fsprobe_blkid.c b/mount/fsprobe_blkid.c new file mode 100644 index 0000000..0616945 --- /dev/null +++ b/mount/fsprobe_blkid.c @@ -0,0 +1,111 @@ +#include <stdio.h> +#include "fsprobe.h" + +#ifdef HAVE_LIBBLKID + +blkid_cache blkid; + +void +mount_blkid_get_cache(void) { + blkid_get_cache(&blkid, NULL); +} + +void +mount_blkid_put_cache(void) { + blkid_put_cache(blkid); +} + +const char * +mount_get_volume_label_by_spec(const char *spec) { + return blkid_get_tag_value(blkid, "LABEL", spec); +} + +const char * +mount_get_devname(const char *spec) { + return blkid_get_devname(blkid, spec, 0); +} + +const char * +mount_get_devname_by_uuid(const char *uuid) { + return blkid_get_devname(blkid, "UUID", uuid); +} + +const char * +mount_get_devname_by_label(const char *label) { + return blkid_get_devname(blkid, "LABEL", label); +} + +/* Also when no UUID= or LABEL= occur? No verbose? No warnings? */ +const char * +mount_get_devname_for_mounting(const char *spec) { + return blkid_get_devname(blkid, spec, 0); +} + +#else +#include <string.h> +#include "sundries.h" +#include "mount_by_label.h" +#include "nls.h" + +void +mount_blkid_get_cache(void) { +} + +void +mount_blkid_put_cache(void) { +} + +const char * +mount_get_volume_label_by_spec(const char *spec) { + return xstrdup(get_volume_label_by_spec(spec)); +} + +const char * +mount_get_devname(const char *spec) { + if (!strncmp(spec, "UUID=", 5)) + return get_spec_by_uuid(spec+5); + if (!strncmp(spec, "LABEL=", 6)) + return get_spec_by_volume_label(spec+6); + return spec; +} + +const char * +mount_get_devname_by_uuid(const char *uuid) { + return get_spec_by_uuid(uuid); +} + +extern char *progname; + +const char * +mount_get_devname_by_label(const char *volumelabel) { + const char *spec, *spec2; + + spec = get_spec_by_volume_label(volumelabel); + spec2 = second_occurrence_of_vol_label(volumelabel); + if (spec2) + die (EX_FAIL, + _("%s: error: the label %s occurs on both %s and %s\n"), + progname, volumelabel, spec, spec2); + return spec; +} + +const char * +mount_get_devname_for_mounting(const char *spec) { + const char *nspec; + + if (!strncmp(spec, "UUID=", 5)) { + nspec = mount_get_devname_by_uuid(spec+5); + if (nspec && verbose > 1) + printf(_("mount: going to mount %s by UUID\n"), spec); + } else if (!strncmp(spec, "LABEL=", 6)) { + nspec = mount_get_devname_by_label(spec+6); + if (nspec && verbose > 1) + printf(_("mount: going to mount %s by label\n"), spec); + } else + nspec = spec; + + return nspec; +} + + +#endif diff --git a/mount/fstab.c b/mount/fstab.c index 72c46f3..5267f62 100644 --- a/mount/fstab.c +++ b/mount/fstab.c @@ -15,7 +15,7 @@ #include "fstab.h" #include "sundries.h" #include "xmalloc.h" -#include "mount_blkid.h" +#include "fsprobe.h" #include "mount_paths.h" #include "nls.h" diff --git a/mount/mount.c b/mount/mount.c index 5058a7e..dfa44dc 100644 --- a/mount/mount.c +++ b/mount/mount.c @@ -29,7 +29,7 @@ #include <selinux/context.h> #endif -#include "mount_blkid.h" +#include "fsprobe.h" #include "mount_constants.h" #include "sundries.h" #include "xmalloc.h" diff --git a/mount/mount_blkid.c b/mount/mount_blkid.c deleted file mode 100644 index 8fa30a1..0000000 --- a/mount/mount_blkid.c +++ /dev/null @@ -1,111 +0,0 @@ -#include <stdio.h> -#include "mount_blkid.h" - -#ifdef HAVE_LIBBLKID - -blkid_cache blkid; - -void -mount_blkid_get_cache(void) { - blkid_get_cache(&blkid, NULL); -} - -void -mount_blkid_put_cache(void) { - blkid_put_cache(blkid); -} - -const char * -mount_get_volume_label_by_spec(const char *spec) { - return blkid_get_tag_value(blkid, "LABEL", spec); -} - -const char * -mount_get_devname(const char *spec) { - return blkid_get_devname(blkid, spec, 0); -} - -const char * -mount_get_devname_by_uuid(const char *uuid) { - return blkid_get_devname(blkid, "UUID", uuid); -} - -const char * -mount_get_devname_by_label(const char *label) { - return blkid_get_devname(blkid, "LABEL", label); -} - -/* Also when no UUID= or LABEL= occur? No verbose? No warnings? */ -const char * -mount_get_devname_for_mounting(const char *spec) { - return blkid_get_devname(blkid, spec, 0); -} - -#else -#include <string.h> -#include "sundries.h" -#include "mount_by_label.h" -#include "nls.h" - -void -mount_blkid_get_cache(void) { -} - -void -mount_blkid_put_cache(void) { -} - -const char * -mount_get_volume_label_by_spec(const char *spec) { - return xstrdup(get_volume_label_by_spec(spec)); -} - -const char * -mount_get_devname(const char *spec) { - if (!strncmp(spec, "UUID=", 5)) - return get_spec_by_uuid(spec+5); - if (!strncmp(spec, "LABEL=", 6)) - return get_spec_by_volume_label(spec+6); - return spec; -} - -const char * -mount_get_devname_by_uuid(const char *uuid) { - return get_spec_by_uuid(uuid); -} - -extern char *progname; - -const char * -mount_get_devname_by_label(const char *volumelabel) { - const char *spec, *spec2; - - spec = get_spec_by_volume_label(volumelabel); - spec2 = second_occurrence_of_vol_label(volumelabel); - if (spec2) - die (EX_FAIL, - _("%s: error: the label %s occurs on both %s and %s\n"), - progname, volumelabel, spec, spec2); - return spec; -} - -const char * -mount_get_devname_for_mounting(const char *spec) { - const char *nspec; - - if (!strncmp(spec, "UUID=", 5)) { - nspec = mount_get_devname_by_uuid(spec+5); - if (nspec && verbose > 1) - printf(_("mount: going to mount %s by UUID\n"), spec); - } else if (!strncmp(spec, "LABEL=", 6)) { - nspec = mount_get_devname_by_label(spec+6); - if (nspec && verbose > 1) - printf(_("mount: going to mount %s by label\n"), spec); - } else - nspec = spec; - - return nspec; -} - - -#endif diff --git a/mount/mount_blkid.h b/mount/mount_blkid.h deleted file mode 100644 index c96ff8c..0000000 --- a/mount/mount_blkid.h +++ /dev/null @@ -1,12 +0,0 @@ -#ifdef HAVE_LIBBLKID -#include <blkid/blkid.h> -extern blkid_cache blkid; -#endif - -extern void mount_blkid_get_cache(void); -extern void mount_blkid_put_cache(void); -extern const char *mount_get_devname_by_uuid(const char *uuid); -extern const char *mount_get_devname_by_label(const char *label); -extern const char *mount_get_volume_label_by_spec(const char *spec); -extern const char *mount_get_devname(const char *spec); -extern const char *mount_get_devname_for_mounting(const char *spec); diff --git a/mount/mount_guess_fstype.c b/mount/mount_guess_fstype.c index f1637f1..51d8750 100644 --- a/mount/mount_guess_fstype.c +++ b/mount/mount_guess_fstype.c @@ -38,7 +38,7 @@ #include <sys/stat.h> #include <sys/types.h> #include "linux_fs.h" -#include "mount_blkid.h" +#include "fsprobe.h" #include "mount_guess_fstype.h" #include "sundries.h" /* for xstrdup */ #include "nls.h" diff --git a/mount/swapon.c b/mount/swapon.c index b6bcd75..af4ba96 100644 --- a/mount/swapon.c +++ b/mount/swapon.c @@ -15,7 +15,7 @@ #include "swap_constants.h" #include "swapargs.h" #include "nls.h" -#include "mount_blkid.h" +#include "fsprobe.h" #include "mount_by_label.h" #include "realpath.h" -- 1.5.0.6 - To unsubscribe from this list: send the line "unsubscribe util-linux-ng" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html