btrfs-progs: subvol show: print a warning with rw and receive_uuid

Add a slightly more convenient way to identify the subvolumes with bad
combination of flags and received uuid.

Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
David Sterba 2021-10-07 18:33:27 +02:00
parent 0a4f9b93ab
commit cb9bd8e326
3 changed files with 30 additions and 0 deletions

View File

@ -1165,6 +1165,14 @@ static int cmd_subvol_show(const struct cmd_struct *cmd, int argc, char **argv)
}
/* Warn if it's a read-write subvolume with received_uuid */
if (!uuid_is_null(subvol.received_uuid) &&
!(subvol.flags & BTRFS_SUBVOL_RDONLY)) {
warning("the subvolume is read-write and has received_uuid set,\n"
"\t don't use it for incremental send. Please see section\n"
"\t 'SUBVOLUME FLAGS' in manual page btrfs-subvolume for\n"
"\t further information.");
}
/* print the info */
printf("%s\n", subvol.id == BTRFS_FS_TREE_OBJECTID ? "/" : subvol_path);
printf("\tName: \t\t\t%s\n",

View File

@ -0,0 +1,22 @@
#!/bin/bash
# Look for warning about read-write subvolume with received_uuid set, on a crafted
# image
source "$TEST_TOP/common"
setup_root_helper
prepare_test_dev
TEST_DEV=$(extract_image "subvol-rw-recv.img")
run_check_mount_test_dev
if ! run_check_stdout $SUDO_HELPER "$TOP/btrfs" subvolume show "$TEST_MNT/subvol1" |
grep -q "WARNING.*received_uuid"; then
_fail "no warning found"
fi
if run_check_stdout $SUDO_HELPER "$TOP/btrfs" subvolume show "$TEST_MNT/snap1" |
grep -q "WARNING.*received_uuid"; then
_fail "unexpected warning"
fi
run_check_umount_test_dev
rm -- "$TEST_DEV"