mirror of
git://sourceware.org/git/lvm2.git
synced 2025-03-10 16:58:47 +03:00
Remove support for the original dm ioctl interface version 1.
Leave the basic support for multiple versions in case we have a new version in future.
This commit is contained in:
parent
cf9927697b
commit
2061c0ec24
@ -1,5 +1,6 @@
|
||||
Version 1.02.66 -
|
||||
===============================
|
||||
Remove support for the original version 1 dm ioctls.
|
||||
Add missing check for allocation failure _create_dir_recursive().
|
||||
Add support for systemd file descriptor handover in dmeventd.
|
||||
Add support for new oom killer adjustment interface (oom_score_adj).
|
||||
|
7
configure
vendored
7
configure
vendored
@ -8917,6 +8917,13 @@ else
|
||||
fi
|
||||
|
||||
|
||||
if test x$DM_COMPAT = xyes; then
|
||||
as_fn_error $? "--enable-compat is not currently supported.
|
||||
Since device-mapper version 1.02.66, only one version (4) of the device-mapper
|
||||
ioctl protocol is supported.
|
||||
" "$LINENO" 5
|
||||
fi
|
||||
|
||||
################################################################################
|
||||
# Check whether --enable-units-compat was given.
|
||||
if test "${enable_units_compat+set}" = set; then :
|
||||
|
@ -846,6 +846,14 @@ AC_ARG_ENABLE(compat,
|
||||
[enable support for old device-mapper versions]),
|
||||
DM_COMPAT=$enableval, DM_COMPAT=no)
|
||||
|
||||
if test x$DM_COMPAT = xyes; then
|
||||
AC_MSG_ERROR(
|
||||
[--enable-compat is not currently supported.
|
||||
Since device-mapper version 1.02.66, only one version (4) of the device-mapper
|
||||
ioctl protocol is supported.]
|
||||
)
|
||||
fi
|
||||
|
||||
################################################################################
|
||||
dnl -- Compatible units suffix mode
|
||||
AC_ARG_ENABLE(units-compat,
|
||||
|
@ -1,123 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.
|
||||
* Copyright (C) 2004-2006 Red Hat, Inc. All rights reserved.
|
||||
*
|
||||
* This file is part of the device-mapper userspace tools.
|
||||
*
|
||||
* This copyrighted material is made available to anyone wishing to use,
|
||||
* modify, copy, or redistribute it subject to the terms and conditions
|
||||
* of the GNU Lesser General Public License v.2.1.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program; if not, write to the Free Software Foundation,
|
||||
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#ifndef _LINUX_LIBDM_COMPAT_H
|
||||
#define _LINUX_LIBDM_COMPAT_H
|
||||
|
||||
#include "kdev_t.h"
|
||||
#include "dm-ioctl.h"
|
||||
#include <inttypes.h>
|
||||
#include <sys/ioctl.h>
|
||||
|
||||
struct dm_task;
|
||||
struct dm_info;
|
||||
|
||||
/*
|
||||
* Old versions of structures for backwards compatibility.
|
||||
*/
|
||||
|
||||
struct dm_ioctl_v1 {
|
||||
uint32_t version[3]; /* in/out */
|
||||
uint32_t data_size; /* total size of data passed in
|
||||
* including this struct */
|
||||
|
||||
uint32_t data_start; /* offset to start of data
|
||||
* relative to start of this struct */
|
||||
|
||||
int32_t target_count; /* in/out */
|
||||
int32_t open_count; /* out */
|
||||
uint32_t flags; /* in/out */
|
||||
|
||||
__kernel_dev_t dev; /* in/out */
|
||||
|
||||
char name[DM_NAME_LEN]; /* device name */
|
||||
char uuid[DM_UUID_LEN]; /* unique identifier for
|
||||
* the block device */
|
||||
};
|
||||
|
||||
struct dm_target_spec_v1 {
|
||||
int32_t status; /* used when reading from kernel only */
|
||||
uint64_t sector_start;
|
||||
uint32_t length;
|
||||
uint32_t next;
|
||||
|
||||
char target_type[DM_MAX_TYPE_NAME];
|
||||
|
||||
};
|
||||
|
||||
struct dm_target_deps_v1 {
|
||||
uint32_t count;
|
||||
|
||||
__kernel_dev_t dev[0]; /* out */
|
||||
};
|
||||
|
||||
enum {
|
||||
/* Top level cmds */
|
||||
DM_VERSION_CMD_V1 = 0,
|
||||
DM_REMOVE_ALL_CMD_V1,
|
||||
|
||||
/* device level cmds */
|
||||
DM_DEV_CREATE_CMD_V1,
|
||||
DM_DEV_REMOVE_CMD_V1,
|
||||
DM_DEV_RELOAD_CMD_V1,
|
||||
DM_DEV_RENAME_CMD_V1,
|
||||
DM_DEV_SUSPEND_CMD_V1,
|
||||
DM_DEV_DEPS_CMD_V1,
|
||||
DM_DEV_STATUS_CMD_V1,
|
||||
|
||||
/* target level cmds */
|
||||
DM_TARGET_STATUS_CMD_V1,
|
||||
DM_TARGET_WAIT_CMD_V1,
|
||||
};
|
||||
|
||||
#define DM_VERSION_V1 _IOWR(DM_IOCTL, DM_VERSION_CMD_V1, struct dm_ioctl)
|
||||
#define DM_REMOVE_ALL_V1 _IOWR(DM_IOCTL, DM_REMOVE_ALL_CMD_V1, struct dm_ioctl)
|
||||
|
||||
#define DM_DEV_CREATE_V1 _IOWR(DM_IOCTL, DM_DEV_CREATE_CMD_V1, struct dm_ioctl)
|
||||
#define DM_DEV_REMOVE_V1 _IOWR(DM_IOCTL, DM_DEV_REMOVE_CMD_V1, struct dm_ioctl)
|
||||
#define DM_DEV_RELOAD_V1 _IOWR(DM_IOCTL, DM_DEV_RELOAD_CMD_V1, struct dm_ioctl)
|
||||
#define DM_DEV_SUSPEND_V1 _IOWR(DM_IOCTL, DM_DEV_SUSPEND_CMD_V1, struct dm_ioctl)
|
||||
#define DM_DEV_RENAME_V1 _IOWR(DM_IOCTL, DM_DEV_RENAME_CMD_V1, struct dm_ioctl)
|
||||
#define DM_DEV_DEPS_V1 _IOWR(DM_IOCTL, DM_DEV_DEPS_CMD_V1, struct dm_ioctl)
|
||||
#define DM_DEV_STATUS_V1 _IOWR(DM_IOCTL, DM_DEV_STATUS_CMD_V1, struct dm_ioctl)
|
||||
|
||||
#define DM_TARGET_STATUS_V1 _IOWR(DM_IOCTL, DM_TARGET_STATUS_CMD_V1, struct dm_ioctl)
|
||||
#define DM_TARGET_WAIT_V1 _IOWR(DM_IOCTL, DM_TARGET_WAIT_CMD_V1, struct dm_ioctl)
|
||||
|
||||
/* *INDENT-OFF* */
|
||||
static struct cmd_data _cmd_data_v1[] = {
|
||||
{ "create", DM_DEV_CREATE_V1, {1, 0, 0} },
|
||||
{ "reload", DM_DEV_RELOAD_V1, {1, 0, 0} },
|
||||
{ "remove", DM_DEV_REMOVE_V1, {1, 0, 0} },
|
||||
{ "remove_all", DM_REMOVE_ALL_V1, {1, 0, 0} },
|
||||
{ "suspend", DM_DEV_SUSPEND_V1, {1, 0, 0} },
|
||||
{ "resume", DM_DEV_SUSPEND_V1, {1, 0, 0} },
|
||||
{ "info", DM_DEV_STATUS_V1, {1, 0, 0} },
|
||||
{ "deps", DM_DEV_DEPS_V1, {1, 0, 0} },
|
||||
{ "rename", DM_DEV_RENAME_V1, {1, 0, 0} },
|
||||
{ "version", DM_VERSION_V1, {1, 0, 0} },
|
||||
{ "status", DM_TARGET_STATUS_V1, {1, 0, 0} },
|
||||
{ "table", DM_TARGET_STATUS_V1, {1, 0, 0} },
|
||||
{ "waitevent", DM_TARGET_WAIT_V1, {1, 0, 0} },
|
||||
{ "names", 0, {4, 0, 0} },
|
||||
{ "clear", 0, {4, 0, 0} },
|
||||
{ "mknodes", 0, {4, 0, 0} },
|
||||
{ "versions", 0, {4, 1, 0} },
|
||||
{ "message", 0, {4, 2, 0} },
|
||||
{ "setgeometry",0, {4, 6, 0} },
|
||||
};
|
||||
/* *INDENT-ON* */
|
||||
|
||||
#endif
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.
|
||||
* Copyright (C) 2004-2007 Red Hat, Inc. All rights reserved.
|
||||
* Copyright (C) 2004-2011 Red Hat, Inc. All rights reserved.
|
||||
*
|
||||
* This file is part of the device-mapper userspace tools.
|
||||
*
|
||||
@ -17,10 +17,6 @@
|
||||
#include "libdm-targets.h"
|
||||
#include "libdm-common.h"
|
||||
|
||||
#ifdef DM_COMPAT
|
||||
# include "libdm-compat.h"
|
||||
#endif
|
||||
|
||||
#include <fcntl.h>
|
||||
#include <dirent.h>
|
||||
#include <sys/ioctl.h>
|
||||
@ -44,8 +40,7 @@
|
||||
* in the _cmd_data arrays.
|
||||
*/
|
||||
|
||||
#if !((DM_VERSION_MAJOR == 1 && DM_VERSION_MINOR >= 0) || \
|
||||
(DM_VERSION_MAJOR == 4 && DM_VERSION_MINOR >= 0))
|
||||
#if !((DM_VERSION_MAJOR == 4 && DM_VERSION_MINOR >= 6))
|
||||
#error The version of dm-ioctl.h included is incompatible.
|
||||
#endif
|
||||
|
||||
@ -92,16 +87,7 @@ static int _version_checked = 0;
|
||||
static int _version_ok = 1;
|
||||
static unsigned _ioctl_buffer_double_factor = 0;
|
||||
|
||||
/*
|
||||
* Support both old and new major numbers to ease the transition.
|
||||
* Clumsy, but only temporary.
|
||||
*/
|
||||
#if DM_VERSION_MAJOR == 4 && defined(DM_COMPAT)
|
||||
const int _dm_compat = 1;
|
||||
#else
|
||||
const int _dm_compat = 0;
|
||||
#endif
|
||||
|
||||
|
||||
/* *INDENT-OFF* */
|
||||
static struct cmd_data _cmd_data_v4[] = {
|
||||
@ -133,7 +119,6 @@ static struct cmd_data _cmd_data_v4[] = {
|
||||
};
|
||||
/* *INDENT-ON* */
|
||||
|
||||
#define ALIGNMENT_V1 sizeof(int)
|
||||
#define ALIGNMENT 8
|
||||
|
||||
/* FIXME Rejig library to record & use errno instead */
|
||||
@ -470,409 +455,6 @@ void dm_task_destroy(struct dm_task *dmt)
|
||||
dm_free(dmt);
|
||||
}
|
||||
|
||||
/*
|
||||
* Protocol Version 1 compatibility functions.
|
||||
*/
|
||||
|
||||
#ifdef DM_COMPAT
|
||||
|
||||
static void _dm_zfree_dmi_v1(struct dm_ioctl_v1 *dmi)
|
||||
{
|
||||
if (dmi) {
|
||||
memset(dmi, 0, dmi->data_size);
|
||||
dm_free(dmi);
|
||||
}
|
||||
}
|
||||
|
||||
static int _dm_task_get_driver_version_v1(struct dm_task *dmt, char *version,
|
||||
size_t size)
|
||||
{
|
||||
unsigned int *v;
|
||||
|
||||
if (!dmt->dmi.v1) {
|
||||
version[0] = '\0';
|
||||
return 0;
|
||||
}
|
||||
|
||||
v = dmt->dmi.v1->version;
|
||||
snprintf(version, size, "%u.%u.%u", v[0], v[1], v[2]);
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* Unmarshall the target info returned from a status call */
|
||||
static int _unmarshal_status_v1(struct dm_task *dmt, struct dm_ioctl_v1 *dmi)
|
||||
{
|
||||
char *outbuf = (char *) dmi + dmi->data_start;
|
||||
char *outptr = outbuf;
|
||||
int32_t i;
|
||||
struct dm_target_spec_v1 *spec;
|
||||
|
||||
for (i = 0; i < dmi->target_count; i++) {
|
||||
spec = (struct dm_target_spec_v1 *) outptr;
|
||||
|
||||
if (!dm_task_add_target(dmt, spec->sector_start,
|
||||
(uint64_t) spec->length,
|
||||
spec->target_type,
|
||||
outptr + sizeof(*spec))) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
outptr = outbuf + spec->next;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int _dm_format_dev_v1(char *buf, int bufsize, uint32_t dev_major,
|
||||
uint32_t dev_minor)
|
||||
{
|
||||
int r;
|
||||
|
||||
if (bufsize < 8)
|
||||
return 0;
|
||||
|
||||
r = snprintf(buf, bufsize, "%03x:%03x", dev_major, dev_minor);
|
||||
if (r < 0 || r > bufsize - 1)
|
||||
return 0;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int _dm_task_get_info_v1(struct dm_task *dmt, struct dm_info *info)
|
||||
{
|
||||
if (!dmt->dmi.v1)
|
||||
return 0;
|
||||
|
||||
memset(info, 0, sizeof(*info));
|
||||
|
||||
info->exists = dmt->dmi.v1->flags & DM_EXISTS_FLAG ? 1 : 0;
|
||||
if (!info->exists)
|
||||
return 1;
|
||||
|
||||
info->suspended = dmt->dmi.v1->flags & DM_SUSPEND_FLAG ? 1 : 0;
|
||||
info->read_only = dmt->dmi.v1->flags & DM_READONLY_FLAG ? 1 : 0;
|
||||
info->target_count = dmt->dmi.v1->target_count;
|
||||
info->open_count = dmt->dmi.v1->open_count;
|
||||
info->event_nr = 0;
|
||||
info->major = MAJOR(dmt->dmi.v1->dev);
|
||||
info->minor = MINOR(dmt->dmi.v1->dev);
|
||||
info->live_table = 1;
|
||||
info->inactive_table = 0;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
static const char *_dm_task_get_name_v1(const struct dm_task *dmt)
|
||||
{
|
||||
return (dmt->dmi.v1->name);
|
||||
}
|
||||
|
||||
static const char *_dm_task_get_uuid_v1(const struct dm_task *dmt)
|
||||
{
|
||||
return (dmt->dmi.v1->uuid);
|
||||
}
|
||||
|
||||
static struct dm_deps *_dm_task_get_deps_v1(struct dm_task *dmt)
|
||||
{
|
||||
log_error("deps version 1 no longer supported by libdevmapper");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static struct dm_names *_dm_task_get_names_v1(struct dm_task *dmt)
|
||||
{
|
||||
return (struct dm_names *) (((void *) dmt->dmi.v1) +
|
||||
dmt->dmi.v1->data_start);
|
||||
}
|
||||
|
||||
static char *_add_target_v1(struct target *t, char *out, char *end)
|
||||
{
|
||||
char *out_sp = out;
|
||||
struct dm_target_spec_v1 sp;
|
||||
size_t sp_size = sizeof(struct dm_target_spec_v1);
|
||||
int len;
|
||||
|
||||
out += sp_size;
|
||||
if (out >= end)
|
||||
return_NULL;
|
||||
|
||||
sp.status = 0;
|
||||
sp.sector_start = t->start;
|
||||
sp.length = t->length;
|
||||
strncpy(sp.target_type, t->type, sizeof(sp.target_type));
|
||||
|
||||
len = strlen(t->params);
|
||||
|
||||
if ((out + len + 1) >= end)
|
||||
return_NULL;
|
||||
|
||||
strcpy(out, t->params);
|
||||
out += len + 1;
|
||||
|
||||
/* align next block */
|
||||
out = _align(out, ALIGNMENT_V1);
|
||||
|
||||
sp.next = out - out_sp;
|
||||
|
||||
memcpy(out_sp, &sp, sp_size);
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
static struct dm_ioctl_v1 *_flatten_v1(struct dm_task *dmt)
|
||||
{
|
||||
const size_t min_size = 16 * 1024;
|
||||
const int (*version)[3];
|
||||
|
||||
struct dm_ioctl_v1 *dmi;
|
||||
struct target *t;
|
||||
size_t len = sizeof(struct dm_ioctl_v1);
|
||||
char *b, *e;
|
||||
int count = 0;
|
||||
|
||||
for (t = dmt->head; t; t = t->next) {
|
||||
len += sizeof(struct dm_target_spec_v1);
|
||||
len += strlen(t->params) + 1 + ALIGNMENT_V1;
|
||||
count++;
|
||||
}
|
||||
|
||||
if (count && dmt->newname) {
|
||||
log_error("targets and newname are incompatible");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (dmt->newname)
|
||||
len += strlen(dmt->newname) + 1;
|
||||
|
||||
/*
|
||||
* Give len a minimum size so that we have space to store
|
||||
* dependencies or status information.
|
||||
*/
|
||||
if (len < min_size)
|
||||
len = min_size;
|
||||
|
||||
if (!(dmi = dm_malloc(len)))
|
||||
return NULL;
|
||||
|
||||
memset(dmi, 0, len);
|
||||
|
||||
version = &_cmd_data_v1[dmt->type].version;
|
||||
|
||||
dmi->version[0] = (*version)[0];
|
||||
dmi->version[1] = (*version)[1];
|
||||
dmi->version[2] = (*version)[2];
|
||||
|
||||
dmi->data_size = len;
|
||||
dmi->data_start = sizeof(struct dm_ioctl_v1);
|
||||
|
||||
if (dmt->dev_name)
|
||||
strncpy(dmi->name, dmt->dev_name, sizeof(dmi->name));
|
||||
|
||||
if (dmt->type == DM_DEVICE_SUSPEND)
|
||||
dmi->flags |= DM_SUSPEND_FLAG;
|
||||
if (dmt->read_only)
|
||||
dmi->flags |= DM_READONLY_FLAG;
|
||||
|
||||
if (dmt->minor >= 0) {
|
||||
if (dmt->major <= 0) {
|
||||
log_error("Missing major number for persistent device");
|
||||
return NULL;
|
||||
}
|
||||
dmi->flags |= DM_PERSISTENT_DEV_FLAG;
|
||||
dmi->dev = MKDEV(dmt->major, dmt->minor);
|
||||
}
|
||||
|
||||
if (dmt->uuid)
|
||||
strncpy(dmi->uuid, dmt->uuid, sizeof(dmi->uuid));
|
||||
|
||||
dmi->target_count = count;
|
||||
|
||||
b = (char *) (dmi + 1);
|
||||
e = (char *) dmi + len;
|
||||
|
||||
for (t = dmt->head; t; t = t->next)
|
||||
if (!(b = _add_target_v1(t, b, e))) {
|
||||
log_error("Ran out of memory building ioctl parameter");
|
||||
goto bad;
|
||||
}
|
||||
|
||||
if (dmt->newname)
|
||||
strcpy(b, dmt->newname);
|
||||
|
||||
return dmi;
|
||||
|
||||
bad:
|
||||
_dm_zfree_dmi_v1(dmi);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static int _dm_names_v1(struct dm_ioctl_v1 *dmi)
|
||||
{
|
||||
const char *dev_dir = dm_dir();
|
||||
int r = 1, len;
|
||||
const char *name;
|
||||
struct dirent *dirent;
|
||||
DIR *d;
|
||||
struct dm_names *names, *old_names = NULL;
|
||||
void *end = (void *) dmi + dmi->data_size;
|
||||
struct stat buf;
|
||||
char path[PATH_MAX];
|
||||
|
||||
log_warn("WARNING: Device list may be incomplete with interface "
|
||||
"version 1.");
|
||||
log_warn("Please upgrade your kernel device-mapper driver.");
|
||||
|
||||
if (!(d = opendir(dev_dir))) {
|
||||
log_sys_error("opendir", dev_dir);
|
||||
return 0;
|
||||
}
|
||||
|
||||
names = (struct dm_names *) ((void *) dmi + dmi->data_start);
|
||||
|
||||
names->dev = 0; /* Flags no data */
|
||||
|
||||
while ((dirent = readdir(d))) {
|
||||
name = dirent->d_name;
|
||||
|
||||
if (name[0] == '.' || !strcmp(name, "control"))
|
||||
continue;
|
||||
|
||||
if (old_names)
|
||||
old_names->next = (uint32_t) ((void *) names -
|
||||
(void *) old_names);
|
||||
snprintf(path, sizeof(path), "%s/%s", dev_dir, name);
|
||||
if (stat(path, &buf)) {
|
||||
log_sys_error("stat", path);
|
||||
continue;
|
||||
}
|
||||
if (!S_ISBLK(buf.st_mode))
|
||||
continue;
|
||||
names->dev = (uint64_t) buf.st_rdev;
|
||||
names->next = 0;
|
||||
len = strlen(name);
|
||||
if (((char *) (names + 1) + len + 1) >= end) {
|
||||
log_error("Insufficient buffer space for device list");
|
||||
r = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
strcpy(names->name, name);
|
||||
|
||||
old_names = names;
|
||||
names = _align((char *) ++names + len + 1, ALIGNMENT);
|
||||
}
|
||||
|
||||
if (closedir(d))
|
||||
log_sys_error("closedir", dev_dir);
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
static int _dm_task_run_v1(struct dm_task *dmt)
|
||||
{
|
||||
struct dm_ioctl_v1 *dmi;
|
||||
unsigned int command;
|
||||
|
||||
dmi = _flatten_v1(dmt);
|
||||
if (!dmi) {
|
||||
log_error("Couldn't create ioctl argument.");
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!_open_control())
|
||||
return 0;
|
||||
|
||||
if ((unsigned) dmt->type >=
|
||||
(sizeof(_cmd_data_v1) / sizeof(*_cmd_data_v1))) {
|
||||
log_error(INTERNAL_ERROR "unknown device-mapper task %d",
|
||||
dmt->type);
|
||||
goto bad;
|
||||
}
|
||||
|
||||
command = _cmd_data_v1[dmt->type].cmd;
|
||||
|
||||
if (dmt->type == DM_DEVICE_TABLE)
|
||||
dmi->flags |= DM_STATUS_TABLE_FLAG;
|
||||
|
||||
if (dmt->new_uuid) {
|
||||
log_error("Changing UUID is not supported by kernel.");
|
||||
goto bad;
|
||||
}
|
||||
|
||||
log_debug("dm %s %s %s%s%s [%u]", _cmd_data_v1[dmt->type].name,
|
||||
dmi->name, dmi->uuid, dmt->newname ? " " : "",
|
||||
dmt->newname ? dmt->newname : "",
|
||||
dmi->data_size);
|
||||
if (dmt->type == DM_DEVICE_LIST) {
|
||||
if (!_dm_names_v1(dmi))
|
||||
goto bad;
|
||||
}
|
||||
#ifdef DM_IOCTLS
|
||||
else if (ioctl(_control_fd, command, dmi) < 0) {
|
||||
if (_log_suppress)
|
||||
log_verbose("device-mapper: %s ioctl failed: %s",
|
||||
_cmd_data_v1[dmt->type].name,
|
||||
strerror(errno));
|
||||
else
|
||||
log_error("device-mapper: %s ioctl failed: %s",
|
||||
_cmd_data_v1[dmt->type].name,
|
||||
strerror(errno));
|
||||
goto bad;
|
||||
}
|
||||
#else /* Userspace alternative for testing */
|
||||
#endif
|
||||
|
||||
if (dmi->flags & DM_BUFFER_FULL_FLAG)
|
||||
/* FIXME Increase buffer size and retry operation (if query) */
|
||||
log_error("WARNING: libdevmapper buffer too small for data");
|
||||
|
||||
switch (dmt->type) {
|
||||
case DM_DEVICE_CREATE:
|
||||
add_dev_node(dmt->dev_name, MAJOR(dmi->dev), MINOR(dmi->dev),
|
||||
dmt->uid, dmt->gid, dmt->mode, 0);
|
||||
break;
|
||||
|
||||
case DM_DEVICE_REMOVE:
|
||||
rm_dev_node(dmt->dev_name, 0);
|
||||
break;
|
||||
|
||||
case DM_DEVICE_RENAME:
|
||||
rename_dev_node(dmt->dev_name, dmt->newname, 0);
|
||||
break;
|
||||
|
||||
case DM_DEVICE_MKNODES:
|
||||
if (dmi->flags & DM_EXISTS_FLAG)
|
||||
add_dev_node(dmt->dev_name, MAJOR(dmi->dev),
|
||||
MINOR(dmi->dev), dmt->uid,
|
||||
dmt->gid, dmt->mode, 0);
|
||||
else
|
||||
rm_dev_node(dmt->dev_name, 0);
|
||||
break;
|
||||
|
||||
case DM_DEVICE_STATUS:
|
||||
case DM_DEVICE_TABLE:
|
||||
if (!_unmarshal_status_v1(dmt, dmi))
|
||||
goto bad;
|
||||
break;
|
||||
|
||||
case DM_DEVICE_SUSPEND:
|
||||
case DM_DEVICE_RESUME:
|
||||
dmt->type = DM_DEVICE_INFO;
|
||||
if (!dm_task_run(dmt))
|
||||
goto bad;
|
||||
_dm_zfree_dmi_v1(dmi); /* We'll use what info returned */
|
||||
return 1;
|
||||
}
|
||||
|
||||
dmt->dmi.v1 = dmi;
|
||||
return 1;
|
||||
|
||||
bad:
|
||||
_dm_zfree_dmi_v1(dmi);
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Protocol Version 4 functions.
|
||||
*/
|
||||
@ -881,11 +463,6 @@ int dm_task_get_driver_version(struct dm_task *dmt, char *version, size_t size)
|
||||
{
|
||||
unsigned *v;
|
||||
|
||||
#ifdef DM_COMPAT
|
||||
if (_dm_version == 1)
|
||||
return _dm_task_get_driver_version_v1(dmt, version, size);
|
||||
#endif
|
||||
|
||||
if (!dmt->dmi.v4) {
|
||||
version[0] = '\0';
|
||||
return 0;
|
||||
@ -1033,11 +610,6 @@ int dm_format_dev(char *buf, int bufsize, uint32_t dev_major,
|
||||
{
|
||||
int r;
|
||||
|
||||
#ifdef DM_COMPAT
|
||||
if (_dm_version == 1)
|
||||
return _dm_format_dev_v1(buf, bufsize, dev_major, dev_minor);
|
||||
#endif
|
||||
|
||||
if (bufsize < 8)
|
||||
return 0;
|
||||
|
||||
@ -1050,11 +622,6 @@ int dm_format_dev(char *buf, int bufsize, uint32_t dev_major,
|
||||
|
||||
int dm_task_get_info(struct dm_task *dmt, struct dm_info *info)
|
||||
{
|
||||
#ifdef DM_COMPAT
|
||||
if (_dm_version == 1)
|
||||
return _dm_task_get_info_v1(dmt, info);
|
||||
#endif
|
||||
|
||||
if (!dmt->dmi.v4)
|
||||
return 0;
|
||||
|
||||
@ -1084,12 +651,6 @@ uint32_t dm_task_get_read_ahead(const struct dm_task *dmt, uint32_t *read_ahead)
|
||||
|
||||
*read_ahead = 0;
|
||||
|
||||
#ifdef DM_COMPAT
|
||||
/* Not supporting this */
|
||||
if (_dm_version == 1)
|
||||
return 1;
|
||||
#endif
|
||||
|
||||
if (!dmt->dmi.v4 || !(dmt->dmi.v4->flags & DM_EXISTS_FLAG))
|
||||
return 0;
|
||||
|
||||
@ -1107,42 +668,22 @@ uint32_t dm_task_get_read_ahead(const struct dm_task *dmt, uint32_t *read_ahead)
|
||||
|
||||
const char *dm_task_get_name(const struct dm_task *dmt)
|
||||
{
|
||||
#ifdef DM_COMPAT
|
||||
if (_dm_version == 1)
|
||||
return _dm_task_get_name_v1(dmt);
|
||||
#endif
|
||||
|
||||
return (dmt->dmi.v4->name);
|
||||
}
|
||||
|
||||
const char *dm_task_get_uuid(const struct dm_task *dmt)
|
||||
{
|
||||
#ifdef DM_COMPAT
|
||||
if (_dm_version == 1)
|
||||
return _dm_task_get_uuid_v1(dmt);
|
||||
#endif
|
||||
|
||||
return (dmt->dmi.v4->uuid);
|
||||
}
|
||||
|
||||
struct dm_deps *dm_task_get_deps(struct dm_task *dmt)
|
||||
{
|
||||
#ifdef DM_COMPAT
|
||||
if (_dm_version == 1)
|
||||
return _dm_task_get_deps_v1(dmt);
|
||||
#endif
|
||||
|
||||
return (struct dm_deps *) (((char *) dmt->dmi.v4) +
|
||||
dmt->dmi.v4->data_start);
|
||||
}
|
||||
|
||||
struct dm_names *dm_task_get_names(struct dm_task *dmt)
|
||||
{
|
||||
#ifdef DM_COMPAT
|
||||
if (_dm_version == 1)
|
||||
return _dm_task_get_names_v1(dmt);
|
||||
#endif
|
||||
|
||||
return (struct dm_names *) (((char *) dmt->dmi.v4) +
|
||||
dmt->dmi.v4->data_start);
|
||||
}
|
||||
@ -2131,11 +1672,6 @@ int dm_task_run(struct dm_task *dmt)
|
||||
int rely_on_udev;
|
||||
int suspended_counter;
|
||||
|
||||
#ifdef DM_COMPAT
|
||||
if (_dm_version == 1)
|
||||
return _dm_task_run_v1(dmt);
|
||||
#endif
|
||||
|
||||
if ((unsigned) dmt->type >=
|
||||
(sizeof(_cmd_data_v4) / sizeof(*_cmd_data_v4))) {
|
||||
log_error(INTERNAL_ERROR "unknown device-mapper task %d",
|
||||
|
@ -20,7 +20,6 @@
|
||||
#include <sys/types.h>
|
||||
|
||||
struct dm_ioctl;
|
||||
struct dm_ioctl_v1;
|
||||
|
||||
struct target {
|
||||
uint64_t start;
|
||||
@ -49,7 +48,6 @@ struct dm_task {
|
||||
uint32_t read_ahead_flags;
|
||||
union {
|
||||
struct dm_ioctl *v4;
|
||||
struct dm_ioctl_v1 *v1;
|
||||
} dmi;
|
||||
char *newname;
|
||||
char *message;
|
||||
|
Loading…
x
Reference in New Issue
Block a user