+int is_fstype_ext(int fd)
+{
+ struct statfs st;
+ int rc;
+
+ rc = fstatfs(fd, &st);
+ if (rc < 0) {
+ llapi_error(LLAPI_MSG_ERROR, rc, "Got statfs error.");
+ return -errno;
+ }
+
+ return (st.f_type == EXT4_SUPER_MAGIC);
+}
+
+
+/**
+ * Attempt to display a path to the object (file) containing changelog entries,
+ * referred to by this changelog_catalog record.
+ *
+ * This path depends on the implementation of the OSD device; zfs-osd and
+ * ldiskfs-osd are different.
+ *
+ * Assumes that if the file system containing the changelog_catalog is
+ * ext{2,3,4}, the backend is ldiskfs-osd; otherwise it is either zfs-osd or at
+ * least names objects based on FID and the zfs-osd path (which includes the
+ * FID) will be sufficient.
+ *
+ * The Object ID stored in the record is also displayed untranslated.
+ */
+#define OSD_OI_FID_NR (1UL << 7)
+static void print_log_path(struct llog_logid_rec *lid, int is_ext)
+{
+
+ char object_path[255];
+ struct lu_fid fid_from_logid;
+
+ logid_to_fid(&lid->lid_id, &fid_from_logid);
+
+ if (is_ext)
+ snprintf(object_path, sizeof(object_path),
+ "O/%ju/d%u/%u", (uintmax_t)fid_from_logid.f_seq,
+ fid_from_logid.f_oid % 32,
+ fid_from_logid.f_oid);
+ else
+ snprintf(object_path, sizeof(object_path),
+ "oi.%ju/"DFID_NOBRACE,
+ (uintmax_t)(fid_from_logid.f_seq & (OSD_OI_FID_NR - 1)),
+ PFID(&fid_from_logid));
+
+ printf("id="DFID":%x path=%s\n",
+ PFID(&lid->lid_id.lgl_oi.oi_fid), lid->lid_id.lgl_ogen,
+ object_path);
+}
+