sizeof(struct btrfs_qgroup_comparer);
set = calloc(1, size);
if (!set) {
- fprintf(stderr, "memory allocation failed\n");
+ error("memory allocation failed");
exit(1);
}
tmp = set;
set = realloc(set, size);
if (!set) {
- fprintf(stderr, "memory allocation failed\n");
+ error("memory allocation failed");
free(tmp);
exit(1);
}
if (pa && child) {
list = malloc(sizeof(*list));
if (!list) {
- fprintf(stderr, "memory allocation failed\n");
+ error("memory allocation failed");
exit(1);
}
list->qgroup = pa;
bq = calloc(1, sizeof(*bq));
if (!bq) {
- printf("memory allocation failed\n");
+ error("memory allocation failed");
exit(1);
}
if (qgroupid) {
if (parent && child) {
list = malloc(sizeof(*list));
if (!list) {
- fprintf(stderr, "memory allocation failed\n");
+ error("memory allocation failed");
exit(1);
}
list->qgroup = parent;
}
ret = qgroup_tree_insert(qgroup_lookup, bq);
if (ret) {
- printf("failed to insert tree %llu\n",
- bq->qgroupid);
+ error("failed to insert %llu into tree: %s",
+ (unsigned long long)bq->qgroupid, strerror(-ret));
exit(1);
}
return ret;
sizeof(struct btrfs_qgroup_filter);
set = calloc(1, size);
if (!set) {
- fprintf(stderr, "memory allocation failed\n");
+ error("memory allocation failed");
exit(1);
}
set->total = BTRFS_QGROUP_NFILTERS_INCREASE;
tmp = set;
set = realloc(set, size);
if (!set) {
- fprintf(stderr, "memory allocation failed\n");
+ error("memory allocation failed");
free(tmp);
exit(1);
}
static inline void print_status_flag_warning(u64 flags)
{
if (!(flags & BTRFS_QGROUP_STATUS_FLAG_ON))
- fprintf(stderr,
- "WARNING: Quota disabled, qgroup data may be out of date\n");
+ warning("quota disabled, qgroup data may be out of date");
else if (flags & BTRFS_QGROUP_STATUS_FLAG_RESCAN)
- fprintf(stderr,
- "WARNING: Rescan is running, qgroup data may be incorrect\n");
+ warning("rescan is running, qgroup data may be incorrect");
else if (flags & BTRFS_QGROUP_STATUS_FLAG_INCONSISTENT)
- fprintf(stderr,
- "WARNING: Qgroup data inconsistent, rescan recommended\n");
+ warning("qgroup data inconsistent, rescan recommended");
}
static int __qgroups_search(int fd, struct qgroup_lookup *qgroup_lookup)
while (1) {
ret = ioctl(fd, BTRFS_IOC_TREE_SEARCH, &args);
if (ret < 0) {
- fprintf(stderr,
- "ERROR: can't perform the search - %s\n",
- strerror(errno));
+ error("cannot perform the search: %s",
+ strerror(errno));
return ret;
}
/* the ioctl returns the number of item it found in nr_items */
ret = ioctl(fd, BTRFS_IOC_INO_LOOKUP, &args);
if (ret < 0) {
- fprintf(stderr,
- "ERROR: can't perform the search - %s\n",
- strerror(errno));
+ error("cannot perform the search: %s", strerror(errno));
return ret;
}
return args.treeid;
out = calloc(sizeof(*out) + sizeof(out->qgroups[0]) * (nitems + n), 1);
if (out == NULL) {
- fprintf(stderr, "ERROR: Not enough memory\n");
+ error("not enough memory");
return -ENOMEM;
}
int pos = 0;
if (qgroupid == 0) {
- fprintf(stderr, "ERROR: bad qgroup specification\n");
+ error("invalid qgroup specification, qgroupid must not 0");
return -EINVAL;
}
p = strchr(arg, ':');
if (!p) {
bad:
- fprintf(stderr, "ERROR: bad copy specification\n");
+ error("invalid copy specification, missing separator :");
return -EINVAL;
}
*p = 0;