[PATCH 2/6] Btrfs-progs: btrfs-restore,check if specified root is fs/file tree firstly

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

 



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@xxxxxxxxxxxxxx>
---
 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

--
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