From f4f425b20bfec2bfa11a2b1df99b246541b3aff9 Mon Sep 17 00:00:00 2001 From: Theodore Ts'o Date: Sun, 19 Mar 2006 15:26:26 -0500 Subject: [PATCH] Prevent error messages to stderr caused by libblkid calling libdevmapper Make the libdevmapper fail quietly if blkid is called without root privileges or the kernel does not include device mapper support. (What is the device mapper _library_ doing writing to stderr, anyway?) Signed-off-by: "Theodore Ts'o" --- lib/blkid/ChangeLog | 8 ++++++++ lib/blkid/devname.c | 10 ++++++++++ 2 files changed, 18 insertions(+) diff --git a/lib/blkid/ChangeLog b/lib/blkid/ChangeLog index e0dac82..d46df09 100644 --- a/lib/blkid/ChangeLog +++ b/lib/blkid/ChangeLog @@ -1,3 +1,11 @@ +2006-03-19 Theodore Ts'o + + * devname.c (dm_probe_all, dm_device_is_leaf): Make the + libdevmapper fail quietly if blkid is called without root + privileges or the kernel does not include device mapper + support. (What is the device mapper _library_ doing + writing to stderr, anyway?) + 2006-03-12 Theodore Ts'o * probe.c (blkid_verify): Fix the bid_time sanity checking logic, diff --git a/lib/blkid/devname.c b/lib/blkid/devname.c index b2ff40f..4c2c895 100644 --- a/lib/blkid/devname.c +++ b/lib/blkid/devname.c @@ -154,6 +154,12 @@ set_pri: } #ifdef HAVE_DEVMAPPER +static void dm_quiet_log(int level, const char *file, int line, + const char *f, ...) +{ + return; +} + /* * device-mapper support */ @@ -203,9 +209,11 @@ static int dm_device_is_leaf(const dev_t dev) unsigned int next = 0; int n, ret = 1; + dm_log_init(dm_quiet_log); task = dm_task_create(DM_DEVICE_LIST); if (!task) return 1; + dm_log_init(0); dm_task_run(task); names = dm_task_get_names(task); @@ -262,9 +270,11 @@ static void dm_probe_all(blkid_cache cache, int only_if_new) unsigned int next = 0; int n; + dm_log_init(dm_quiet_log); task = dm_task_create(DM_DEVICE_LIST); if (!task) return; + dm_log_init(0); dm_task_run(task); names = dm_task_get_names(task); -- 1.8.3.1