Merge master.kernel.org:/pub/scm/linux/kernel/git/herbert/crypto-2.6
[linux-drm-fsl-dcu.git] / Documentation / accounting / getdelays.c
index e9126e794ed7c04c19c42fb318dd36295d8806da..71acc28ed0d1b8b6b3692362bcf9d6ef4d7fcd02 100644 (file)
@@ -61,8 +61,6 @@ __u64 stime, utime;
 #define MAX_MSG_SIZE   1024
 /* Maximum number of cpus expected to be specified in a cpumask */
 #define MAX_CPUS       32
-/* Maximum length of pathname to log file */
-#define MAX_FILENAME   256
 
 struct msgtemplate {
        struct nlmsghdr n;
@@ -72,6 +70,16 @@ struct msgtemplate {
 
 char cpumask[100+6*MAX_CPUS];
 
+static void usage(void)
+{
+       fprintf(stderr, "getdelays [-dilv] [-w logfile] [-r bufsize] "
+                       "[-m cpumask] [-t tgid] [-p pid]\n");
+       fprintf(stderr, "  -d: print delayacct stats\n");
+       fprintf(stderr, "  -i: print IO accounting (works only with -p)\n");
+       fprintf(stderr, "  -l: listen forever\n");
+       fprintf(stderr, "  -v: debug on\n");
+}
+
 /*
  * Create a raw netlink socket and bind
  */
@@ -221,13 +229,13 @@ int main(int argc, char *argv[])
        int count = 0;
        int write_file = 0;
        int maskset = 0;
-       char logfile[128];
+       char *logfile = NULL;
        int loop = 0;
 
        struct msgtemplate msg;
 
        while (1) {
-               c = getopt(argc, argv, "diw:r:m:t:p:v:l");
+               c = getopt(argc, argv, "diw:r:m:t:p:vl");
                if (c < 0)
                        break;
 
@@ -241,7 +249,7 @@ int main(int argc, char *argv[])
                        print_io_accounting = 1;
                        break;
                case 'w':
-                       strncpy(logfile, optarg, MAX_FILENAME);
+                       logfile = strdup(optarg);
                        printf("write to file %s\n", logfile);
                        write_file = 1;
                        break;
@@ -277,7 +285,7 @@ int main(int argc, char *argv[])
                        loop = 1;
                        break;
                default:
-                       printf("Unknown option %d\n", c);
+                       usage();
                        exit(-1);
                }
        }