summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cmds-qgroup.c3
-rw-r--r--messages.h4
-rw-r--r--mkfs/rootdir.c47
-rw-r--r--qgroup.c3
4 files changed, 25 insertions, 32 deletions
diff --git a/cmds-qgroup.c b/cmds-qgroup.c
index 7234bdc1..10859c82 100644
--- a/cmds-qgroup.c
+++ b/cmds-qgroup.c
@@ -380,8 +380,7 @@ static int cmd_qgroup_show(int argc, char **argv)
if (sync) {
err = btrfs_util_sync_fd(fd);
if (err)
- warning("sync ioctl failed on '%s': %s", path,
- strerror(errno));
+ warning("sync ioctl failed on '%s': %m", path);
}
if (filter_flag) {
diff --git a/messages.h b/messages.h
index 2b97aa08..ec7d9338 100644
--- a/messages.h
+++ b/messages.h
@@ -61,9 +61,9 @@
PRINT_TRACE_ON_ERROR; \
PRINT_VERBOSE_ERROR; \
if (lib_str && strcmp(errno_str, lib_str) != 0) \
- __btrfs_error("%s: %s", lib_str, errno_str); \
+ __btrfs_error("%s: %m", lib_str); \
else \
- __btrfs_error("%s", errno_str); \
+ __btrfs_error("%m"); \
DO_ABORT_ON_ERROR; \
} while (0)
diff --git a/mkfs/rootdir.c b/mkfs/rootdir.c
index c430bac6..74c46241 100644
--- a/mkfs/rootdir.c
+++ b/mkfs/rootdir.c
@@ -237,8 +237,7 @@ static int add_xattr_item(struct btrfs_trans_handle *trans,
if (ret < 0) {
if (errno == ENOTSUP)
return 0;
- error("getting a list of xattr failed for %s: %s", file_name,
- strerror(errno));
+ error("getting a list of xattr failed for %s: %m", file_name);
return ret;
}
if (ret == 0)
@@ -253,8 +252,8 @@ static int add_xattr_item(struct btrfs_trans_handle *trans,
if (ret < 0) {
if (errno == ENOTSUP)
return 0;
- error("getting a xattr value failed for %s attr %s: %s",
- file_name, cur_name, strerror(errno));
+ error("getting a xattr value failed for %s attr %s: %m",
+ file_name, cur_name);
return ret;
}
@@ -281,7 +280,7 @@ static int add_symbolic_link(struct btrfs_trans_handle *trans,
ret = readlink(path_name, buf, sizeof(buf));
if (ret <= 0) {
- error("readlink failed for %s: %s", path_name, strerror(errno));
+ error("readlink failed for %s: %m", path_name);
goto fail;
}
if (ret >= sizeof(buf)) {
@@ -320,7 +319,7 @@ static int add_file_items(struct btrfs_trans_handle *trans,
fd = open(path_name, O_RDONLY);
if (fd == -1) {
- error("cannot open %s: %s", path_name, strerror(errno));
+ error("cannot open %s: %m", path_name);
return ret;
}
@@ -339,10 +338,9 @@ static int add_file_items(struct btrfs_trans_handle *trans,
ret_read = pread64(fd, buffer, st->st_size, bytes_read);
if (ret_read == -1) {
- error("cannot read %s at offset %llu length %llu: %s",
+ error("cannot read %s at offset %llu length %llu: %m",
path_name, (unsigned long long)bytes_read,
- (unsigned long long)st->st_size,
- strerror(errno));
+ (unsigned long long)st->st_size);
free(buffer);
goto end;
}
@@ -388,11 +386,10 @@ again:
ret_read = pread64(fd, eb->data, sectorsize, file_pos +
bytes_read);
if (ret_read == -1) {
- error("cannot read %s at offset %llu length %llu: %s",
+ error("cannot read %s at offset %llu length %llu: %m",
path_name,
(unsigned long long)file_pos + bytes_read,
- (unsigned long long)sectorsize,
- strerror(errno));
+ (unsigned long long)sectorsize);
goto end;
}
@@ -467,7 +464,7 @@ static int traverse_directory(struct btrfs_trans_handle *trans,
dir_entry->dir_name = dir_name;
dir_entry->path = realpath(dir_name, NULL);
if (!dir_entry->path) {
- error("realpath failed for %s: %s", dir_name, strerror(errno));
+ error("realpath failed for %s: %m", dir_name);
ret = -1;
goto fail_no_dir;
}
@@ -506,8 +503,8 @@ static int traverse_directory(struct btrfs_trans_handle *trans,
parent_inum = parent_dir_entry->inum;
parent_dir_name = parent_dir_entry->dir_name;
if (chdir(parent_dir_entry->path)) {
- error("chdir failed for %s: %s",
- parent_dir_name, strerror(errno));
+ error("chdir failed for %s: %m",
+ parent_dir_name);
ret = -1;
goto fail_no_files;
}
@@ -515,8 +512,8 @@ static int traverse_directory(struct btrfs_trans_handle *trans,
count = scandir(parent_dir_entry->path, &files,
directory_select, NULL);
if (count == -1) {
- error("scandir failed for %s: %s",
- parent_dir_name, strerror(errno));
+ error("scandir failed for %s: %m",
+ parent_dir_name);
ret = -1;
goto fail;
}
@@ -525,8 +522,8 @@ static int traverse_directory(struct btrfs_trans_handle *trans,
cur_file = files[i];
if (lstat(cur_file->d_name, &st) == -1) {
- error("lstat failed for %s: %s",
- cur_file->d_name, strerror(errno));
+ error("lstat failed for %s: %m",
+ cur_file->d_name);
ret = -1;
goto fail;
}
@@ -648,7 +645,7 @@ int btrfs_mkfs_fill_dir(const char *source_dir, struct btrfs_root *root,
ret = lstat(source_dir, &root_st);
if (ret) {
- error("unable to lstat %s: %s", source_dir, strerror(errno));
+ error("unable to lstat %s: %m", source_dir);
ret = -errno;
goto out;
}
@@ -739,8 +736,7 @@ u64 btrfs_mkfs_size_dir(const char *dir_name, u32 sectorsize, u64 min_dev_size,
*/
ret = nftw(dir_name, ftw_add_entry_size, 10, FTW_PHYS);
if (ret < 0) {
- error("ftw subdir walk of %s failed: %s", dir_name,
- strerror(errno));
+ error("ftw subdir walk of %s failed: %m", dir_name);
exit(1);
}
@@ -946,16 +942,15 @@ int btrfs_mkfs_shrink_fs(struct btrfs_fs_info *fs_info, u64 *new_size_ret,
if (shrink_file_size) {
ret = fstat64(device->fd, &file_stat);
if (ret < 0) {
- error("failed to stat devid %llu: %s", device->devid,
- strerror(errno));
+ error("failed to stat devid %llu: %m", device->devid);
return ret;
}
if (!S_ISREG(file_stat.st_mode))
return ret;
ret = ftruncate64(device->fd, new_size);
if (ret < 0) {
- error("failed to truncate device file of devid %llu: %s",
- device->devid, strerror(errno));
+ error("failed to truncate device file of devid %llu: %m",
+ device->devid);
return ret;
}
}
diff --git a/qgroup.c b/qgroup.c
index 3269feb2..2cfd6dbd 100644
--- a/qgroup.c
+++ b/qgroup.c
@@ -1072,8 +1072,7 @@ static int __qgroups_search(int fd, struct qgroup_lookup *qgroup_lookup)
error("can't list qgroups: quotas not enabled");
ret = -ENOTTY;
} else {
- error("can't list qgroups: %s",
- strerror(errno));
+ error("can't list qgroups: %m");
ret = -errno;
}