linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: David Sterba <dsterba@suse.cz>
To: linux-btrfs@vger.kernel.org
Cc: David Sterba <dsterba@suse.cz>
Subject: [PATCH] btrfs-progs: send: check if parent or clone sources are read-only
Date: Mon, 16 Dec 2013 16:47:07 +0100	[thread overview]
Message-ID: <1387208827-10831-1-git-send-email-dsterba@suse.cz> (raw)

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@suse.cz>
---
 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


                 reply	other threads:[~2013-12-16 15:47 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1387208827-10831-1-git-send-email-dsterba@suse.cz \
    --to=dsterba@suse.cz \
    --cc=linux-btrfs@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).