Skip to content

Commit

Permalink
btrfs-progs: Issue warnings if ioctls fail in sigint handlers
Browse files Browse the repository at this point in the history
The two sigint handlers issue ioctls to clean up, but if
they fail, noone would know.  I'm not sure there is
any other error handling to be done at this point, but a
notification seems wise.

Signed-off-by: Eric Sandeen <[email protected]>
  • Loading branch information
Eric Sandeen authored and kdave committed Mar 10, 2013
1 parent 06efd54 commit 7b81119
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
5 changes: 4 additions & 1 deletion cmds-replace.c
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,13 @@ static int is_numerical(const char *str)
static int dev_replace_cancel_fd = -1;
static void dev_replace_sigint_handler(int signal)
{
int ret;
struct btrfs_ioctl_dev_replace_args args = {0};

args.cmd = BTRFS_IOCTL_DEV_REPLACE_CMD_CANCEL;
ioctl(dev_replace_cancel_fd, BTRFS_IOC_DEV_REPLACE, &args);
ret = ioctl(dev_replace_cancel_fd, BTRFS_IOC_DEV_REPLACE, &args);
if (ret < 0)
perror("Device replace cancel failed");
}

static int dev_replace_handle_sigint(int fd)
Expand Down
6 changes: 5 additions & 1 deletion cmds-scrub.c
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,11 @@ static void free_history(struct scrub_file_record **last_scrubs)
static int cancel_fd = -1;
static void scrub_sigint_record_progress(int signal)
{
ioctl(cancel_fd, BTRFS_IOC_SCRUB_CANCEL, NULL);
int ret;

ret = ioctl(cancel_fd, BTRFS_IOC_SCRUB_CANCEL, NULL);
if (ret < 0)
perror("Scrub cancel failed");
}

static int scrub_handle_sigint_parent(void)
Expand Down

0 comments on commit 7b81119

Please sign in to comment.