/*ARGSUSED*/ int fp_uuid( void *obj, int bit, int count, char *fmtstr, int size, int arg, int base, int array) { char bp[40]; /* UUID string is 36 chars + trailing '\0' */ int i; uuid_t *p; ASSERT(bitoffs(bit) == 0); for (p = (uuid_t *)((char *)obj + byteize(bit)), i = 0; i < count && !seenint(); i++, p++) { if (array) dbprintf("%d:", i + base); platform_uuid_unparse(p, bp); dbprintf("%s", bp); if (i < count - 1) dbprintf(" "); } return 1; }
static int header_check_uuid(xfs_mount_t *mp, xlog_rec_header_t *head) { char uu_log[64], uu_sb[64]; if (print_skip_uuid) return 0; if (!platform_uuid_compare(&mp->m_sb.sb_uuid, &head->h_fs_uuid)) return 0; platform_uuid_unparse(&mp->m_sb.sb_uuid, uu_sb); platform_uuid_unparse(&head->h_fs_uuid, uu_log); printf(_("* ERROR: mismatched uuid in log\n" "* SB : %s\n* log: %s\n"), uu_sb, uu_log); memcpy(&mp->m_sb.sb_uuid, &head->h_fs_uuid, sizeof(uuid_t)); return 0; }
static int uuid_f( int argc, char **argv) { char bp[40]; xfs_agnumber_t agno; uuid_t uu; uuid_t *uup = NULL; if (argc != 1 && argc != 2) { dbprintf(_("invalid parameters\n")); return 0; } if (argc == 2) { /* WRITE UUID */ if ((x.isreadonly & LIBXFS_ISREADONLY) || !expert_mode) { dbprintf(_("%s: not in expert mode, writing disabled\n"), progname); return 0; } if (!strcasecmp(argv[1], "generate")) { platform_uuid_generate(&uu); } else if (!strcasecmp(argv[1], "nil")) { platform_uuid_clear(&uu); } else if (!strcasecmp(argv[1], "rewrite")) { uup = do_uuid(0, NULL); if (!uup) { dbprintf(_("failed to read UUID from AG 0\n")); return 0; } memcpy(&uu, uup, sizeof(uuid_t)); platform_uuid_unparse(&uu, bp); dbprintf(_("old UUID = %s\n"), bp); } else if (!strcasecmp(argv[1], "restore")) { xfs_sb_t tsb; if (!get_sb(0, &tsb)) return 0; /* Not set; nothing to do. Success! */ if (!xfs_sb_version_hasmetauuid(&tsb)) return 0; memcpy(&uu, mp->m_sb.sb_meta_uuid, sizeof(uuid_t)); } else { if (platform_uuid_parse(argv[1], &uu)) { dbprintf(_("invalid UUID\n")); return 0; } } /* clear the log (setting uuid) if it's not dirty */ if (!sb_logzero(&uu)) return 0; dbprintf(_("writing all SBs\n")); for (agno = 0; agno < mp->m_sb.sb_agcount; agno++) if (!do_uuid(agno, &uu)) { dbprintf(_("failed to set UUID in AG %d\n"), agno); break; } platform_uuid_unparse(&uu, bp); dbprintf(_("new UUID = %s\n"), bp); return 0; } else { /* READ+CHECK UUID */ for (agno = 0; agno < mp->m_sb.sb_agcount; agno++) { uup = do_uuid(agno, NULL); if (!uup) { dbprintf(_("failed to read UUID from AG %d\n"), agno); return 0; } if (agno) { if (memcmp(&uu, uup, sizeof(uuid_t))) { dbprintf(_("warning: UUID in AG %d " "differs to the primary SB\n"), agno); break; } } else { memcpy(&uu, uup, sizeof(uuid_t)); } } if (mp->m_sb.sb_logstart) { if (x.logdev && x.logdev != x.ddev) dbprintf(_("warning - external log specified " "for FS with an internal log\n")); } else if (!x.logdev || (x.logdev == x.ddev)) { dbprintf(_("warning - no external log specified " "for FS with an external log\n")); } platform_uuid_unparse(&uu, bp); dbprintf(_("UUID = %s\n"), bp); } return 0; }
int xlog_print_rec_head(xlog_rec_header_t *head, int *len, int bad_hdr_warn) { int i; char uub[64]; int datalen,bbs; if (print_no_print) return be32_to_cpu(head->h_num_logops); if (!head->h_magicno) return ZEROED_LOG; if (be32_to_cpu(head->h_magicno) != XLOG_HEADER_MAGIC_NUM) { if (bad_hdr_warn) printf(_("Header 0x%x wanted 0x%x\n"), be32_to_cpu(head->h_magicno), XLOG_HEADER_MAGIC_NUM); return BAD_HEADER; } /* check for cleared blocks written by xlog_clear_stale_blocks() */ if (!head->h_len && !head->h_crc && !head->h_prev_block && !head->h_num_logops && !head->h_size) return CLEARED_BLKS; datalen=be32_to_cpu(head->h_len); bbs=BTOBB(datalen); printf(_("cycle: %d version: %d "), be32_to_cpu(head->h_cycle), be32_to_cpu(head->h_version)); print_lsn(" lsn", &head->h_lsn); print_lsn(" tail_lsn", &head->h_tail_lsn); printf("\n"); printf(_("length of Log Record: %d prev offset: %d num ops: %d\n"), datalen, be32_to_cpu(head->h_prev_block), be32_to_cpu(head->h_num_logops)); if (print_overwrite) { printf(_("cycle num overwrites: ")); for (i=0; i< MIN(bbs, XLOG_HEADER_CYCLE_SIZE / BBSIZE); i++) printf("%d - 0x%x ", i, be32_to_cpu(head->h_cycle_data[i])); printf("\n"); } platform_uuid_unparse(&head->h_fs_uuid, uub); printf(_("uuid: %s format: "), uub); switch (be32_to_cpu(head->h_fmt)) { case XLOG_FMT_UNKNOWN: printf(_("unknown\n")); break; case XLOG_FMT_LINUX_LE: printf(_("little endian linux\n")); break; case XLOG_FMT_LINUX_BE: printf(_("big endian linux\n")); break; case XLOG_FMT_IRIX_BE: printf(_("big endian irix\n")); break; default: printf("? (%d)\n", be32_to_cpu(head->h_fmt)); break; } printf(_("h_size: %d\n"), be32_to_cpu(head->h_size)); *len = be32_to_cpu(head->h_len); return(be32_to_cpu(head->h_num_logops)); } /* xlog_print_rec_head */