1
0
mirror of git://sourceware.org/git/lvm2.git synced 2025-01-03 05:18:29 +03:00

device_mapper: convert vdo to use dm_ prefix

Keep using DM_/dm_ prefixes for device_mapper code.
This commit is contained in:
Zdenek Kabelac 2018-07-09 10:04:51 +02:00
parent 4a64bb9573
commit 9b6b4f14d8
2 changed files with 49 additions and 48 deletions

View File

@ -3,6 +3,7 @@
// For DM_ARRAY_SIZE! // For DM_ARRAY_SIZE!
#include "device_mapper/all.h" #include "device_mapper/all.h"
#include "base/memory/zalloc.h"
#include <ctype.h> #include <ctype.h>
#include <stdlib.h> #include <stdlib.h>
@ -27,14 +28,14 @@ static bool _parse_operating_mode(const char *b, const char *e, void *context)
{ {
static const struct { static const struct {
const char str[12]; const char str[12];
enum vdo_operating_mode mode; enum dm_vdo_operating_mode mode;
} _table[] = { } _table[] = {
{"recovering", VDO_MODE_RECOVERING}, {"recovering", DM_VDO_MODE_RECOVERING},
{"read-only", VDO_MODE_READ_ONLY}, {"read-only", DM_VDO_MODE_READ_ONLY},
{"normal", VDO_MODE_NORMAL} {"normal", DM_VDO_MODE_NORMAL}
}; };
enum vdo_operating_mode *r = context; enum dm_vdo_operating_mode *r = context;
unsigned i; unsigned i;
for (i = 0; i < DM_ARRAY_SIZE(_table); i++) { for (i = 0; i < DM_ARRAY_SIZE(_table); i++) {
if (_tok_eq(b, e, _table[i].str)) { if (_tok_eq(b, e, _table[i].str)) {
@ -50,13 +51,13 @@ static bool _parse_compression_state(const char *b, const char *e, void *context
{ {
static const struct { static const struct {
const char str[8]; const char str[8];
enum vdo_compression_state state; enum dm_vdo_compression_state state;
} _table[] = { } _table[] = {
{"online", VDO_COMPRESSION_ONLINE}, {"online", DM_VDO_COMPRESSION_ONLINE},
{"offline", VDO_COMPRESSION_OFFLINE} {"offline", DM_VDO_COMPRESSION_OFFLINE}
}; };
enum vdo_compression_state *r = context; enum dm_vdo_compression_state *r = context;
unsigned i; unsigned i;
for (i = 0; i < DM_ARRAY_SIZE(_table); i++) { for (i = 0; i < DM_ARRAY_SIZE(_table); i++) {
if (_tok_eq(b, e, _table[i].str)) { if (_tok_eq(b, e, _table[i].str)) {
@ -88,18 +89,18 @@ static bool _parse_index_state(const char *b, const char *e, void *context)
{ {
static const struct { static const struct {
const char str[8]; const char str[8];
enum vdo_index_state state; enum dm_vdo_index_state state;
} _table[] = { } _table[] = {
{"error", VDO_INDEX_ERROR}, {"error", DM_VDO_INDEX_ERROR},
{"closed", VDO_INDEX_CLOSED}, {"closed", DM_VDO_INDEX_CLOSED},
{"opening", VDO_INDEX_OPENING}, {"opening", DM_VDO_INDEX_OPENING},
{"closing", VDO_INDEX_CLOSING}, {"closing", DM_VDO_INDEX_CLOSING},
{"offline", VDO_INDEX_OFFLINE}, {"offline", DM_VDO_INDEX_OFFLINE},
{"online", VDO_INDEX_ONLINE}, {"online", DM_VDO_INDEX_ONLINE},
{"unknown", VDO_INDEX_UNKNOWN} {"unknown", DM_VDO_INDEX_UNKNOWN}
}; };
enum vdo_index_state *r = context; enum dm_vdo_index_state *r = context;
unsigned i; unsigned i;
for (i = 0; i < DM_ARRAY_SIZE(_table); i++) { for (i = 0; i < DM_ARRAY_SIZE(_table); i++) {
if (_tok_eq(b, e, _table[i].str)) { if (_tok_eq(b, e, _table[i].str)) {
@ -145,10 +146,10 @@ static const char *_next_tok(const char *b, const char *e)
return te == b ? NULL : te; return te == b ? NULL : te;
} }
static void _set_error(struct vdo_status_parse_result *result, const char *fmt, ...) static void _set_error(struct dm_vdo_status_parse_result *result, const char *fmt, ...)
__attribute__ ((format(printf, 2, 3))); __attribute__ ((format(printf, 2, 3)));
static void _set_error(struct vdo_status_parse_result *result, const char *fmt, ...) static void _set_error(struct dm_vdo_status_parse_result *result, const char *fmt, ...)
{ {
va_list ap; va_list ap;
@ -160,7 +161,7 @@ static void _set_error(struct vdo_status_parse_result *result, const char *fmt,
static bool _parse_field(const char **b, const char *e, static bool _parse_field(const char **b, const char *e,
bool (*p_fn)(const char *, const char *, void *), bool (*p_fn)(const char *, const char *, void *),
void *field, const char *field_name, void *field, const char *field_name,
struct vdo_status_parse_result *result) struct dm_vdo_status_parse_result *result)
{ {
const char *te; const char *te;
@ -180,13 +181,13 @@ static bool _parse_field(const char **b, const char *e,
} }
bool vdo_status_parse(struct dm_pool *mem, const char *input, bool dm_vdo_status_parse(struct dm_pool *mem, const char *input,
struct vdo_status_parse_result *result) struct dm_vdo_status_parse_result *result)
{ {
const char *b = b = input; const char *b = b = input;
const char *e = input + strlen(input); const char *e = input + strlen(input);
const char *te; const char *te;
struct vdo_status *s; struct dm_vdo_status *s;
s = (!mem) ? zalloc(sizeof(*s)) : dm_pool_zalloc(mem, sizeof(*s)); s = (!mem) ? zalloc(sizeof(*s)) : dm_pool_zalloc(mem, sizeof(*s));

View File

@ -20,51 +20,51 @@
//---------------------------------------------------------------- //----------------------------------------------------------------
enum vdo_operating_mode { enum dm_vdo_operating_mode {
VDO_MODE_RECOVERING, DM_VDO_MODE_RECOVERING,
VDO_MODE_READ_ONLY, DM_VDO_MODE_READ_ONLY,
VDO_MODE_NORMAL DM_VDO_MODE_NORMAL
}; };
enum vdo_compression_state { enum dm_vdo_compression_state {
VDO_COMPRESSION_ONLINE, DM_VDO_COMPRESSION_ONLINE,
VDO_COMPRESSION_OFFLINE DM_VDO_COMPRESSION_OFFLINE
}; };
enum vdo_index_state { enum dm_vdo_index_state {
VDO_INDEX_ERROR, DM_VDO_INDEX_ERROR,
VDO_INDEX_CLOSED, DM_VDO_INDEX_CLOSED,
VDO_INDEX_OPENING, DM_VDO_INDEX_OPENING,
VDO_INDEX_CLOSING, DM_VDO_INDEX_CLOSING,
VDO_INDEX_OFFLINE, DM_VDO_INDEX_OFFLINE,
VDO_INDEX_ONLINE, DM_VDO_INDEX_ONLINE,
VDO_INDEX_UNKNOWN DM_VDO_INDEX_UNKNOWN
}; };
struct vdo_status { struct dm_vdo_status {
char *device; char *device;
enum vdo_operating_mode operating_mode; enum dm_vdo_operating_mode operating_mode;
bool recovering; bool recovering;
enum vdo_index_state index_state; enum dm_vdo_index_state index_state;
enum vdo_compression_state compression_state; enum dm_vdo_compression_state compression_state;
uint64_t used_blocks; uint64_t used_blocks;
uint64_t total_blocks; uint64_t total_blocks;
}; };
void vdo_status_destroy(struct vdo_status *s); void dm_vdo_status_destroy(struct dm_vdo_status *s);
#define VDO_MAX_ERROR 256 #define VDO_MAX_ERROR 256
struct vdo_status_parse_result { struct dm_vdo_status_parse_result {
char error[VDO_MAX_ERROR]; char error[VDO_MAX_ERROR];
struct vdo_status *status; struct dm_vdo_status *status;
}; };
struct dm_pool; struct dm_pool;
// Parses the status line from the kernel target. // Parses the status line from the kernel target.
bool vdo_status_parse(struct dm_pool *mem, const char *input, bool dm_vdo_status_parse(struct dm_pool *mem, const char *input,
struct vdo_status_parse_result *result); struct dm_vdo_status_parse_result *result);
//---------------------------------------------------------------- //----------------------------------------------------------------