[sheepdog] [PATCH] dog/node: confirm before md plug

Ruoyu liangry at ucweb.com
Tue Jul 15 09:04:19 CEST 2014


Once a directory is plugged into the node, all data in it will be removed.
Therefore, it is better to print a warning message to user first for fear that
he or she specifies a wrong path.

Signed-off-by: Ruoyu <liangry at ucweb.com>
---
 dog/node.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/dog/node.c b/dog/node.c
index 83ff541..95ef4a4 100644
--- a/dog/node.c
+++ b/dog/node.c
@@ -468,8 +468,16 @@ static int do_plug_unplug(char *disks, bool plug)
 	return EXIT_SUCCESS;
 }
 
+#define MD_PLUG_PRINT				\
+	"    __\n"				\
+	"   ()'`;\n"				\
+	"   /\\|`\n"				\
+	"  /  |   Caution! The directories to be plugged will be purged.\n" \
+	"(/_)_|_  Are you sure you want to continue? [yes/no]: "
+
 static int md_plug(int argc, char **argv)
 {
+	confirm(MD_PLUG_PRINT);
 	return do_plug_unplug(argv[optind], true);
 }
 
-- 
1.8.3.2





More information about the sheepdog mailing list