Whamcloud - gitweb
LU-13099 lmv: disable statahead for remote objects
[fs/lustre-release.git] / lustre / utils / lr_reader.c
index c7717d5..f1072a2 100644 (file)
 #include <getopt.h>
 
 #include <asm/byteorder.h>
-#include <linux/lustre_disk.h>
-#include <lustre_ver.h>
+#include <linux/lustre/lustre_disk.h>
+#include <linux/lustre/lustre_ver.h>
 
 char *progname;
-static struct option const longopts[] = {
-       { "help", no_argument, 0, 'h' },
-       { "client", no_argument, 0, 'c' },
-       { "reply", no_argument, 0, 'r' },
-       { 0, 0, 0, 0}
-};
+static struct option const long_opts[] = {
+       { .val = 'c',   .name = "client",       .has_arg = no_argument },
+       { .val = 'h',   .name = "help",         .has_arg = no_argument },
+       { .val = 'r',   .name = "reply",        .has_arg = no_argument },
+       { .name = NULL } };
 
 /* Executes the command \a cmd and returns command status.
  */
@@ -87,10 +86,10 @@ int run_command(char *cmd, size_t cmdsz)
        fd = mkstemp(log);
        if (fd >= 0) {
                close(fd);
-               strncat(cmd, " >", 2);
-               strncat(cmd, log, strlen(log));
+               strncat(cmd, " >", cmdsz);
+               strncat(cmd, log, cmdsz);
        }
-       strncat(cmd, " 2>&1", 5);
+       strncat(cmd, " 2>&1", cmdsz - strlen(cmd));
 
        /* Can't use popen because we need the rv of the command */
        rc = system(cmd);
@@ -137,7 +136,7 @@ int main(int argc, char *const argv[])
        int opt_reply = 0;
 
        progname = argv[0];
-       while ((c = getopt_long(argc, argv, "chr", longopts, NULL)) != -1) {
+       while ((c = getopt_long(argc, argv, "chr", long_opts, NULL)) != -1) {
                switch (c) {
                case 'c':
                        opt_client = 1;
@@ -210,9 +209,11 @@ int main(int argc, char *const argv[])
        printf("  feature_compat: %#x\n", lsd.lsd_feature_compat);
        printf("  feature_incompat: %#x\n", lsd.lsd_feature_incompat);
        printf("  feature_rocompat: %#x\n", lsd.lsd_feature_rocompat);
-       printf("  last_transaction: %llu\n", lsd.lsd_last_transno);
+       printf("  last_transaction: %llu\n",
+              (unsigned long long)lsd.lsd_last_transno);
        printf("  target_index: %u\n", lsd.lsd_osd_index);
-       printf("  mount_count: %llu\n", lsd.lsd_mount_count);
+       printf("  mount_count: %llu\n",
+              (unsigned long long)lsd.lsd_mount_count);
 
        /* read client information */
        if (opt_client) {
@@ -260,8 +261,9 @@ int main(int argc, char *const argv[])
                        printf("\n  %.40s:\n", lcd.lcd_uuid);
                        printf("    generation: %u\n", lcd.lcd_generation);
                        printf("    last_transaction: %llu\n",
-                              lcd.lcd_last_transno);
-                       printf("    last_xid: %llu\n", lcd.lcd_last_xid);
+                              (unsigned long long)lcd.lcd_last_transno);
+                       printf("    last_xid: %llu\n",
+                              (unsigned long long)lcd.lcd_last_xid);
                        printf("    last_result: %u\n", lcd.lcd_last_result);
                        printf("    last_data: %u\n", lcd.lcd_last_data);
 
@@ -276,9 +278,9 @@ int main(int argc, char *const argv[])
                                lcd.lcd_last_close_data =
                                        __le32_to_cpu(lcd.lcd_last_close_data);
                                printf("    last_close_transation: %llu\n",
-                                      lcd.lcd_last_close_transno);
+                                      (unsigned long long)lcd.lcd_last_close_transno);
                                printf("    last_close_xid: %llu\n",
-                                      lcd.lcd_last_close_xid);
+                                      (unsigned long long)lcd.lcd_last_close_xid);
                                printf("    last_close_result: %u\n",
                                       lcd.lcd_last_close_result);
                                printf("    last_close_data: %u\n",
@@ -376,10 +378,13 @@ int main(int argc, char *const argv[])
                        printf("  %lld:\n", slot);
                        printf("    client_generation: %u\n",
                               lrd.lrd_client_gen);
-                       printf("    last_transaction: %llu\n", lrd.lrd_transno);
-                       printf("    last_xid: %llu\n", lrd.lrd_xid);
+                       printf("    last_transaction: %lluu\n",
+                              (unsigned long long)lrd.lrd_transno);
+                       printf("    last_xid: %llu\n",
+                              (unsigned long long)lrd.lrd_xid);
                        printf("    last_result: %u\n", lrd.lrd_result);
-                       printf("    last_data: %llu\n\n", lrd.lrd_data);
+                       printf("    last_data: %llu\n\n",
+                              (unsigned long long)lrd.lrd_data);
                }
        }