X-Git-Url: https://git.whamcloud.com/?a=blobdiff_plain;f=lustre%2Futils%2Fllog_reader.c;h=3548d25f24a75aeb4dc49e3208d78198a5eb8c0f;hb=a8dcf372f430c308d3e96fb506563068d0a80c2d;hp=c5922c14aa5bb8d132408a4efaf6d5ec23f76339;hpb=0d5a9a777adfb014ff04830d3bdc249561233e88;p=fs%2Flustre-release.git diff --git a/lustre/utils/llog_reader.c b/lustre/utils/llog_reader.c index c5922c1..3548d25 100644 --- a/lustre/utils/llog_reader.c +++ b/lustre/utils/llog_reader.c @@ -15,11 +15,7 @@ * * You should have received a copy of the GNU General Public License * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf - * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. + * http://www.gnu.org/licenses/gpl-2.0.html * * GPL HEADER END */ @@ -27,7 +23,7 @@ * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved. * Use is subject to license terms. * - * Copyright (c) 2011, 2015, Intel Corporation. + * Copyright (c) 2011, 2016, Intel Corporation. */ /* * This file is part of Lustre, http://www.lustre.org/ @@ -44,6 +40,7 @@ #include #include #include +#include #include #include #include @@ -56,11 +53,12 @@ #include #include #include -#include -#include +#include +#include +#include +#include +#include #include -#include -#include static inline int ext2_test_bit(int nr, const void *addr) { @@ -156,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) @@ -262,7 +260,7 @@ int llog_pack_buffer(int fd, struct llog_log_hdr **llog, } /* the llog header not countable here.*/ - recs_num = le32_to_cpu((*llog)->llh_count) - 1; + recs_num = __le32_to_cpu((*llog)->llh_count) - 1; recs_buf = malloc(recs_num * sizeof(**recs_pr)); if (recs_buf == NULL) { @@ -274,7 +272,7 @@ int llog_pack_buffer(int fd, struct llog_log_hdr **llog, } recs_pr = (struct llog_rec_hdr **)recs_buf; - ptr = file_buf + le32_to_cpu((*llog)->llh_hdr.lrh_len); + ptr = file_buf + __le32_to_cpu((*llog)->llh_hdr.lrh_len); i = 0; while (ptr < (file_buf + file_size)) { @@ -290,7 +288,7 @@ int llog_pack_buffer(int fd, struct llog_log_hdr **llog, } cur_rec = (struct llog_rec_hdr *)ptr; - idx = le32_to_cpu(cur_rec->lrh_index); + idx = __le32_to_cpu(cur_rec->lrh_index); recs_pr[i] = cur_rec; offset = (unsigned long)ptr - (unsigned long)file_buf; if (cur_rec->lrh_len == 0 || @@ -310,7 +308,7 @@ int llog_pack_buffer(int fd, struct llog_log_hdr **llog, i--; } - ptr += le32_to_cpu(cur_rec->lrh_len); + ptr += __le32_to_cpu(cur_rec->lrh_len); if ((ptr - file_buf) > file_size) { printf("The log is corrupt (too big at %d)\n", i); rc = -EINVAL; @@ -345,24 +343,24 @@ void llog_unpack_buffer(int fd, struct llog_log_hdr *llog_buf, void print_llog_header(struct llog_log_hdr *llog_buf) { - time_t t; + time_t t; - printf("Header size : %u\n", - le32_to_cpu(llog_buf->llh_hdr.lrh_len)); + printf("Header size : %u\n", + __le32_to_cpu(llog_buf->llh_hdr.lrh_len)); - t = le64_to_cpu(llog_buf->llh_timestamp); - printf("Time : %s", ctime(&t)); + t = __le64_to_cpu(llog_buf->llh_timestamp); + printf("Time : %s", ctime(&t)); - printf("Number of records: %u\n", - le32_to_cpu(llog_buf->llh_count)-1); + printf("Number of records: %u\n", + __le32_to_cpu(llog_buf->llh_count)-1); - printf("Target uuid : %s \n", - (char *)(&llog_buf->llh_tgtuuid)); + printf("Target uuid : %s\n", + (char *)(&llog_buf->llh_tgtuuid)); - /* Add the other info you want to view here */ + /* Add the other info you want to view here */ - printf("-----------------------\n"); - return; + printf("-----------------------\n"); + return; } static void print_1_cfg(struct lustre_cfg *lcfg) @@ -380,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) { @@ -407,7 +437,7 @@ static void print_setup_cfg(struct lustre_cfg *lcfg) void print_lustre_cfg(struct lustre_cfg *lcfg, int *skip) { - enum lcfg_command_type cmd = le32_to_cpu(lcfg->lcfg_command); + enum lcfg_command_type cmd = __le32_to_cpu(lcfg->lcfg_command); if (*skip > 0) printf("SKIP "); @@ -625,10 +655,10 @@ static void print_hsm_action(struct llog_agent_req_rec *larr) void print_changelog_rec(struct llog_changelog_rec *rec) { printf("changelog record id:0x%x cr_flags:0x%x cr_type:%s(0x%x)\n", - le32_to_cpu(rec->cr_hdr.lrh_id), - le32_to_cpu(rec->cr.cr_flags), - changelog_type2str(le32_to_cpu(rec->cr.cr_type)), - le32_to_cpu(rec->cr.cr_type)); + __le32_to_cpu(rec->cr_hdr.lrh_id), + __le32_to_cpu(rec->cr.cr_flags), + changelog_type2str(__le32_to_cpu(rec->cr.cr_type)), + __le32_to_cpu(rec->cr.cr_type)); } static void print_records(struct llog_rec_hdr **recs, @@ -638,10 +668,10 @@ static void print_records(struct llog_rec_hdr **recs, int i, skip = 0; for (i = 0; i < rec_number; i++) { - printf("#%.2d (%.3d)", le32_to_cpu(recs[i]->lrh_index), - le32_to_cpu(recs[i]->lrh_len)); + printf("#%.2d (%.3d)", __le32_to_cpu(recs[i]->lrh_index), + __le32_to_cpu(recs[i]->lrh_len)); - lopt = le32_to_cpu(recs[i]->lrh_type); + lopt = __le32_to_cpu(recs[i]->lrh_type); if (recs[i]->lrh_id == CANCELLED) printf("NOT SET "); @@ -668,7 +698,7 @@ static void print_records(struct llog_rec_hdr **recs, break; case CHANGELOG_USER_REC: printf("changelog_user record id:0x%x\n", - le32_to_cpu(recs[i]->lrh_id)); + __le32_to_cpu(recs[i]->lrh_id)); break; default: printf("unknown type %x\n", lopt);