Whamcloud - gitweb
LU-6179 llite: Implement ladvise lockahead
[fs/lustre-release.git] / lustre / utils / llog_reader.c
index 074684b..3548d25 100644 (file)
@@ -40,6 +40,7 @@
 #include <limits.h>
 #include <stdbool.h>
 #include <stdio.h>
+#include <stdlib.h>
 #include <string.h>
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <linux/magic.h>
 #include <errno.h>
 #include <time.h>
-#include <lnet/nidstr.h>
-#include <lustre/lustre_idl.h>
+#include <linux/lnet/nidstr.h>
+#include <linux/lustre/lustre_cfg.h>
+#include <linux/lustre/lustre_fid.h>
+#include <linux/lustre/lustre_ostid.h>
+#include <linux/lustre/lustre_log_user.h>
 #include <lustre/lustreapi.h>
-#include <lustre_log_user.h>
-#include <lustre_cfg.h>
 
 static inline int ext2_test_bit(int nr, const void *addr)
 {
@@ -152,9 +154,9 @@ static void print_log_path(struct llog_logid_rec *lid, int is_ext)
                         (uintmax_t)(fid_from_logid.f_seq & (OSD_OI_FID_NR - 1)),
                         PFID(&fid_from_logid));
 
-       printf("ogen=%X id="DOSTID" path=%s\n",
-               lid->lid_id.lgl_ogen, POSTID(&lid->lid_id.lgl_oi),
-               object_path);
+       printf("id="DFID":%x path=%s\n",
+              PFID(&lid->lid_id.lgl_oi.oi_fid), lid->lid_id.lgl_ogen,
+              object_path);
 }
 
 int main(int argc, char **argv)
@@ -376,6 +378,38 @@ static void print_1_cfg(struct lustre_cfg *lcfg)
         return;
 }
 
+static char *lustre_cfg_string(struct lustre_cfg *lcfg, __u32 index)
+{
+       char *s;
+
+       if (lcfg->lcfg_buflens[index] == 0)
+               return NULL;
+
+       s = lustre_cfg_buf(lcfg, index);
+       if (s == NULL)
+               return NULL;
+
+       /*
+        * make sure it's NULL terminated, even if this kills a char
+        * of data. Try to use the padding first though.
+        */
+       if (s[lcfg->lcfg_buflens[index] - 1] != '\0') {
+               size_t last = __ALIGN_KERNEL(lcfg->lcfg_buflens[index], 8) - 1;
+               char lost;
+
+               /* Use the smaller value */
+               if (last > lcfg->lcfg_buflens[index])
+                       last = lcfg->lcfg_buflens[index];
+
+               lost = s[last];
+               s[last] = '\0';
+               if (lost != '\0') {
+                       fprintf(stderr, "Truncated buf %d to '%s' (lost '%c'...)\n",
+                               index, s, lost);
+               }
+       }
+       return s;
+}
 
 static void print_setup_cfg(struct lustre_cfg *lcfg)
 {