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 <dsterba@suse.com>
This commit is contained in:
David Sterba 2023-04-20 01:00:41 +02:00
parent 6ef6c07ef7
commit 938c6a19a9
1 changed files with 4 additions and 2 deletions

View File

@ -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;
}