From 938c6a19a9f28ccf93a70793ad2f4281ec053b5f Mon Sep 17 00:00:00 2001 From: David Sterba Date: Thu, 20 Apr 2023 01:00:41 +0200 Subject: [PATCH] btrfs-progs: subvol snapshot: adjust error message when there's an active swapfile Attempting to create a snapshot of subvolume with an active swapfile prints the errno message corresponding to ETXTBSY but this is confusing so change it to be more descriptove to: ERROR: cannot snapshot '/hibernate': source subvolume contains an active swapfile (Text file busy) Issue: #607 Signed-off-by: David Sterba --- cmds/subvolume.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/cmds/subvolume.c b/cmds/subvolume.c index 8bb21f9f..9e5e1411 100644 --- a/cmds/subvolume.c +++ b/cmds/subvolume.c @@ -652,9 +652,11 @@ static int cmd_subvolume_snapshot(const struct cmd_struct *cmd, int argc, char * strncpy_null(args.name, newname); res = ioctl(fddst, BTRFS_IOC_SNAP_CREATE_V2, &args); - if (res < 0) { - error("cannot snapshot '%s': %m", subvol); + if (errno == ETXTBSY) + error("cannot snapshot '%s': source subvolume contains an active swapfile (%m)", subvol); + else + error("cannot snapshot '%s': %m", subvol); goto out; }