mirror of
git://sourceware.org/git/lvm2.git
synced 2024-12-29 15:22:30 +03:00
Use same log levels as LVM2.
This commit is contained in:
parent
4af6dc9663
commit
2cf9604929
@ -84,7 +84,7 @@ int dm_task_set_ro(struct dm_task *dmt)
|
||||
int dm_task_set_newname(struct dm_task *dmt, const char *newname)
|
||||
{
|
||||
if (!(dmt->newname = strdup(newname))) {
|
||||
log("dm_task_set_newname: strdup(%s) failed", newname);
|
||||
log_error("dm_task_set_newname: strdup(%s) failed", newname);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -98,19 +98,19 @@ struct target *create_target(uint64_t start,
|
||||
struct target *t = malloc(sizeof(*t));
|
||||
|
||||
if (!t) {
|
||||
log("create_target: malloc(%d) failed", sizeof(*t));
|
||||
log_error("create_target: malloc(%d) failed", sizeof(*t));
|
||||
return NULL;
|
||||
}
|
||||
|
||||
memset(t, 0, sizeof(*t));
|
||||
|
||||
if (!(t->params = strdup(params))) {
|
||||
log("create_target: strdup(params) failed");
|
||||
log_error("create_target: strdup(params) failed");
|
||||
goto bad;
|
||||
}
|
||||
|
||||
if (!(t->type = strdup(type))) {
|
||||
log("create_target: strdup(type) failed");
|
||||
log_error("create_target: strdup(type) failed");
|
||||
goto bad;
|
||||
}
|
||||
|
||||
@ -140,7 +140,7 @@ static void *_add_target(struct target *t, void *out, void *end)
|
||||
|
||||
out += sizeof(struct dm_target_spec);
|
||||
if (out >= end) {
|
||||
log(no_space);
|
||||
log_error(no_space);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@ -152,9 +152,9 @@ static void *_add_target(struct target *t, void *out, void *end)
|
||||
len = strlen(t->params);
|
||||
|
||||
if ((out + len + 1) >= end) {
|
||||
log(no_space);
|
||||
log_error(no_space);
|
||||
|
||||
log("t->params= '%s'", t->params);
|
||||
log_error("t->params= '%s'", t->params);
|
||||
return NULL;
|
||||
}
|
||||
strcpy((char *) out, t->params);
|
||||
@ -184,7 +184,7 @@ static struct dm_ioctl *_flatten(struct dm_task *dmt)
|
||||
}
|
||||
|
||||
if (count && dmt->newname) {
|
||||
log("targets and newname are incompatible");
|
||||
log_error("targets and newname are incompatible");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@ -240,14 +240,14 @@ int dm_task_run(struct dm_task *dmt)
|
||||
char control[PATH_MAX];
|
||||
|
||||
if (!dmi) {
|
||||
log("Couldn't create ioctl argument");
|
||||
log_error("Couldn't create ioctl argument");
|
||||
return 0;
|
||||
}
|
||||
|
||||
snprintf(control, sizeof(control), "%s/control", dm_dir());
|
||||
|
||||
if ((fd = open(control, O_RDWR)) < 0) {
|
||||
log("Couldn't open device-mapper control device");
|
||||
log_error("Couldn't open device-mapper control device");
|
||||
goto bad;
|
||||
}
|
||||
|
||||
@ -285,13 +285,13 @@ int dm_task_run(struct dm_task *dmt)
|
||||
break;
|
||||
|
||||
default:
|
||||
log("Internal error: unknown device-mapper task %d",
|
||||
log_error("Internal error: unknown device-mapper task %d",
|
||||
dmt->type);
|
||||
goto bad;
|
||||
}
|
||||
|
||||
if (ioctl(fd, command, dmi) < 0) {
|
||||
log("device-mapper ioctl cmd %d failed: %s", dmt->type,
|
||||
log_error("device-mapper ioctl cmd %d failed: %s", dmt->type,
|
||||
strerror(errno));
|
||||
goto bad;
|
||||
}
|
||||
|
@ -69,7 +69,7 @@ struct dm_task *dm_task_create(int type)
|
||||
struct dm_task *dmt = malloc(sizeof(*dmt));
|
||||
|
||||
if (!dmt) {
|
||||
log("dm_task_create: malloc(%d) failed", sizeof(*dmt));
|
||||
log_error("dm_task_create: malloc(%d) failed", sizeof(*dmt));
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@ -97,7 +97,7 @@ int dm_task_set_name(struct dm_task *dmt, const char *name)
|
||||
|
||||
if (stat(name, &st1) || stat(path, &st2) ||
|
||||
!(st1.st_dev == st2.st_dev)) {
|
||||
log("dm_task_set_name: Device %s not found", name);
|
||||
log_error("dm_task_set_name: Device %s not found", name);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -105,7 +105,7 @@ int dm_task_set_name(struct dm_task *dmt, const char *name)
|
||||
}
|
||||
|
||||
if (!(dmt->dev_name = strdup(name))) {
|
||||
log("dm_task_set_name: strdup(%s) failed", name);
|
||||
log_error("dm_task_set_name: strdup(%s) failed", name);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -149,7 +149,7 @@ int add_dev_node(const char *dev_name, dev_t dev)
|
||||
|
||||
if (stat(path, &info) >= 0) {
|
||||
if (!S_ISBLK(info.st_mode)) {
|
||||
log("A non-block device file at '%s' "
|
||||
log_error("A non-block device file at '%s' "
|
||||
"is already present", path);
|
||||
return 0;
|
||||
}
|
||||
@ -158,13 +158,13 @@ int add_dev_node(const char *dev_name, dev_t dev)
|
||||
return 1;
|
||||
|
||||
if (unlink(path) < 0) {
|
||||
log("Unable to unlink device node for '%s'", dev_name);
|
||||
log_error("Unable to unlink device node for '%s'", dev_name);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (mknod(path, S_IFBLK | S_IRUSR | S_IWUSR | S_IRGRP, dev) < 0) {
|
||||
log("Unable to make device node for '%s'", dev_name);
|
||||
log_error("Unable to make device node for '%s'", dev_name);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -182,7 +182,7 @@ int rm_dev_node(const char *dev_name)
|
||||
return 1;
|
||||
|
||||
if (unlink(path) < 0) {
|
||||
log("Unable to unlink device node for '%s'", dev_name);
|
||||
log_error("Unable to unlink device node for '%s'", dev_name);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -4,8 +4,20 @@
|
||||
* This file is released under the LGPL.
|
||||
*/
|
||||
|
||||
#define _LOG_DEBUG 7
|
||||
#define _LOG_INFO 6
|
||||
#define _LOG_NOTICE 5
|
||||
#define _LOG_WARN 4
|
||||
#define _LOG_ERR 3
|
||||
#define _LOG_FATAL 2
|
||||
|
||||
extern dm_log_fn _log;
|
||||
#define log(msg, x...) _log(1, __FILE__, __LINE__, msg, ## x)
|
||||
|
||||
#define log_error(msg, x...) _log(_LOG_ERR, __FILE__, __LINE__, msg, ## x)
|
||||
#define log_print(msg, x...) _log(_LOG_WARN, __FILE__, __LINE__, msg, ## x)
|
||||
#define log_verbose(msg, x...) _log(_LOG_NOTICE, __FILE__, __LINE__, msg, ## x)
|
||||
#define log_very_verbose(msg, x...) _log(_LOG_INFO, __FILE__, __LINE__, msg, ## x)
|
||||
#define log_debug(msg, x...) _log(_LOG_DEBUG, __FILE__, __LINE__, msg, ## x)
|
||||
|
||||
extern struct target *create_target(uint64_t start,
|
||||
uint64_t len,
|
||||
|
Loading…
Reference in New Issue
Block a user