mirror of
git://sourceware.org/git/lvm2.git
synced 2024-12-21 13:34:40 +03:00
Introduce log_sys_* macros from LVM2.
Convert existing "<string>: <function> failed: <strerror>" type messages to use this macro. Patch by Jun'ichi Nomura.
This commit is contained in:
parent
3579b652e7
commit
87518d850b
@ -1,5 +1,6 @@
|
|||||||
Version 1.02.22 -
|
Version 1.02.22 -
|
||||||
================================
|
================================
|
||||||
|
Introduce and use log_sys_* macros from LVM2
|
||||||
dm_fclose: new function
|
dm_fclose: new function
|
||||||
libdevmapper, dmeventd: be paranoid about detecting write failure
|
libdevmapper, dmeventd: be paranoid about detecting write failure
|
||||||
|
|
||||||
|
@ -140,7 +140,7 @@ static int _get_proc_number(const char *file, const char *name,
|
|||||||
uint32_t num;
|
uint32_t num;
|
||||||
|
|
||||||
if (!(fl = fopen(file, "r"))) {
|
if (!(fl = fopen(file, "r"))) {
|
||||||
log_error("%s: fopen failed: %s", file, strerror(errno));
|
log_sys_error("fopen", file);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -150,7 +150,7 @@ static int _get_proc_number(const char *file, const char *name,
|
|||||||
if (number) {
|
if (number) {
|
||||||
*number = num;
|
*number = num;
|
||||||
if (fclose(fl))
|
if (fclose(fl))
|
||||||
log_error("%s: fclose failed: %s", file, strerror(errno));
|
log_sys_error("fclose", file);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
dm_bit_set(_dm_bitset, num);
|
dm_bit_set(_dm_bitset, num);
|
||||||
@ -160,7 +160,7 @@ static int _get_proc_number(const char *file, const char *name,
|
|||||||
} while (c != EOF && c != '\n');
|
} while (c != EOF && c != '\n');
|
||||||
}
|
}
|
||||||
if (fclose(fl))
|
if (fclose(fl))
|
||||||
log_error("%s: fclose failed: %s", file, strerror(errno));
|
log_sys_error("fclose", file);
|
||||||
|
|
||||||
if (number) {
|
if (number) {
|
||||||
log_error("%s: No entry for %s found", file, name);
|
log_error("%s: No entry for %s found", file, name);
|
||||||
@ -190,8 +190,7 @@ static int _control_exists(const char *control, uint32_t major, uint32_t minor)
|
|||||||
|
|
||||||
if (stat(control, &buf) < 0) {
|
if (stat(control, &buf) < 0) {
|
||||||
if (errno != ENOENT)
|
if (errno != ENOENT)
|
||||||
log_error("%s: stat failed: %s", control,
|
log_sys_error("stat", control);
|
||||||
strerror(errno));
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -199,8 +198,7 @@ static int _control_exists(const char *control, uint32_t major, uint32_t minor)
|
|||||||
log_verbose("%s: Wrong inode type", control);
|
log_verbose("%s: Wrong inode type", control);
|
||||||
if (!unlink(control))
|
if (!unlink(control))
|
||||||
return 0;
|
return 0;
|
||||||
log_error("%s: unlink failed: %s", control,
|
log_sys_error("unlink", control);
|
||||||
strerror(errno));
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -211,8 +209,7 @@ static int _control_exists(const char *control, uint32_t major, uint32_t minor)
|
|||||||
major, minor);
|
major, minor);
|
||||||
if (!unlink(control))
|
if (!unlink(control))
|
||||||
return 0;
|
return 0;
|
||||||
log_error("%s: unlink failed: %s", control,
|
log_sys_error("unlink", control);
|
||||||
strerror(errno));
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -238,7 +235,7 @@ static int _create_control(const char *control, uint32_t major, uint32_t minor)
|
|||||||
|
|
||||||
if (mknod(control, S_IFCHR | S_IRUSR | S_IWUSR,
|
if (mknod(control, S_IFCHR | S_IRUSR | S_IWUSR,
|
||||||
MKDEV(major, minor)) < 0) {
|
MKDEV(major, minor)) < 0) {
|
||||||
log_error("%s: mknod failed: %s", control, strerror(errno));
|
log_sys_error("mknod", control);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -301,7 +298,7 @@ static int _open_control(void)
|
|||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
if ((_control_fd = open(control, O_RDWR)) < 0) {
|
if ((_control_fd = open(control, O_RDWR)) < 0) {
|
||||||
log_error("%s: open failed: %s", control, strerror(errno));
|
log_sys_error("open", control);
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -597,7 +594,7 @@ static int _dm_names_v1(struct dm_ioctl_v1 *dmi)
|
|||||||
log_warn("Please upgrade your kernel device-mapper driver.");
|
log_warn("Please upgrade your kernel device-mapper driver.");
|
||||||
|
|
||||||
if (!(d = opendir(dev_dir))) {
|
if (!(d = opendir(dev_dir))) {
|
||||||
log_error("%s: opendir failed: %s", dev_dir, strerror(errno));
|
log_sys_error("opendir", dev_dir);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -616,7 +613,7 @@ static int _dm_names_v1(struct dm_ioctl_v1 *dmi)
|
|||||||
(void *) old_names);
|
(void *) old_names);
|
||||||
snprintf(path, sizeof(path), "%s/%s", dev_dir, name);
|
snprintf(path, sizeof(path), "%s/%s", dev_dir, name);
|
||||||
if (stat(path, &buf)) {
|
if (stat(path, &buf)) {
|
||||||
log_error("%s: stat failed: %s", path, strerror(errno));
|
log_sys_error("stat", path);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (!S_ISBLK(buf.st_mode))
|
if (!S_ISBLK(buf.st_mode))
|
||||||
@ -637,7 +634,7 @@ static int _dm_names_v1(struct dm_ioctl_v1 *dmi)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (closedir(d))
|
if (closedir(d))
|
||||||
log_error("%s: closedir failed: %s", dev_dir, strerror(errno));
|
log_sys_error("closedir", dev_dir);
|
||||||
|
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
@ -1324,7 +1321,7 @@ static int _process_mapper_dir(struct dm_task *dmt)
|
|||||||
|
|
||||||
dir = dm_dir();
|
dir = dm_dir();
|
||||||
if (!(d = opendir(dir))) {
|
if (!(d = opendir(dir))) {
|
||||||
log_error("opendir %s: %s", dir, strerror(errno));
|
log_sys_error("opendir", dir);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1338,7 +1335,7 @@ static int _process_mapper_dir(struct dm_task *dmt)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (closedir(d))
|
if (closedir(d))
|
||||||
log_error("closedir %s: %s", dir, strerror(errno));
|
log_sys_error("closedir", dir);
|
||||||
|
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
@ -242,7 +242,7 @@ int dm_set_selinux_context(const char *path, mode_t mode)
|
|||||||
log_debug("Setting SELinux context for %s to %s.", path, scontext);
|
log_debug("Setting SELinux context for %s to %s.", path, scontext);
|
||||||
|
|
||||||
if ((lsetfilecon(path, scontext) < 0) && (errno != ENOTSUP)) {
|
if ((lsetfilecon(path, scontext) < 0) && (errno != ENOTSUP)) {
|
||||||
log_error("%s: lsetfilecon failed: %s", path, strerror(errno));
|
log_sys_error("lsetfilecon", path);
|
||||||
freecon(scontext);
|
freecon(scontext);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -288,7 +288,7 @@ static int _add_dev_node(const char *dev_name, uint32_t major, uint32_t minor,
|
|||||||
umask(old_mask);
|
umask(old_mask);
|
||||||
|
|
||||||
if (chown(path, uid, gid) < 0) {
|
if (chown(path, uid, gid) < 0) {
|
||||||
log_error("%s: chown failed: %s", path, strerror(errno));
|
log_sys_error("chown", path);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -33,8 +33,7 @@ static int _create_dir_recursive(const char *dir)
|
|||||||
if (*orig) {
|
if (*orig) {
|
||||||
rc = mkdir(orig, 0777);
|
rc = mkdir(orig, 0777);
|
||||||
if (rc < 0 && errno != EEXIST) {
|
if (rc < 0 && errno != EEXIST) {
|
||||||
log_error("%s: mkdir failed: %s", orig,
|
log_sys_error("mkdir", orig);
|
||||||
strerror(errno));
|
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -44,8 +43,7 @@ static int _create_dir_recursive(const char *dir)
|
|||||||
/* Create final directory */
|
/* Create final directory */
|
||||||
rc = mkdir(dir, 0777);
|
rc = mkdir(dir, 0777);
|
||||||
if (rc < 0 && errno != EEXIST) {
|
if (rc < 0 && errno != EEXIST) {
|
||||||
log_error("%s: mkdir failed: %s", orig,
|
log_sys_error("mkdir", orig);
|
||||||
strerror(errno));
|
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user