1
0
mirror of git://sourceware.org/git/lvm2.git synced 2024-12-21 13:34:40 +03:00

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.
This commit is contained in:
Zdenek Kabelac 2015-07-01 09:54:57 +02:00
parent a69ded43b0
commit 04ae5007e3

View File

@ -301,6 +301,7 @@ struct dm_tree {
int no_flush; /* 1 sets noflush (mirrors/multipath) */ int no_flush; /* 1 sets noflush (mirrors/multipath) */
int retry_remove; /* 1 retries remove if not successful */ int retry_remove; /* 1 retries remove if not successful */
uint32_t cookie; 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 */ 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 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) void dm_tree_node_set_udev_flags(struct dm_tree_node *dnode, uint16_t udev_flags)
{ {