/* memory map the file */
if (stat(file, &info) || S_ISDIR(info.st_mode)) {
- log_sys_err("stat");
+ log_sys_error("stat", file);
return 0;
}
if ((fd = open(file, O_RDONLY)) < 0) {
- log_sys_err("open");
+ log_sys_error("open", file);
return 0;
}
p->fb = mmap((caddr_t) 0, info.st_size, PROT_READ, MAP_PRIVATE, fd, 0);
if (p->fb == MAP_FAILED) {
- log_sys_err("mmap");
+ log_sys_error("mmap", file);
close(fd);
return 0;
}
/* unmap the file */
if (munmap((char *) p->fb, info.st_size)) {
- log_sys_err("munmap failed");
+ log_sys_error("munmap", file);
r = 0;
}
int r = 1;
FILE *fp = fopen(file, "w");
if (!fp) {
- log_sys_err("open");
+ log_sys_error("open", file);
return 0;
}
buffer[n] = '\0';
if (stat(buffer, info) < 0) {
- log_sys_err("stat");
+ log_sys_very_verbose("stat", buffer);
return NULL;
}
struct stat info;
struct device *dev;
- log_debug("dev-cache adding %s", path);
+ log_very_verbose("dev-cache adding %s", path);
if (stat(path, &info) < 0) {
- log_sys_err("stat");
+ log_sys_very_verbose("stat", path);
return 0;
}
int fd;
long s;
- log_verbose("Getting device size");
+ log_very_verbose("Getting size of %s", dev->name);
if ((fd = open(dev->name, O_RDONLY)) < 0) {
- log_sys_err("open");
+ log_sys_error("open", dev->name);
return 0;
}
/* FIXME: add 64 bit ioctl */
if (ioctl(fd, BLKGETSIZE, &s) < 0) {
- log_sys_err("ioctl");
+ log_sys_error("ioctl BLKGETSIZE", dev->name);
close(fd);
return 0;
}
int fd = open(dev->name, O_RDONLY);
if (fd < 0) {
- log_sys_err("open");
+ log_sys_very_verbose("open", dev->name);
return 0;
}
if (lseek(fd, offset, SEEK_SET) < 0) {
- log_sys_err("lseek");
+ log_sys_error("lseek", dev->name);
return 0;
}
int fd = open(dev->name, O_WRONLY);
if (fd < 0) {
- log_sys_err("open");
+ log_sys_error("open", dev->name);
return 0;
}
if (lseek(fd, offset, SEEK_SET) < 0) {
- log_sys_err("lseek");
+ log_sys_error("lseek", dev->name);
return 0;
}
}
if (data->pv.id[0] != 'H' || data->pv.id[1] != 'M') {
- log_debug("%s does not have a valid PV identifier.",
+ log_very_verbose("%s does not have a valid PV identifier",
dev->name);
goto bad;
}
if (!_munge_formats(&data->pv)) {
- log_verbose("Unknown metadata version %d found on %s",
+ log_very_verbose("Unknown metadata version %d found on %s",
data->pv.version, dev->name);
goto bad;
}
* is it an orphan ?
*/
if (data->pv.vg_name == '\0') {
- log_very_verbose("%s is not a member of any VG",
- dev->name);
+ log_very_verbose("%s is not a member of any VG", dev->name);
return data;
}
va_start(ap, format);
switch(level) {
case _LOG_DEBUG:
- if (_verbose_level > 2) {
- printf(" ");
+ if (_verbose_level > 2 && format[1]) {
+ printf(" ");
vprintf(format, ap);
putchar('\n');
}
#define log_warn(x...) plog(_LOG_WARN, x)
#define log_err(x...) plog(_LOG_ERR, x)
#define log_fatal(x...) plog(_LOG_FATAL, x)
-#define log_sys_err(x) log_debug("system call '%s' failed (%s)", \
- x, strerror(errno))
-#define stack log_debug( "stack trace" )
+#define stack log_debug( "s" )
/*
* Macros to use for messages:
* log_verbose - print to stdout if verbose is set (-v)
* log_very_verbose - print to stdout if verbose is set twice (-vv)
* log_debug - print to stdout if verbose is set three times (-vvv)
+ * (suppressed if single-character string such as with 'stack')
*
* In addition, messages will be logged to file or syslog if they
* are more serious than the log level specified with -d.
#define log_verbose(fmt, args...) log_notice(fmt , ## args)
#define log_very_verbose(fmt, args...) log_info(fmt , ## args)
+/* System call equivalents */
+#define log_sys_error(x, y) \
+ log_err("%s: %s failed: %s", y, x, strerror(errno))
+#define log_sys_very_verbose(x, y) \
+ log_info("%s: %s failed: %s", y, x, strerror(errno))
+
#endif
/*
sprintf(new_path, "%s%s", prefix, vg_name_new);
log_verbose("Renaming %s to %s", old_path, new_path);
- if (!(rename(old_path, new_path))) {
+ if (rename(old_path, new_path)) {
log_error("Renaming %s to %s failed: %s",
old_path, new_path, strerror(errno));
return ECMD_FAILED;