[PATCH] btrfs-progs: send: check if parent or clone sources are read-only

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The reference roots have to be read-only otherwise the results of send
stream could be undefined if the roots accidentaly change during the
process.

Signed-off-by: David Sterba <dsterba@xxxxxxx>
---
 cmds-send.c | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)

diff --git a/cmds-send.c b/cmds-send.c
index 302f5a89790a..85461d5b0283 100644
--- a/cmds-send.c
+++ b/cmds-send.c
@@ -504,6 +504,18 @@ int cmd_send(int argc, char **argv)
 						"root_id for %s\n", subvol);
 				goto out;
 			}
+
+			ret = is_subvol_ro(&send, subvol);
+			if (ret < 0)
+				goto out;
+			if (!ret) {
+				ret = -EINVAL;
+				fprintf(stderr,
+				"ERROR: cloned subvol %s is not read-only.\n",
+					subvol);
+				goto out;
+			}
+
 			add_clone_source(&send, root_id);
 			subvol_uuid_search_finit(&send.sus);
 			free(subvol);
@@ -532,6 +544,18 @@ int cmd_send(int argc, char **argv)
 						"%s\n", optarg, strerror(-ret));
 				goto out;
 			}
+
+			ret = is_subvol_ro(&send, snapshot_parent);
+			if (ret < 0)
+				goto out;
+			if (!ret) {
+				ret = -EINVAL;
+				fprintf(stderr,
+					"ERROR: parent %s is not read-only.\n",
+					snapshot_parent);
+				goto out;
+			}
+
 			full_send = 0;
 			break;
 		case 'i':
-- 
1.8.5

--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Filesystem Development]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux