mirror of
git://sourceware.org/git/lvm2.git
synced 2024-12-12 08:13:48 +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 -
|
||||
================================
|
||||
Introduce and use log_sys_* macros from LVM2
|
||||
dm_fclose: new function
|
||||
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;
|
||||
|
||||
if (!(fl = fopen(file, "r"))) {
|
||||
log_error("%s: fopen failed: %s", file, strerror(errno));
|
||||
log_sys_error("fopen", file);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -150,7 +150,7 @@ static int _get_proc_number(const char *file, const char *name,
|
||||
if (number) {
|
||||
*number = num;
|
||||
if (fclose(fl))
|
||||
log_error("%s: fclose failed: %s", file, strerror(errno));
|
||||
log_sys_error("fclose", file);
|
||||
return 1;
|
||||
}
|
||||
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');
|
||||
}
|
||||
if (fclose(fl))
|
||||
log_error("%s: fclose failed: %s", file, strerror(errno));
|
||||
log_sys_error("fclose", file);
|
||||
|
||||
if (number) {
|
||||
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 (errno != ENOENT)
|
||||
log_error("%s: stat failed: %s", control,
|
||||
strerror(errno));
|
||||
log_sys_error("stat", control);
|
||||
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);
|
||||
if (!unlink(control))
|
||||
return 0;
|
||||
log_error("%s: unlink failed: %s", control,
|
||||
strerror(errno));
|
||||
log_sys_error("unlink", control);
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -211,8 +209,7 @@ static int _control_exists(const char *control, uint32_t major, uint32_t minor)
|
||||
major, minor);
|
||||
if (!unlink(control))
|
||||
return 0;
|
||||
log_error("%s: unlink failed: %s", control,
|
||||
strerror(errno));
|
||||
log_sys_error("unlink", control);
|
||||
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,
|
||||
MKDEV(major, minor)) < 0) {
|
||||
log_error("%s: mknod failed: %s", control, strerror(errno));
|
||||
log_sys_error("mknod", control);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -301,7 +298,7 @@ static int _open_control(void)
|
||||
goto error;
|
||||
|
||||
if ((_control_fd = open(control, O_RDWR)) < 0) {
|
||||
log_error("%s: open failed: %s", control, strerror(errno));
|
||||
log_sys_error("open", control);
|
||||
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.");
|
||||
|
||||
if (!(d = opendir(dev_dir))) {
|
||||
log_error("%s: opendir failed: %s", dev_dir, strerror(errno));
|
||||
log_sys_error("opendir", dev_dir);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -616,7 +613,7 @@ static int _dm_names_v1(struct dm_ioctl_v1 *dmi)
|
||||
(void *) old_names);
|
||||
snprintf(path, sizeof(path), "%s/%s", dev_dir, name);
|
||||
if (stat(path, &buf)) {
|
||||
log_error("%s: stat failed: %s", path, strerror(errno));
|
||||
log_sys_error("stat", path);
|
||||
continue;
|
||||
}
|
||||
if (!S_ISBLK(buf.st_mode))
|
||||
@ -637,7 +634,7 @@ static int _dm_names_v1(struct dm_ioctl_v1 *dmi)
|
||||
}
|
||||
|
||||
if (closedir(d))
|
||||
log_error("%s: closedir failed: %s", dev_dir, strerror(errno));
|
||||
log_sys_error("closedir", dev_dir);
|
||||
|
||||
return r;
|
||||
}
|
||||
@ -1324,7 +1321,7 @@ static int _process_mapper_dir(struct dm_task *dmt)
|
||||
|
||||
dir = dm_dir();
|
||||
if (!(d = opendir(dir))) {
|
||||
log_error("opendir %s: %s", dir, strerror(errno));
|
||||
log_sys_error("opendir", dir);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -1338,7 +1335,7 @@ static int _process_mapper_dir(struct dm_task *dmt)
|
||||
}
|
||||
|
||||
if (closedir(d))
|
||||
log_error("closedir %s: %s", dir, strerror(errno));
|
||||
log_sys_error("closedir", dir);
|
||||
|
||||
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);
|
||||
|
||||
if ((lsetfilecon(path, scontext) < 0) && (errno != ENOTSUP)) {
|
||||
log_error("%s: lsetfilecon failed: %s", path, strerror(errno));
|
||||
log_sys_error("lsetfilecon", path);
|
||||
freecon(scontext);
|
||||
return 0;
|
||||
}
|
||||
@ -288,7 +288,7 @@ static int _add_dev_node(const char *dev_name, uint32_t major, uint32_t minor,
|
||||
umask(old_mask);
|
||||
|
||||
if (chown(path, uid, gid) < 0) {
|
||||
log_error("%s: chown failed: %s", path, strerror(errno));
|
||||
log_sys_error("chown", path);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -33,8 +33,7 @@ static int _create_dir_recursive(const char *dir)
|
||||
if (*orig) {
|
||||
rc = mkdir(orig, 0777);
|
||||
if (rc < 0 && errno != EEXIST) {
|
||||
log_error("%s: mkdir failed: %s", orig,
|
||||
strerror(errno));
|
||||
log_sys_error("mkdir", orig);
|
||||
goto out;
|
||||
}
|
||||
}
|
||||
@ -44,8 +43,7 @@ static int _create_dir_recursive(const char *dir)
|
||||
/* Create final directory */
|
||||
rc = mkdir(dir, 0777);
|
||||
if (rc < 0 && errno != EEXIST) {
|
||||
log_error("%s: mkdir failed: %s", orig,
|
||||
strerror(errno));
|
||||
log_sys_error("mkdir", orig);
|
||||
goto out;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user