summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZdenek Kabelac <zkabelac@redhat.com>2015-07-01 09:54:57 +0200
committerZdenek Kabelac <zkabelac@redhat.com>2015-07-01 13:41:40 +0200
commit04ae5007e3952c3d071cfcd03e03db87332b9027 (patch)
tree6dc31a9991edd063397f190fb5763376d688bf31
parenta69ded43b0364812c58eb9479c2dae4dd2febc8c (diff)
downloadlvm2-04ae5007e3952c3d071cfcd03e03db87332b9027.tar.gz
libdm: add helper function to print _node_name
_node_name() prepares into dm_tree internal buffer device name and it (major:minor) for easy usage for debug messages. To avoid any allocation a small buffer in struct dm_tree is preallocated to store this message.
-rw-r--r--libdm/libdm-deptree.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/libdm/libdm-deptree.c b/libdm/libdm-deptree.c
index 8428376ce..cb43afed1 100644
--- a/libdm/libdm-deptree.c
+++ b/libdm/libdm-deptree.c
@@ -301,6 +301,7 @@ struct dm_tree {
int no_flush; /* 1 sets noflush (mirrors/multipath) */
int retry_remove; /* 1 retries remove if not successful */
uint32_t cookie;
+ char buf[DM_NAME_LEN + 32]; /* print buffer for device_name (major:minor) */
const char **optional_uuid_suffixes; /* uuid suffixes ignored when matching */
};
@@ -595,6 +596,19 @@ static struct dm_tree_node *_find_dm_tree_node_by_uuid(struct dm_tree *dtree,
return NULL;
}
+/* Return node's device_name (major:minor) for debug messages */
+static const char *_node_name(struct dm_tree_node *dnode)
+{
+ if (dm_snprintf(dnode->dtree->buf, sizeof(dnode->dtree->buf),
+ "%s (%" PRIu32 ":%" PRIu32 ")",
+ dnode->name, dnode->info.major, dnode->info.minor) < 0) {
+ stack;
+ return dnode->name;
+ }
+
+ return dnode->dtree->buf;
+}
+
void dm_tree_node_set_udev_flags(struct dm_tree_node *dnode, uint16_t udev_flags)
{