mirror of
git://sourceware.org/git/lvm2.git
synced 2024-10-28 11:55:55 +03:00
more dm_get_registered_device() code
This commit is contained in:
parent
4396ee160a
commit
088e6e29da
@ -95,21 +95,14 @@ static int parse_argv(int argc, char **argv,
|
|||||||
int main(int argc, char **argv)
|
int main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
int list = 0, next = 0, ret, reg = default_reg;
|
int list = 0, next = 0, ret, reg = default_reg;
|
||||||
char *device = NULL, *device_arg = NULL,
|
char *device = NULL, *dso_name = default_dso_name, *dso_name_arg = NULL;
|
||||||
*dso_name = default_dso_name, *dso_name_arg = NULL;
|
|
||||||
|
|
||||||
if (!parse_argv(argc, argv, &dso_name_arg, &device_arg, ®, &list))
|
if (!parse_argv(argc, argv, &dso_name_arg, &device, ®, &list))
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
|
|
||||||
if (dso_name_arg)
|
|
||||||
dso_name = dso_name_arg;
|
|
||||||
else
|
|
||||||
dso_name_arg = dso_name;
|
|
||||||
|
|
||||||
if (device_arg)
|
|
||||||
device = device_arg;
|
|
||||||
|
|
||||||
if (list) {
|
if (list) {
|
||||||
|
dso_name = dso_name_arg;
|
||||||
|
|
||||||
do {
|
do {
|
||||||
/* FIXME: dso_name and/or device name given. */
|
/* FIXME: dso_name and/or device name given. */
|
||||||
if (!(ret= dm_get_registered_device(&dso_name,
|
if (!(ret= dm_get_registered_device(&dso_name,
|
||||||
@ -118,19 +111,6 @@ int main(int argc, char **argv)
|
|||||||
printf("%s %s 0x%x\n",
|
printf("%s %s 0x%x\n",
|
||||||
dso_name, device, events);
|
dso_name, device, events);
|
||||||
|
|
||||||
if (!dso_name_arg) {
|
|
||||||
free(dso_name);
|
|
||||||
dso_name = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!device_arg) {
|
|
||||||
free(device);
|
|
||||||
device = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (dso_name_arg && device_arg)
|
|
||||||
break;
|
|
||||||
|
|
||||||
next = 1;
|
next = 1;
|
||||||
}
|
}
|
||||||
} while (!ret);
|
} while (!ret);
|
||||||
@ -138,6 +118,9 @@ int main(int argc, char **argv)
|
|||||||
exit(EXIT_SUCCESS);
|
exit(EXIT_SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (dso_name_arg)
|
||||||
|
dso_name = dso_name_arg;
|
||||||
|
|
||||||
if ((ret = reg ? dm_register_for_event(dso_name, device, events) :
|
if ((ret = reg ? dm_register_for_event(dso_name, device, events) :
|
||||||
dm_unregister_for_event(dso_name, device, events))) {
|
dm_unregister_for_event(dso_name, device, events))) {
|
||||||
fprintf(stderr, "Failed to %sregister %s: %s\n",
|
fprintf(stderr, "Failed to %sregister %s: %s\n",
|
||||||
|
@ -214,7 +214,6 @@ static int parse_message(struct message_data *message_data)
|
|||||||
|
|
||||||
log_print("%s: here\n", __func__);
|
log_print("%s: here\n", __func__);
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
memset(message_data, 0, sizeof(*message_data));
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Retrieve application identifier, mapped device
|
* Retrieve application identifier, mapped device
|
||||||
@ -770,6 +769,7 @@ static int get_registered_device(struct message_data *message_data, int next)
|
|||||||
list_iterate_items(thread, &thread_registry) {
|
list_iterate_items(thread, &thread_registry) {
|
||||||
dev = dso = 0;
|
dev = dso = 0;
|
||||||
|
|
||||||
|
log_print("%s: working %s %s %u\n", __func__, thread->dso_data->dso_name, thread->device_path, thread->events);
|
||||||
/* If DSO name equals. */
|
/* If DSO name equals. */
|
||||||
if (message_data->dso_name &&
|
if (message_data->dso_name &&
|
||||||
!strcmp(message_data->dso_name,
|
!strcmp(message_data->dso_name,
|
||||||
@ -784,10 +784,19 @@ static int get_registered_device(struct message_data *message_data, int next)
|
|||||||
|
|
||||||
/* We've got both DSO name and device patch or either. */
|
/* We've got both DSO name and device patch or either. */
|
||||||
/* FIXME: wrong logic! */
|
/* FIXME: wrong logic! */
|
||||||
if ((dso && dev) || dso || dev) {
|
if (message_data->dso_name && message_data->device_path &&
|
||||||
|
dso && dev)
|
||||||
hit = 1;
|
hit = 1;
|
||||||
|
else if (message_data->dso_name && dso)
|
||||||
|
hit = 1;
|
||||||
|
else if (message_data->device_path &&
|
||||||
|
dev)
|
||||||
|
hit = 1;
|
||||||
|
|
||||||
|
if (hit)
|
||||||
|
{log_print("%s: HIT %s %s %u\n", __func__, thread->dso_data->dso_name, thread->device_path, thread->events);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
Loading…
Reference in New Issue
Block a user