if (!res) {
free(*info_ptr);
- fprintf(stderr, "ERROR: not enough memory\n");
+ error("not enough memory");
return -ENOMEM;
}
return -e;
if (ret < 0) {
- fprintf(stderr,
- "ERROR: can't perform the search - %s\n",
+ error("cannot look up chunk tree info: %s",
strerror(e));
return 1;
}
sargs_orig = sargs = calloc(1, sizeof(struct btrfs_ioctl_space_args));
if (!sargs) {
- fprintf(stderr, "ERROR: not enough memory\n");
+ error("not enough memory");
return NULL;
}
ret = ioctl(fd, BTRFS_IOC_SPACE_INFO, sargs);
e = errno;
if (ret) {
- fprintf(stderr,
- "ERROR: couldn't get space info on '%s' - %s\n",
- path, strerror(e));
+ error("cannot get space info on '%s': %s", path, strerror(e));
free(sargs);
return NULL;
}
(count * sizeof(struct btrfs_ioctl_space_info)));
if (!sargs) {
free(sargs_orig);
- fprintf(stderr, "ERROR: not enough memory\n");
+ error("not enough memory");
return NULL;
}
e = errno;
if (ret) {
- fprintf(stderr,
- "ERROR: couldn't get space info on '%s' - %s\n",
- path, strerror(e));
+ error("cannot get space info with %u slots: %s",
+ count, strerror(e));
free(sargs);
return NULL;
}
}
if (r_total_size == 0) {
- fprintf(stderr,
- "ERROR: couldn't get space info on '%s' - %s\n",
+ error("cannot get space info on '%s': %s",
path, strerror(errno));
ret = 1;
ratio = 1;
if (!ratio)
- fprintf(stderr, "WARNING: RAID56 detected, not implemented\n");
+ warning("RAID56 detected, not implemented");
if (ratio > max_data_ratio)
max_data_ratio = ratio;
}
if ((flags & (BTRFS_BLOCK_GROUP_DATA | BTRFS_BLOCK_GROUP_METADATA))
== (BTRFS_BLOCK_GROUP_DATA | BTRFS_BLOCK_GROUP_METADATA)) {
- fprintf(stderr, "WARNING: MIXED blockgroups not handled\n");
+ warning("MIXED blockgroups not handled");
}
if (flags & BTRFS_BLOCK_GROUP_DATA) {
if (ret < 0) {
if (errno == EPERM)
return -errno;
- fprintf(stderr, "ERROR: cannot get filesystem info - %s\n",
+ error("cannot get filesystem info: %s",
strerror(errno));
return 1;
}
info = calloc(fi_args.num_devices, sizeof(struct device_info));
if (!info) {
- fprintf(stderr, "ERROR: not enough memory\n");
+ error("not enough memory");
return 1;
}
if (ret == -ENODEV)
continue;
if (ret) {
- fprintf(stderr,
- "ERROR: cannot get info about device devid=%d\n",
- i);
+ error("cannot get info about device devid=%d", i);
free(info);
return ret;
}
ret = load_chunk_info(fd, chunkinfo, chunkcount);
if (ret == -EPERM) {
- fprintf(stderr,
- "WARNING: can't read detailed chunk info, RAID5/6 numbers will be incorrect, run as root\n");
+ warning(
+"cannot read detailed chunk info, RAID5/6 numbers will be incorrect, run as root");
} else if (ret) {
return ret;
}
ret = load_device_info(fd, devinfo, devcount);
if (ret == -EPERM) {
- fprintf(stderr,
- "WARNING: can't get filesystem info from ioctl(FS_INFO), run as root\n");
+ warning(
+ "cannot get filesystem info from ioctl(FS_INFO), run as root");
ret = 0;
}
matrix = table_create(ncols, nrows);
if (!matrix) {
- fprintf(stderr, "ERROR: not enough memory\n");
+ error("not enough memory");
return;
}