device-mapper has the habit of freeing up all internal structures
after dm_task_destroy. So we shouldn't try to access any of these
later on.
References: bnc#672857
Signed-off-by: Hannes Reinecke <hare@suse.de>
{
struct dm_task *dmt;
struct dm_info info;
+ int event = -1;
if (!(dmt = dm_task_create(DM_DEVICE_INFO)))
- return 0;
+ return -1;
if (!dm_task_set_name(dmt, name))
goto out;
if (!dm_task_run(dmt))
goto out;
- if (!dm_task_get_info(dmt, &info)) {
- info.event_nr = 0;
+ if (!dm_task_get_info(dmt, &info))
goto out;
- }
- if (!info.exists) {
- info.event_nr = 0;
- goto out;
- }
+ if (info.exists)
+ event = info.event_nr;
out:
dm_task_destroy(dmt);
- return info.event_nr;
+ return event;
}
char *