Added ability to add device names from a file to blktrace.
authorAlan D. Brunelle <Alan.Brunelle@hp.com>
Mon, 26 Feb 2007 19:44:27 +0000 (20:44 +0100)
committerJens Axboe <axboe@carl.home.kernel.dk>
Mon, 26 Feb 2007 19:44:27 +0000 (20:44 +0100)
Added new argument to blktrace:

-I <devs file>

Where <devs file> has one device per line, each device is added to any
explicit -d arg, or the trailing device arguments.

Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
blktrace.c
doc/blktrace.tex

index 359cdad07c8ad014bf35714929a114a55dde9c24..2ad940d10f224653c43e5ca1e02ff97019fbadc8 100644 (file)
@@ -60,7 +60,7 @@ static char blktrace_version[] = "0.99.2";
 
 #define DEBUGFS_TYPE   0x64626720
 
-#define S_OPTS "d:a:A:r:o:kw:Vb:n:D:lh:p:s"
+#define S_OPTS "d:a:A:r:o:kw:Vb:n:D:lh:p:sI:"
 static struct option l_opts[] = {
        {
                .name = "dev",
@@ -68,6 +68,12 @@ static struct option l_opts[] = {
                .flag = NULL,
                .val = 'd'
        },
+       {
+               .name = "input-devs",
+               .has_arg = required_argument,
+               .flag = NULL,
+               .val = 'I'
+       },
        {
                .name = "act-mask",
                .has_arg = required_argument,
@@ -1749,7 +1755,7 @@ static int net_setup_client(void)
 
 static char usage_str[] = \
        "-d <dev> [ -r debugfs path ] [ -o <output> ] [-k ] [ -w time ]\n" \
-       "[ -a action ] [ -A action mask ] [ -v ]\n\n" \
+       "[ -a action ] [ -A action mask ] [ -I  <devs file> ] [ -v ]\n\n" \
        "\t-d Use specified device. May also be given last after options\n" \
        "\t-r Path to mounted debugfs, defaults to /sys/kernel/debug\n" \
        "\t-o File(s) to send output to\n" \
@@ -1764,6 +1770,7 @@ static char usage_str[] = \
        "\t-h Run in network client mode, connecting to the given host\n" \
        "\t-p Network port to use (default 8462)\n" \
        "\t-s Make the network client NOT use sendfile() to transfer data\n" \
+       "\t-I Add devices found in <devs file>\n" \
        "\t-V Print program version info\n\n";
 
 static void show_usage(char *program)
@@ -1807,6 +1814,24 @@ int main(int argc, char *argv[])
                                return 1;
                        break;
 
+               case 'I': {
+                       char dev_line[256];
+                       FILE *ifp = fopen(optarg, "r");
+
+                       if (!ifp) {
+                               fprintf(stderr, 
+                                       "Invalid file for devices %s\n", 
+                                       optarg);
+                               return 1;
+                       }
+
+                       while (fscanf(ifp, "%s\n", dev_line) == 1)
+                               if (resize_devices(strdup(dev_line)) != 0)
+                                       return 1;
+                       break;
+               }
+                       
+
                case 'r':
                        debugfs_path = optarg;
                        break;
index 02ae1aa2f1e50f11566c8dc14b7136bf1709df0b..0a83f4dfae1f444d4dcc94e56b167cd9b949a3e0 100644 (file)
@@ -21,7 +21,7 @@
 \title{blktrace User Guide}
 \author{blktrace: Jens Axboe (axboe@suse.de)\\
         User Guide: Alan D. Brunelle (Alan.Brunelle@hp.com)}
-\date{23 February 2005}
+\date{18 February 2007}
 
 \begin{document}
 \maketitle
@@ -393,6 +393,8 @@ Short              & Long                       & Description \\ \hline\hline
 -r \emph{rel-path} & --relay=\emph{rel-path}    & Specifies debugfs mount point \\ \hline
 -V                 & --version                  & Outputs version \\ \hline
 -w \emph{seconds}  & --stopwatch=\emph{seconds} & Sets run time to the number of seconds specified \\ \hline
+-I \emph{devs file}& --input-devs=\emph{devs file}& Adds devices found in \emph{devs file} to list of devices to trace. \\
+                   &                              & (One device per line.) \\ \hline
 \end{tabular}
 
 \subsubsection{\label{sec:filter-mask}Filter Masks}