1
0
mirror of git://sourceware.org/git/lvm2.git synced 2024-12-25 01:34:38 +03:00

more dm_get_registered_device() code

This commit is contained in:
Heinz Mauelshagen 2005-05-03 13:50:42 +00:00
parent dbf2888d43
commit 3e940f80c7
2 changed files with 19 additions and 27 deletions

View File

@ -95,21 +95,14 @@ static int parse_argv(int argc, char **argv,
int main(int argc, char **argv)
{
int list = 0, next = 0, ret, reg = default_reg;
char *device = NULL, *device_arg = NULL,
*dso_name = default_dso_name, *dso_name_arg = NULL;
char *device = NULL, *dso_name = default_dso_name, *dso_name_arg = NULL;
if (!parse_argv(argc, argv, &dso_name_arg, &device_arg, &reg, &list))
if (!parse_argv(argc, argv, &dso_name_arg, &device, &reg, &list))
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) {
dso_name = dso_name_arg;
do {
/* FIXME: dso_name and/or device name given. */
if (!(ret= dm_get_registered_device(&dso_name,
@ -118,19 +111,6 @@ int main(int argc, char **argv)
printf("%s %s 0x%x\n",
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;
}
} while (!ret);
@ -138,6 +118,9 @@ int main(int argc, char **argv)
exit(EXIT_SUCCESS);
}
if (dso_name_arg)
dso_name = dso_name_arg;
if ((ret = reg ? dm_register_for_event(dso_name, device, events) :
dm_unregister_for_event(dso_name, device, events))) {
fprintf(stderr, "Failed to %sregister %s: %s\n",

View File

@ -214,7 +214,6 @@ static int parse_message(struct message_data *message_data)
log_print("%s: here\n", __func__);
fflush(stdout);
memset(message_data, 0, sizeof(*message_data));
/*
* 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) {
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 (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. */
/* FIXME: wrong logic! */
if ((dso && dev) || dso || dev) {
if (message_data->dso_name && message_data->device_path &&
dso && dev)
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;
}
}
}
/*