From: Wang Shilong <wangsl.fnst@cn.fujitsu.com>
To: <linux-btrfs@vger.kernel.org>
Subject: [PATCH 2/6] Btrfs-progs: btrfs-restore,check if specified root is fs/file tree firstly
Date: Thu, 19 Jun 2014 09:27:05 +0800 [thread overview]
Message-ID: <1403141229-25565-2-git-send-email-wangsl.fnst@cn.fujitsu.com> (raw)
In-Reply-To: <1403141229-25565-1-git-send-email-wangsl.fnst@cn.fujitsu.com>
Steps to reproduce:
# mkfs.btrfs -f /dev/sda9
# mount /dev/sda9 /mnt
# dd if=/dev/zero of=/mnt/data bs=1M count=1
# btrfs restore -r /dev/sda9 -r 2 -o /tmp
If users don't input a valid fs/file root objectid, btrfs restore still
continue and don't restore anything, this is unfriendly, we could
check it firstly.
Signed-off-by: Wang Shilong <wangsl.fnst@cn.fujitsu.com>
---
cmds-restore.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/cmds-restore.c b/cmds-restore.c
index 96b97e1..934755a 100644
--- a/cmds-restore.c
+++ b/cmds-restore.c
@@ -1180,6 +1180,11 @@ int cmd_restore(int argc, char **argv)
break;
case 'r':
root_objectid = arg_strtou64(optarg);
+ if (!is_fstree(root_objectid)) {
+ fprintf(stderr, "objectid %llu is not a valid fs/file tree\n",
+ root_objectid);
+ exit(1);
+ }
break;
case 'l':
list_roots = 1;
--
1.9.0
next prev parent reply other threads:[~2014-06-19 1:31 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-06-19 1:27 [PATCH 1/6] Btrfs-progs: fsck: switch to is_fstree() Wang Shilong
2014-06-19 1:27 ` Wang Shilong [this message]
2014-06-19 1:27 ` [PATCH 3/6] Btrfs-progs: btrfs-restore, fix wrong return value if it fails to read specified fs root Wang Shilong
2014-06-19 1:27 ` [PATCH 4/6] Btrfs-progs: btrfs-restore,output resason why it fails to read root Wang Shilong
2014-06-19 1:27 ` [PATCH 5/6] Btrfs-progs: btrfs-restore, don't allow users to specify -r and -f at the same time Wang Shilong
2014-06-19 1:27 ` [PATCH 6/6] Btrfs-progs: btrfs-restore, document updates Wang Shilong
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=1403141229-25565-2-git-send-email-wangsl.fnst@cn.fujitsu.com \
--to=wangsl.fnst@cn.fujitsu.com \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.