#include "disk-io.h"
#include "commands.h"
-
+#include "help.h"
+#include "mkfs/common.h"
static int print_replace_status(int fd, const char *path, int once);
static char *time2string(char *buf, size_t s, __u64 t);
status_args.cmd = BTRFS_IOCTL_DEV_REPLACE_CMD_STATUS;
status_args.result = BTRFS_IOCTL_DEV_REPLACE_RESULT_NO_RESULT;
ret = ioctl(fdmnt, BTRFS_IOC_DEV_REPLACE, &status_args);
- if (ret) {
+ if (ret < 0) {
fprintf(stderr,
"ERROR: ioctl(DEV_REPLACE_STATUS) failed on \"%s\": %s",
path, strerror(errno));
}
strncpy((char *)start_args.start.tgtdev_name, dstdev,
BTRFS_DEVICE_PATH_NAME_MAX);
- ret = btrfs_prepare_device(fddstdev, dstdev, 1, &dstdev_block_count, 0,
- 0);
+ ret = btrfs_prepare_device(fddstdev, dstdev, &dstdev_block_count, 0,
+ PREP_DEVICE_ZERO_END | PREP_DEVICE_VERBOSE);
if (ret)
goto leave_with_error;
start_args.result = BTRFS_IOCTL_DEV_REPLACE_RESULT_NO_RESULT;
ret = ioctl(fdmnt, BTRFS_IOC_DEV_REPLACE, &start_args);
if (do_not_background) {
- if (ret) {
+ if (ret < 0) {
fprintf(stderr,
"ERROR: ioctl(DEV_REPLACE_START) failed on \"%s\": %s",
path, strerror(errno));
args.cmd = BTRFS_IOCTL_DEV_REPLACE_CMD_STATUS;
args.result = BTRFS_IOCTL_DEV_REPLACE_RESULT_NO_RESULT;
ret = ioctl(fd, BTRFS_IOC_DEV_REPLACE, &args);
- if (ret) {
+ if (ret < 0) {
fprintf(stderr, "ERROR: ioctl(DEV_REPLACE_STATUS) failed on \"%s\": %s",
path, strerror(errno));
if (args.result != BTRFS_IOCTL_DEV_REPLACE_RESULT_NO_RESULT)
printf("Never started");
break;
default:
- error("unknown status from ioctl DEV_REPLACE_STATUS on '%s': %llu\n",
+ error("unknown status from ioctl DEV_REPLACE_STATUS on '%s': %llu",
path, status->replace_state);
return -EINVAL;
}
ret = ioctl(fd, BTRFS_IOC_DEV_REPLACE, &args);
e = errno;
close_file_or_dir(fd, dirstream);
- if (ret) {
+ if (ret < 0) {
fprintf(stderr, "ERROR: ioctl(DEV_REPLACE_CANCEL) failed on \"%s\": %s",
path, strerror(e));
if (args.result != BTRFS_IOCTL_DEV_REPLACE_RESULT_NO_RESULT)