Where is the implementation of the function dm_task_create
in cryptsetup (and other dm_task_ related functions)? Grepping for this function in the source for cryptsetup I come up with nothing. I see it is used in lib/libdevmapper.c and that it has a function prototype in libdevmapper.h. However where is the implementation? As a side note, cryptsetup compiles fine and executes.
Just to check, I grepped through the kernel source as well but it doesn't appear to be implemented in the kernel either.
From the following link http://www.saout.de/pipermail/dm-crypt/2009-December/000464.html it appears that at least in the past it was implemented in libdevmapper.c.
It's implemented in libdm-common.c
, which is part of libdm
(lib device-mapper). It is not implemented as part of cryptsetup
itself.
This code is maintained alongside LVM2, as documented on this page:
The userspace code (dmsetup and libdevmapper) is now maintained alongside the LVM2 source available from http://sources.redhat.com/lvm2/. To build / install it without LVM2 use 'make device-mapper' / 'make device-mapper_install'.
Here's the implementation:
struct dm_task *dm_task_create(int type)
{
struct dm_task *dmt = dm_zalloc(sizeof(*dmt));
if (!dmt) {
log_error("dm_task_create: malloc(%" PRIsize_t ") failed",
sizeof(*dmt));
return NULL;
}
if (!dm_check_version()) {
dm_free(dmt);
return_NULL;
}
dmt->type = type;
dmt->minor = -1;
dmt->major = -1;
dmt->allow_default_major_fallback = 1;
dmt->uid = DM_DEVICE_UID;
dmt->gid = DM_DEVICE_GID;
dmt->mode = DM_DEVICE_MODE;
dmt->no_open_count = 0;
dmt->read_ahead = DM_READ_AHEAD_AUTO;
dmt->read_ahead_flags = 0;
dmt->event_nr = 0;
dmt->cookie_set = 0;
dmt->query_inactive_table = 0;
dmt->new_uuid = 0;
dmt->secure_data = 0;
return dmt;
}