ffdc: Added -e option to enable dump specific functions

Added support for the dump specific filename format.

Change-Id: I8771017c5a029675f98bca54170dc3330ac2c24d
Signed-off-by: Jayanth Othayoth <ojayanth@in.ibm.com>
diff --git a/ffdc b/ffdc
index 3adf81c..4ee0814 100644
--- a/ffdc
+++ b/ffdc
@@ -1,5 +1,7 @@
 #!/bin/sh
 
+# TODO openbmc/openbmc#1622 remove -e option related changes.
+
 help=$'FFDC File Collection Script
 
 Collects various FFDC files and system parameters and places them in a .tar
@@ -9,6 +11,7 @@
 Options:
    -d, --dir <directory>  Specify destination directory. Defaults to /tmp if
                           invalid or unspecified.
+   -e, --enable_dump      Enable BMC Dump specific features.
    -h, --help             Display this help text and exit.
 '
 
@@ -38,6 +41,7 @@
 
 dir=$"ffdc_$(date +"%Y-%m-%d_%H-%M-%S")"
 dest="/tmp"
+enable_dump=false
 
 while [[ $# -gt 0 ]]; do
   key="$1"
@@ -52,6 +56,10 @@
       fi
       shift 2
       ;;
+    -e|--enable_dump)
+      enable_dump=true
+      shift
+      ;;
     -h|--help)
       echo "$help"
       exit
@@ -65,6 +73,12 @@
 
 echo "Using destination directory $dest"
 
+if [ $enable_dump = true ]; then
+  id=$(basename $dest)
+  printf -v f_id "%08d" $id
+  dir=$"obmcdump_"$f_id"_$(date +"%s")"
+fi
+
 mkdir -p "$dest/$dir"
 
 for ((i=0;i<${#arr[@]};i+=2)); do