2 * Copyright (c) 2000-2003,2005 Silicon Graphics, Inc.
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License as
7 * published by the Free Software Foundation.
9 * This program is distributed in the hope that it would be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write the Free Software Foundation,
16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
23 #define CLEARED_BLKS (-5)
24 #define ZEROED_LOG (-4)
25 #define FULL_READ (-3)
26 #define PARTIAL_READ (-2)
27 #define BAD_HEADER (-1)
31 char *trans_type
[] = {
78 typedef struct xlog_split_item
{
79 struct xlog_split_item
*si_next
;
80 struct xlog_split_item
*si_prev
;
85 xlog_split_item_t
*split_list
= NULL
;
88 print_xlog_op_line(void)
90 printf("--------------------------------------"
91 "--------------------------------------\n");
92 } /* print_xlog_op_line */
95 print_xlog_xhdr_line(void)
97 printf("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
98 "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n");
99 } /* print_xlog_xhdr_line */
102 print_xlog_record_line(void)
104 printf("======================================"
105 "======================================\n");
106 } /* print_xlog_record_line */
111 printf("***********************************"
112 "***********************************\n");
116 * Given a pointer to a data segment, print out the data as if it were
117 * a log operation header.
120 xlog_print_op_header(xlog_op_header_t
*op_head
,
124 xlog_op_header_t hbuf
;
127 * memmove because on 64/n32, partial reads can cause the op_head
128 * pointer to come in pointing to an odd-numbered byte
130 memmove(&hbuf
, op_head
, sizeof(xlog_op_header_t
));
132 *ptr
+= sizeof(xlog_op_header_t
);
133 printf(_("Oper (%d): tid: %x len: %d clientid: %s "), i
,
134 be32_to_cpu(op_head
->oh_tid
),
135 be32_to_cpu(op_head
->oh_len
),
136 (op_head
->oh_clientid
== XFS_TRANSACTION
? "TRANS" :
137 (op_head
->oh_clientid
== XFS_LOG
? "LOG" : "ERROR")));
138 printf(_("flags: "));
139 if (op_head
->oh_flags
) {
140 if (op_head
->oh_flags
& XLOG_START_TRANS
)
142 if (op_head
->oh_flags
& XLOG_COMMIT_TRANS
)
144 if (op_head
->oh_flags
& XLOG_WAS_CONT_TRANS
)
146 if (op_head
->oh_flags
& XLOG_UNMOUNT_TRANS
)
148 if (op_head
->oh_flags
& XLOG_CONTINUE_TRANS
)
150 if (op_head
->oh_flags
& XLOG_END_TRANS
)
156 } /* xlog_print_op_header */
160 xlog_print_add_to_trans(xlog_tid_t tid
,
163 xlog_split_item_t
*item
;
165 item
= (xlog_split_item_t
*)calloc(sizeof(xlog_split_item_t
), 1);
167 item
->si_skip
= skip
;
168 item
->si_next
= split_list
;
169 item
->si_prev
= NULL
;
171 split_list
->si_prev
= item
;
173 } /* xlog_print_add_to_trans */
177 xlog_print_find_tid(xlog_tid_t tid
, uint was_cont
)
179 xlog_split_item_t
*listp
= split_list
;
182 if (was_cont
!= 0) /* Not first time we have used this tid */
188 if (listp
->si_xtid
== tid
)
190 listp
= listp
->si_next
;
195 if (--listp
->si_skip
== 0) {
196 if (listp
== split_list
) { /* delete at head */
197 split_list
= listp
->si_next
;
199 split_list
->si_prev
= NULL
;
202 listp
->si_next
->si_prev
= listp
->si_prev
;
203 listp
->si_prev
->si_next
= listp
->si_next
;
208 } /* xlog_print_find_tid */
211 xlog_print_trans_header(char **ptr
, int len
)
213 xfs_trans_header_t
*h
;
216 char *magic_c
= (char *)&magic
;
220 magic
=*(__uint32_t
*)cptr
; /* XXX be32_to_cpu soon */
223 #if __BYTE_ORDER == __LITTLE_ENDIAN
225 magic_c
[3], magic_c
[2], magic_c
[1], magic_c
[0]);
228 magic_c
[0], magic_c
[1], magic_c
[2], magic_c
[3]);
231 if (len
!= sizeof(xfs_trans_header_t
)) {
232 printf(_(" Not enough data to decode further\n"));
235 h
= (xfs_trans_header_t
*)cptr
;
236 printf(_(" type: %s tid: %x num_items: %d\n"),
237 trans_type
[h
->th_type
], h
->th_tid
, h
->th_num_items
);
239 } /* xlog_print_trans_header */
243 xlog_print_trans_buffer(char **ptr
, int len
, int *i
, int num_ops
)
245 xfs_buf_log_format_t
*f
;
246 xlog_op_header_t
*head
= NULL
;
249 int bucket
, col
, buckets
;
251 xfs_buf_log_format_t lbuf
;
252 int size
, blen
, map_size
, struct_size
;
254 unsigned short flags
;
257 * memmove to ensure 8-byte alignment for the long longs in
258 * buf_log_format_t structure
260 memmove(&lbuf
, *ptr
, MIN(sizeof(xfs_buf_log_format_t
), len
));
264 ASSERT(f
->blf_type
== XFS_LI_BUF
);
266 blkno
= f
->blf_blkno
;
269 map_size
= f
->blf_map_size
;
270 flags
= f
->blf_flags
;
273 * size of the format header is dependent on the size of the bitmap, not
274 * the size of the in-memory structure. Hence the slightly obtuse
277 struct_size
= offsetof(struct xfs_buf_log_format
, blf_map_size
) + map_size
;
279 if (len
>= struct_size
) {
280 ASSERT((len
- sizeof(struct_size
)) % sizeof(int) == 0);
281 printf(_("#regs: %d start blkno: %lld (0x%llx) len: %d bmap size: %d flags: 0x%x\n"),
282 size
, (long long)blkno
, (unsigned long long)blkno
, blen
, map_size
, flags
);
286 ASSERT(len
>= 4); /* must have at least 4 bytes if != 0 */
287 printf(_("#regs: %d Not printing rest of data\n"), f
->blf_size
);
292 /* Check if all regions in this log item were in the given LR ptr */
293 if (*i
+num
> num_ops
-1) {
294 skip
= num
- (num_ops
-1-*i
);
301 head
= (xlog_op_header_t
*)*ptr
;
302 xlog_print_op_header(head
, *i
, ptr
);
304 printf(_("SUPER BLOCK Buffer: "));
305 if (be32_to_cpu(head
->oh_len
) < 4*8) {
306 printf(_("Out of space\n"));
310 * memmove because *ptr may not be 8-byte aligned
312 memmove(&x
, *ptr
, sizeof(__be64
));
313 memmove(&y
, *ptr
+8, sizeof(__be64
));
314 printf(_("icount: %llu ifree: %llu "),
315 (unsigned long long) be64_to_cpu(x
),
316 (unsigned long long) be64_to_cpu(y
));
317 memmove(&x
, *ptr
+16, sizeof(__be64
));
318 memmove(&y
, *ptr
+24, sizeof(__be64
));
319 printf(_("fdblks: %llu frext: %llu\n"),
320 (unsigned long long) be64_to_cpu(x
),
321 (unsigned long long) be64_to_cpu(y
));
324 } else if (be32_to_cpu(*(__be32
*)(*ptr
)) == XFS_AGI_MAGIC
) {
325 struct xfs_agi
*agi
, agi_s
;
327 /* memmove because *ptr may not be 8-byte aligned */
329 memmove(agi
, *ptr
, sizeof(struct xfs_agi
));
330 printf(_("AGI Buffer: XAGI "));
332 * v4 filesystems only contain the fields before the uuid.
333 * Even v5 filesystems don't log any field beneath it. That
334 * means that the size that is logged is almost always going to
335 * be smaller than the structure itself. Hence we need to make
336 * sure that the buffer contains all the data we want to print
337 * rather than just check against the structure size.
339 if (be32_to_cpu(head
->oh_len
) < offsetof(xfs_agi_t
, agi_uuid
) -
340 XFS_AGI_UNLINKED_BUCKETS
*sizeof(xfs_agino_t
)) {
341 printf(_("out of space\n"));
344 printf(_("ver: %d "),
345 be32_to_cpu(agi
->agi_versionnum
));
346 printf(_("seq#: %d len: %d cnt: %d root: %d\n"),
347 be32_to_cpu(agi
->agi_seqno
),
348 be32_to_cpu(agi
->agi_length
),
349 be32_to_cpu(agi
->agi_count
),
350 be32_to_cpu(agi
->agi_root
));
351 printf(_("level: %d free#: 0x%x newino: 0x%x\n"),
352 be32_to_cpu(agi
->agi_level
),
353 be32_to_cpu(agi
->agi_freecount
),
354 be32_to_cpu(agi
->agi_newino
));
355 if (be32_to_cpu(head
->oh_len
) == 128) {
357 } else if (be32_to_cpu(head
->oh_len
) == 256) {
360 if (head
->oh_flags
& XLOG_CONTINUE_TRANS
) {
361 printf(_("AGI unlinked data skipped "));
362 printf(_("(CONTINUE set, no space)\n"));
365 buckets
= XFS_AGI_UNLINKED_BUCKETS
;
367 for (bucket
= 0; bucket
< buckets
;) {
368 printf(_("bucket[%d - %d]: "), bucket
, bucket
+3);
369 for (col
= 0; col
< 4; col
++, bucket
++) {
370 if (bucket
< buckets
) {
372 be32_to_cpu(agi
->agi_unlinked
[bucket
]));
378 } else if (be32_to_cpu(*(__be32
*)(*ptr
)) == XFS_AGF_MAGIC
) {
379 struct xfs_agf
*agf
, agf_s
;
381 /* memmove because *ptr may not be 8-byte aligned */
383 memmove(agf
, *ptr
, sizeof(struct xfs_agf
));
384 printf(_("AGF Buffer: XAGF "));
386 * v4 filesystems only contain the fields before the uuid.
387 * Even v5 filesystems don't log any field beneath it. That
388 * means that the size that is logged is almost always going to
389 * be smaller than the structure itself. Hence we need to make
390 * sure that the buffer contains all the data we want to print
391 * rather than just check against the structure size.
393 if (be32_to_cpu(head
->oh_len
) < offsetof(xfs_agf_t
, agf_uuid
)) {
394 printf(_("Out of space\n"));
397 printf(_("ver: %d seq#: %d len: %d \n"),
398 be32_to_cpu(agf
->agf_versionnum
),
399 be32_to_cpu(agf
->agf_seqno
),
400 be32_to_cpu(agf
->agf_length
));
401 printf(_("root BNO: %d CNT: %d\n"),
402 be32_to_cpu(agf
->agf_roots
[XFS_BTNUM_BNOi
]),
403 be32_to_cpu(agf
->agf_roots
[XFS_BTNUM_CNTi
]));
404 printf(_("level BNO: %d CNT: %d\n"),
405 be32_to_cpu(agf
->agf_levels
[XFS_BTNUM_BNOi
]),
406 be32_to_cpu(agf
->agf_levels
[XFS_BTNUM_CNTi
]));
407 printf(_("1st: %d last: %d cnt: %d "
408 "freeblks: %d longest: %d\n"),
409 be32_to_cpu(agf
->agf_flfirst
),
410 be32_to_cpu(agf
->agf_fllast
),
411 be32_to_cpu(agf
->agf_flcount
),
412 be32_to_cpu(agf
->agf_freeblks
),
413 be32_to_cpu(agf
->agf_longest
));
415 } else if (be32_to_cpu(*(__be32
*)(*ptr
)) == XFS_DQUOT_MAGIC
) {
416 struct xfs_disk_dquot
*dq
, dq_s
;
418 /* memmove because *ptr may not be 8-byte aligned */
420 memmove(dq
, *ptr
, sizeof(struct xfs_disk_dquot
));
421 printf(_("DQUOT Buffer: DQ "));
422 if (be32_to_cpu(head
->oh_len
) <
423 sizeof(xfs_disk_dquot_t
)) {
424 printf(_("Out of space\n"));
428 printf(_("ver: %d flags: 0x%x id: %d \n"),
429 dq
->d_version
, dq
->d_flags
,
430 be32_to_cpu(dq
->d_id
));
431 printf(_("blk limits hard: %llu soft: %llu\n"),
433 be64_to_cpu(dq
->d_blk_hardlimit
),
435 be64_to_cpu(dq
->d_blk_softlimit
));
436 printf(_("blk count: %llu warns: %d timer: %d\n"),
437 (unsigned long long) be64_to_cpu(dq
->d_bcount
),
438 (int) be16_to_cpu(dq
->d_bwarns
),
439 be32_to_cpu(dq
->d_btimer
));
440 printf(_("ino limits hard: %llu soft: %llu\n"),
442 be64_to_cpu(dq
->d_ino_hardlimit
),
444 be64_to_cpu(dq
->d_ino_softlimit
));
445 printf(_("ino count: %llu warns: %d timer: %d\n"),
446 (unsigned long long) be64_to_cpu(dq
->d_icount
),
447 (int) be16_to_cpu(dq
->d_iwarns
),
448 be32_to_cpu(dq
->d_itimer
));
451 printf(_("BUF DATA\n"));
453 uint
*dp
= (uint
*)*ptr
;
454 int nums
= be32_to_cpu(head
->oh_len
) >> 2;
469 *ptr
+= be32_to_cpu(head
->oh_len
);
471 if (head
&& head
->oh_flags
& XLOG_CONTINUE_TRANS
)
474 } /* xlog_print_trans_buffer */
478 xlog_print_trans_efd(char **ptr
, uint len
)
480 xfs_efd_log_format_t
*f
;
481 xfs_efd_log_format_t lbuf
;
482 /* size without extents at end */
483 uint core_size
= sizeof(xfs_efd_log_format_t
) - sizeof(xfs_extent_t
);
486 * memmove to ensure 8-byte alignment for the long longs in
487 * xfs_efd_log_format_t structure
489 memmove(&lbuf
, *ptr
, MIN(core_size
, len
));
492 if (len
>= core_size
) {
493 printf(_("EFD: #regs: %d num_extents: %d id: 0x%llx\n"),
494 f
->efd_size
, f
->efd_nextents
, (unsigned long long)f
->efd_efi_id
);
496 /* don't print extents as they are not used */
500 printf(_("EFD: Not enough data to decode further\n"));
503 } /* xlog_print_trans_efd */
507 xlog_print_trans_efi(
512 xfs_efi_log_format_t
*src_f
, *f
= NULL
;
517 int core_size
= offsetof(xfs_efi_log_format_t
, efi_extents
);
520 * memmove to ensure 8-byte alignment for the long longs in
521 * xfs_efi_log_format_t structure
523 if ((src_f
= (xfs_efi_log_format_t
*)malloc(src_len
)) == NULL
) {
524 fprintf(stderr
, _("%s: xlog_print_trans_efi: malloc failed\n"), progname
);
527 memmove((char*)src_f
, *ptr
, src_len
);
530 /* convert to native format */
531 dst_len
= sizeof(xfs_efi_log_format_t
) + (src_f
->efi_nextents
- 1) * sizeof(xfs_extent_t
);
533 if (continued
&& src_len
< core_size
) {
534 printf(_("EFI: Not enough data to decode further\n"));
539 if ((f
= (xfs_efi_log_format_t
*)malloc(dst_len
)) == NULL
) {
540 fprintf(stderr
, _("%s: xlog_print_trans_efi: malloc failed\n"), progname
);
543 if (xfs_efi_copy_format((char*)src_f
, src_len
, f
, continued
)) {
548 printf(_("EFI: #regs: %d num_extents: %d id: 0x%llx\n"),
549 f
->efi_size
, f
->efi_nextents
, (unsigned long long)f
->efi_id
);
552 printf(_("EFI free extent data skipped (CONTINUE set, no space)\n"));
557 for (i
=0; i
< f
->efi_nextents
; i
++) {
558 printf("(s: 0x%llx, l: %d) ",
559 (unsigned long long)ex
->ext_start
, ex
->ext_len
);
560 if (i
% 4 == 3) printf("\n");
563 if (i
% 4 != 0) printf("\n");
568 } /* xlog_print_trans_efi */
572 xlog_print_trans_qoff(char **ptr
, uint len
)
574 xfs_qoff_logformat_t
*f
;
575 xfs_qoff_logformat_t lbuf
;
577 memmove(&lbuf
, *ptr
, MIN(sizeof(xfs_qoff_logformat_t
), len
));
580 if (len
>= sizeof(xfs_qoff_logformat_t
)) {
581 printf(_("QOFF: #regs: %d flags: 0x%x\n"), f
->qf_size
, f
->qf_flags
);
584 printf(_("QOFF: Not enough data to decode further\n"));
587 } /* xlog_print_trans_qoff */
591 xlog_print_trans_inode_core(xfs_icdinode_t
*ip
)
593 printf(_("INODE CORE\n"));
594 printf(_("magic 0x%hx mode 0%ho version %d format %d\n"),
595 ip
->di_magic
, ip
->di_mode
, (int)ip
->di_version
,
597 printf(_("nlink %hd uid %d gid %d\n"),
598 ip
->di_nlink
, ip
->di_uid
, ip
->di_gid
);
599 printf(_("atime 0x%x mtime 0x%x ctime 0x%x\n"),
600 ip
->di_atime
.t_sec
, ip
->di_mtime
.t_sec
, ip
->di_ctime
.t_sec
);
601 printf(_("size 0x%llx nblocks 0x%llx extsize 0x%x nextents 0x%x\n"),
602 (unsigned long long)ip
->di_size
, (unsigned long long)ip
->di_nblocks
,
603 ip
->di_extsize
, ip
->di_nextents
);
604 printf(_("naextents 0x%x forkoff %d dmevmask 0x%x dmstate 0x%hx\n"),
605 ip
->di_anextents
, (int)ip
->di_forkoff
, ip
->di_dmevmask
,
607 printf(_("flags 0x%x gen 0x%x\n"),
608 ip
->di_flags
, ip
->di_gen
);
614 xfs_dir2_sf_hdr_t
*sfp
,
621 xfs_dir2_sf_entry_t
*sfep
;
623 printf(_("SHORTFORM DIRECTORY size %d\n"),
625 /* bail out for now */
629 printf(_("SHORTFORM DIRECTORY size %d count %d\n"),
631 memmove(&ino
, &(sfp
->parent
), sizeof(ino
));
632 printf(_(".. ino 0x%llx\n"), (unsigned long long) be64_to_cpu(ino
));
635 sfep
= xfs_dir2_sf_firstentry(sfp
);
636 for (i
= 0; i
< count
; i
++) {
637 ino
= M_DIROPS(log
->l_mp
)->sf_get_ino(sfp
, sfep
);
638 memmove(namebuf
, (sfep
->name
), sfep
->namelen
);
639 namebuf
[sfep
->namelen
] = '\0';
640 printf(_("%s ino 0x%llx namelen %d\n"),
641 namebuf
, (unsigned long long)ino
, sfep
->namelen
);
642 sfep
= M_DIROPS(log
->l_mp
)->sf_nextentry(sfp
, sfep
);
647 xlog_print_trans_inode(
656 xlog_op_header_t
*op_head
;
657 xfs_inode_log_format_t dst_lbuf
;
658 xfs_inode_log_format_64_t src_lbuf
; /* buffer of biggest one */
659 xfs_inode_log_format_t
*f
;
664 * print inode type header region
666 * memmove to ensure 8-byte alignment for the long longs in
667 * xfs_inode_log_format_t structure
669 * len can be smaller than xfs_inode_log_format_32|64_t
670 * if format data is split over operations
672 memmove(&src_lbuf
, *ptr
, MIN(sizeof(xfs_inode_log_format_64_t
), len
));
673 (*i
)++; /* bump index */
676 (len
== sizeof(xfs_inode_log_format_32_t
) ||
677 len
== sizeof(xfs_inode_log_format_64_t
))) {
678 f
= xfs_inode_item_format_convert((char*)&src_lbuf
, len
, &dst_lbuf
);
679 printf(_("INODE: "));
680 printf(_("#regs: %d ino: 0x%llx flags: 0x%x dsize: %d\n"),
681 f
->ilf_size
, (unsigned long long)f
->ilf_ino
,
682 f
->ilf_fields
, f
->ilf_dsize
);
683 printf(_(" blkno: %lld len: %d boff: %d\n"),
684 (long long)f
->ilf_blkno
, f
->ilf_len
, f
->ilf_boffset
);
686 ASSERT(len
>= 4); /* must have at least 4 bytes if != 0 */
687 f
= (xfs_inode_log_format_t
*)&src_lbuf
;
688 printf(_("INODE: #regs: %d Not printing rest of data\n"),
693 if (*i
>= num_ops
) /* end of LR */
694 return f
->ilf_size
-1;
696 /* core inode comes 2nd */
697 op_head
= (xlog_op_header_t
*)*ptr
;
698 xlog_print_op_header(op_head
, *i
, ptr
);
700 if (op_head
->oh_flags
& XLOG_CONTINUE_TRANS
) {
701 return f
->ilf_size
-1;
704 memmove(&dino
, *ptr
, sizeof(dino
));
705 mode
= dino
.di_mode
& S_IFMT
;
706 size
= (int)dino
.di_size
;
707 xlog_print_trans_inode_core(&dino
);
708 *ptr
+= xfs_icdinode_size(dino
.di_version
);
710 if (*i
== num_ops
-1 && f
->ilf_size
== 3) {
714 /* does anything come next */
715 op_head
= (xlog_op_header_t
*)*ptr
;
717 switch (f
->ilf_fields
& (XFS_ILOG_DEV
| XFS_ILOG_UUID
)) {
719 printf(_("DEV inode: no extra region\n"));
722 printf(_("UUID inode: no extra region\n"));
726 /* Only the inode core is logged */
727 if (f
->ilf_size
== 2)
730 ASSERT(f
->ilf_size
<= 4);
731 ASSERT((f
->ilf_size
== 3) || (f
->ilf_fields
& XFS_ILOG_AFORK
));
733 if (f
->ilf_fields
& XFS_ILOG_DFORK
) {
735 xlog_print_op_header(op_head
, *i
, ptr
);
737 switch (f
->ilf_fields
& XFS_ILOG_DFORK
) {
739 printf(_("EXTENTS inode data\n"));
741 case XFS_ILOG_DBROOT
:
742 printf(_("BTREE inode data\n"));
745 printf(_("LOCAL inode data\n"));
747 xlog_print_dir2_sf(log
, (xfs_dir2_sf_hdr_t
*)*ptr
, size
);
750 ASSERT((f
->ilf_fields
& XFS_ILOG_DFORK
) == 0);
754 *ptr
+= be32_to_cpu(op_head
->oh_len
);
755 if (op_head
->oh_flags
& XLOG_CONTINUE_TRANS
)
757 op_head
= (xlog_op_header_t
*)*ptr
;
760 if (f
->ilf_fields
& XFS_ILOG_AFORK
) {
762 xlog_print_op_header(op_head
, *i
, ptr
);
764 switch (f
->ilf_fields
& XFS_ILOG_AFORK
) {
766 printf(_("EXTENTS attr data\n"));
768 case XFS_ILOG_ABROOT
:
769 printf(_("BTREE attr data\n"));
772 printf(_("LOCAL attr data\n"));
774 xlog_print_dir2_sf(log
, (xfs_dir2_sf_hdr_t
*)*ptr
, size
);
777 ASSERT((f
->ilf_fields
& XFS_ILOG_AFORK
) == 0);
780 *ptr
+= be32_to_cpu(op_head
->oh_len
);
781 if (op_head
->oh_flags
& XLOG_CONTINUE_TRANS
)
786 } /* xlog_print_trans_inode */
790 xlog_print_trans_dquot(char **ptr
, int len
, int *i
, int num_ops
)
792 xfs_dq_logformat_t
*f
;
793 xfs_dq_logformat_t lbuf
= {0};
794 xfs_disk_dquot_t ddq
;
795 xlog_op_header_t
*head
= NULL
;
799 * print dquot header region
801 * memmove to ensure 8-byte alignment for the long longs in
802 * xfs_dq_logformat_t structure
804 memmove(&lbuf
, *ptr
, MIN(sizeof(xfs_dq_logformat_t
), len
));
806 (*i
)++; /* bump index */
809 if (len
== sizeof(xfs_dq_logformat_t
)) {
810 printf(_("#regs: %d id: 0x%x"), f
->qlf_size
, f
->qlf_id
);
811 printf(_(" blkno: %lld len: %d boff: %d\n"),
812 (long long)f
->qlf_blkno
, f
->qlf_len
, f
->qlf_boffset
);
814 ASSERT(len
>= 4); /* must have at least 4 bytes if != 0 */
815 printf(_("DQUOT: #regs: %d Not printing rest of data\n"),
821 /* Check if all regions in this log item were in the given LR ptr */
822 if (*i
+num
> num_ops
-1) {
823 skip
= num
- (num_ops
-1-*i
);
830 head
= (xlog_op_header_t
*)*ptr
;
831 xlog_print_op_header(head
, *i
, ptr
);
832 ASSERT(be32_to_cpu(head
->oh_len
) == sizeof(xfs_disk_dquot_t
));
833 memmove(&ddq
, *ptr
, sizeof(xfs_disk_dquot_t
));
834 printf(_("DQUOT: magic 0x%hx flags 0%ho\n"),
835 be16_to_cpu(ddq
.d_magic
), ddq
.d_flags
);
836 *ptr
+= be32_to_cpu(head
->oh_len
);
838 if (head
&& head
->oh_flags
& XLOG_CONTINUE_TRANS
)
841 } /* xlog_print_trans_dquot */
845 xlog_print_trans_icreate(
851 struct xfs_icreate_log icl_buf
= {0};
852 struct xfs_icreate_log
*icl
;
854 memmove(&icl_buf
, *ptr
, MIN(sizeof(struct xfs_icreate_log
), len
));
858 /* handle complete header only */
859 if (len
!= sizeof(struct xfs_icreate_log
)) {
860 printf(_("ICR: split header, not printing\n"));
861 return 1; /* to skip leftover in next region */
864 printf(_("ICR: #ag: %d agbno: 0x%x len: %d\n"
865 " cnt: %d isize: %d gen: 0x%x\n"),
866 be32_to_cpu(icl
->icl_ag
), be32_to_cpu(icl
->icl_agbno
),
867 be32_to_cpu(icl
->icl_length
), be32_to_cpu(icl
->icl_count
),
868 be32_to_cpu(icl
->icl_isize
), be32_to_cpu(icl
->icl_gen
));
872 /******************************************************************************
876 ******************************************************************************
880 xlog_print_lseek(struct xlog
*log
, int fd
, xfs_daddr_t blkno
, int whence
)
882 #define BBTOOFF64(bbs) (((xfs_off_t)(bbs)) << BBSHIFT)
885 if (whence
== SEEK_SET
)
886 offset
= BBTOOFF64(blkno
+log
->l_logBBstart
);
888 offset
= BBTOOFF64(blkno
);
889 if (lseek64(fd
, offset
, whence
) < 0) {
890 fprintf(stderr
, _("%s: lseek64 to %lld failed: %s\n"),
891 progname
, (long long)offset
, strerror(errno
));
894 } /* xlog_print_lseek */
898 print_lsn(char *string
,
901 printf("%s: %u,%u", string
,
902 CYCLE_LSN(be64_to_cpu(*lsn
)), BLOCK_LSN(be64_to_cpu(*lsn
)));
914 xlog_rec_header_t
*rhead
,
915 xlog_rec_ext_header_t
*xhdrs
,
919 int read_len
, skip
, lost_context
= 0;
930 /* read_len must read up to some block boundary */
931 read_len
= (int) BBTOB(BTOBB(len
));
933 /* read_type => don't malloc() new buffer, use old one */
934 if (*read_type
== FULL_READ
) {
935 if ((ptr
= buf
= malloc(read_len
)) == NULL
) {
936 fprintf(stderr
, _("%s: xlog_print_record: malloc failed\n"), progname
);
940 read_len
-= *read_type
;
941 buf
= (char *)((intptr_t)(*partial_buf
) + (intptr_t)(*read_type
));
944 if ((ret
= (int) read(fd
, buf
, read_len
)) == -1) {
945 fprintf(stderr
, _("%s: xlog_print_record: read error\n"), progname
);
948 /* Did we overflow the end? */
949 if (*read_type
== FULL_READ
&&
950 BLOCK_LSN(be64_to_cpu(rhead
->h_lsn
)) + BTOBB(read_len
) >=
952 *read_type
= BBTOB(logBBsize
- BLOCK_LSN(be64_to_cpu(rhead
->h_lsn
))-1);
957 /* Did we read everything? */
958 if ((ret
== 0 && read_len
!= 0) || ret
!= read_len
) {
963 if (*read_type
!= FULL_READ
)
964 read_len
+= *read_type
;
966 /* Everything read in. Start from beginning of buffer
967 * Unpack the data, by putting the saved cycle-data back
968 * into the first word of each BB.
972 for (i
= 0; ptr
< buf
+ read_len
; ptr
+= BBSIZE
, i
++) {
973 xlog_rec_header_t
*rechead
= (xlog_rec_header_t
*)ptr
;
976 if (be32_to_cpu(rechead
->h_magicno
) == XLOG_HEADER_MAGIC_NUM
) {
977 /* data should not have magicno as first word
978 * as it should by cycle#
984 * FIXME: cycle+1 should be a macro pv#900369
986 if (be32_to_cpu(rhead
->h_cycle
) !=
987 be32_to_cpu(*(__be32
*)ptr
)) {
988 if ((*read_type
== FULL_READ
) ||
989 (be32_to_cpu(rhead
->h_cycle
) + 1 !=
990 be32_to_cpu(*(__be32
*)ptr
))) {
997 /* copy back the data from the header */
998 if (i
< XLOG_HEADER_CYCLE_SIZE
/ BBSIZE
) {
999 /* from 1st header */
1000 *(__be32
*)ptr
= rhead
->h_cycle_data
[i
];
1003 ASSERT(xhdrs
!= NULL
);
1004 /* from extra headers */
1005 j
= i
/ (XLOG_HEADER_CYCLE_SIZE
/ BBSIZE
);
1006 k
= i
% (XLOG_HEADER_CYCLE_SIZE
/ BBSIZE
);
1007 *(__be32
*)ptr
= xhdrs
[j
-1].xh_cycle_data
[k
];
1013 for (i
=0; i
<num_ops
; i
++) {
1016 xlog_op_header_t
*op_head
= (xlog_op_header_t
*)ptr
;
1018 print_xlog_op_line();
1019 xlog_print_op_header(op_head
, i
, &ptr
);
1020 continued
= ((op_head
->oh_flags
& XLOG_WAS_CONT_TRANS
) ||
1021 (op_head
->oh_flags
& XLOG_CONTINUE_TRANS
));
1023 if (continued
&& be32_to_cpu(op_head
->oh_len
) == 0)
1026 if (print_no_data
) {
1027 for (n
= 0; n
< be32_to_cpu(op_head
->oh_len
); n
++) {
1028 printf("0x%02x ", (unsigned int)*ptr
);
1037 /* print transaction data */
1038 if (xlog_print_find_tid(be32_to_cpu(op_head
->oh_tid
),
1039 op_head
->oh_flags
& XLOG_WAS_CONT_TRANS
)) {
1040 printf(_("Left over region from split log item\n"));
1041 /* Skip this leftover bit */
1042 ptr
+= be32_to_cpu(op_head
->oh_len
);
1043 /* We've lost context; don't complain if next one looks bad too */
1048 if (be32_to_cpu(op_head
->oh_len
) != 0) {
1049 if (*(uint
*)ptr
== XFS_TRANS_HEADER_MAGIC
) {
1050 skip
= xlog_print_trans_header(&ptr
,
1051 be32_to_cpu(op_head
->oh_len
));
1053 switch (*(unsigned short *)ptr
) {
1055 skip
= xlog_print_trans_buffer(&ptr
,
1056 be32_to_cpu(op_head
->oh_len
),
1060 case XFS_LI_ICREATE
: {
1061 skip
= xlog_print_trans_icreate(&ptr
,
1062 be32_to_cpu(op_head
->oh_len
),
1066 case XFS_LI_INODE
: {
1067 skip
= xlog_print_trans_inode(log
, &ptr
,
1068 be32_to_cpu(op_head
->oh_len
),
1069 &i
, num_ops
, continued
);
1072 case XFS_LI_DQUOT
: {
1073 skip
= xlog_print_trans_dquot(&ptr
,
1074 be32_to_cpu(op_head
->oh_len
),
1079 skip
= xlog_print_trans_efi(&ptr
,
1080 be32_to_cpu(op_head
->oh_len
),
1085 skip
= xlog_print_trans_efd(&ptr
,
1086 be32_to_cpu(op_head
->oh_len
));
1089 case XFS_LI_QUOTAOFF
: {
1090 skip
= xlog_print_trans_qoff(&ptr
,
1091 be32_to_cpu(op_head
->oh_len
));
1094 case XLOG_UNMOUNT_TYPE
: {
1095 printf(_("Unmount filesystem\n"));
1100 if (bad_hdr_warn
&& !lost_context
) {
1102 _("%s: unknown log operation type (%x)\n"),
1103 progname
, *(unsigned short *)ptr
);
1110 _("Left over region from split log item\n"));
1113 ptr
+= be32_to_cpu(op_head
->oh_len
);
1119 xlog_print_add_to_trans(be32_to_cpu(op_head
->oh_tid
), skip
);
1125 } /* xlog_print_record */
1129 xlog_print_rec_head(xlog_rec_header_t
*head
, int *len
, int bad_hdr_warn
)
1136 return be32_to_cpu(head
->h_num_logops
);
1138 if (!head
->h_magicno
)
1141 if (be32_to_cpu(head
->h_magicno
) != XLOG_HEADER_MAGIC_NUM
) {
1143 printf(_("Header 0x%x wanted 0x%x\n"),
1144 be32_to_cpu(head
->h_magicno
),
1145 XLOG_HEADER_MAGIC_NUM
);
1149 /* check for cleared blocks written by xlog_clear_stale_blocks() */
1150 if (!head
->h_len
&& !head
->h_crc
&& !head
->h_prev_block
&&
1151 !head
->h_num_logops
&& !head
->h_size
)
1152 return CLEARED_BLKS
;
1154 datalen
=be32_to_cpu(head
->h_len
);
1157 printf(_("cycle: %d version: %d "),
1158 be32_to_cpu(head
->h_cycle
),
1159 be32_to_cpu(head
->h_version
));
1160 print_lsn(" lsn", &head
->h_lsn
);
1161 print_lsn(" tail_lsn", &head
->h_tail_lsn
);
1163 printf(_("length of Log Record: %d prev offset: %d num ops: %d\n"),
1165 be32_to_cpu(head
->h_prev_block
),
1166 be32_to_cpu(head
->h_num_logops
));
1168 if (print_overwrite
) {
1169 printf(_("cycle num overwrites: "));
1170 for (i
=0; i
< MIN(bbs
, XLOG_HEADER_CYCLE_SIZE
/ BBSIZE
); i
++)
1171 printf("%d - 0x%x ",
1173 be32_to_cpu(head
->h_cycle_data
[i
]));
1177 platform_uuid_unparse(&head
->h_fs_uuid
, uub
);
1178 printf(_("uuid: %s format: "), uub
);
1179 switch (be32_to_cpu(head
->h_fmt
)) {
1180 case XLOG_FMT_UNKNOWN
:
1181 printf(_("unknown\n"));
1183 case XLOG_FMT_LINUX_LE
:
1184 printf(_("little endian linux\n"));
1186 case XLOG_FMT_LINUX_BE
:
1187 printf(_("big endian linux\n"));
1189 case XLOG_FMT_IRIX_BE
:
1190 printf(_("big endian irix\n"));
1193 printf("? (%d)\n", be32_to_cpu(head
->h_fmt
));
1196 printf(_("h_size: %d\n"), be32_to_cpu(head
->h_size
));
1198 *len
= be32_to_cpu(head
->h_len
);
1199 return(be32_to_cpu(head
->h_num_logops
));
1200 } /* xlog_print_rec_head */
1203 xlog_print_rec_xhead(xlog_rec_ext_header_t
*head
, int coverage
)
1207 print_xlog_xhdr_line();
1208 printf(_("extended-header: cycle: %d\n"), be32_to_cpu(head
->xh_cycle
));
1210 if (print_overwrite
) {
1211 printf(_("cycle num overwrites: "));
1212 for (i
= 0; i
< coverage
; i
++)
1213 printf("%d - 0x%x ",
1215 be32_to_cpu(head
->xh_cycle_data
[i
]));
1218 } /* xlog_print_rec_xhead */
1221 print_xlog_bad_zeroed(xfs_daddr_t blkno
)
1224 printf(_("* ERROR: found data after zeroed blocks block=%-21lld *\n"),
1228 xlog_exit("Bad log - data after zeroed blocks");
1229 } /* print_xlog_bad_zeroed */
1232 print_xlog_bad_header(xfs_daddr_t blkno
, char *buf
)
1235 printf(_("* ERROR: header cycle=%-11d block=%-21lld *\n"),
1236 xlog_get_cycle(buf
), (long long)blkno
);
1239 xlog_exit("Bad log record header");
1240 } /* print_xlog_bad_header */
1243 print_xlog_bad_data(xfs_daddr_t blkno
)
1246 printf(_("* ERROR: data block=%-21lld *\n"),
1250 xlog_exit("Bad data in log");
1251 } /* print_xlog_bad_data */
1254 print_xlog_bad_reqd_hdrs(xfs_daddr_t blkno
, int num_reqd
, int num_hdrs
)
1257 printf(_("* ERROR: for header block=%lld\n"
1258 "* not enough hdrs for data length, "
1259 "required num = %d, hdr num = %d\n"),
1260 (long long)blkno
, num_reqd
, num_hdrs
);
1263 xlog_exit(_("Not enough headers for data length."));
1264 } /* print_xlog_bad_reqd_hdrs */
1267 xlog_reallocate_xhdrs(int num_hdrs
, xlog_rec_ext_header_t
**ret_xhdrs
)
1269 int len
= (num_hdrs
-1) * sizeof(xlog_rec_ext_header_t
);
1271 *ret_xhdrs
= (xlog_rec_ext_header_t
*)realloc(*ret_xhdrs
, len
);
1272 if (*ret_xhdrs
== NULL
) {
1273 fprintf(stderr
, _("%s: xlog_print: malloc failed for ext hdrs\n"), progname
);
1278 /* for V2 logs read each extra hdr and print it out */
1280 xlog_print_extended_headers(
1284 xlog_rec_header_t
*hdr
,
1286 xlog_rec_ext_header_t
**ret_xhdrs
)
1292 char xhbuf
[XLOG_HEADER_SIZE
];
1293 xlog_rec_ext_header_t
*x
;
1295 num_required
= howmany(len
, XLOG_HEADER_CYCLE_SIZE
);
1296 num_hdrs
= be32_to_cpu(hdr
->h_size
) / XLOG_HEADER_CYCLE_SIZE
;
1297 if (be32_to_cpu(hdr
->h_size
) % XLOG_HEADER_CYCLE_SIZE
)
1300 if (num_required
> num_hdrs
) {
1301 print_xlog_bad_reqd_hdrs((*blkno
)-1, num_required
, num_hdrs
);
1304 if (num_hdrs
== 1) {
1311 if (*ret_xhdrs
== NULL
|| num_hdrs
> *ret_num_hdrs
) {
1312 xlog_reallocate_xhdrs(num_hdrs
, ret_xhdrs
);
1315 *ret_num_hdrs
= num_hdrs
;
1317 /* don't include 1st header */
1318 for (i
= 1, x
= *ret_xhdrs
; i
< num_hdrs
; i
++, (*blkno
)++, x
++) {
1319 /* read one extra header blk */
1320 if (read(fd
, xhbuf
, 512) == 0) {
1321 printf(_("%s: physical end of log\n"), progname
);
1322 print_xlog_record_line();
1323 /* reached the end so return 1 */
1326 if (print_only_data
) {
1327 printf(_("BLKNO: %lld\n"), (long long)*blkno
);
1328 xlog_recover_print_data(xhbuf
, 512);
1331 if (i
== num_hdrs
- 1) {
1333 coverage_bb
= BTOBB(len
) %
1334 (XLOG_HEADER_CYCLE_SIZE
/ BBSIZE
);
1337 /* earliear header */
1338 coverage_bb
= XLOG_HEADER_CYCLE_SIZE
/ BBSIZE
;
1340 xlog_print_rec_xhead((xlog_rec_ext_header_t
*)xhbuf
, coverage_bb
);
1343 /* Copy from buffer into xhdrs array for later.
1344 * Could endian convert here but then code later on
1345 * will look asymmetric with the 1 hdr normal case
1346 * which does endian coversion on access.
1348 x
->xh_cycle
= ((xlog_rec_ext_header_t
*)xhbuf
)->xh_cycle
;
1349 for (j
= 0; j
< XLOG_HEADER_CYCLE_SIZE
/ BBSIZE
; j
++) {
1350 x
->xh_cycle_data
[j
] =
1351 ((xlog_rec_ext_header_t
*)xhbuf
)->xh_cycle_data
[j
];
1359 * This code is gross and needs to be rewritten.
1361 void xfs_log_print(struct xlog
*log
,
1363 int print_block_start
)
1365 char hbuf
[XLOG_HEADER_SIZE
];
1366 xlog_rec_header_t
*hdr
= (xlog_rec_header_t
*)&hbuf
[0];
1367 xlog_rec_ext_header_t
*xhdrs
= NULL
;
1368 int num_ops
, len
, num_hdrs
= 1;
1369 xfs_daddr_t block_end
= 0, block_start
, blkno
, error
;
1370 xfs_daddr_t zeroed_blkno
= 0, cleared_blkno
= 0;
1371 int read_type
= FULL_READ
;
1375 int first_hdr_found
= 0;
1377 logBBsize
= log
->l_logBBsize
;
1380 * Normally, block_start and block_end are the same value since we
1381 * are printing the entire log. However, if the start block is given,
1382 * we still end at the end of the logical log.
1384 if ((error
= xlog_print_find_oldest(log
, &block_end
))) {
1385 fprintf(stderr
, _("%s: problem finding oldest LR\n"), progname
);
1388 if (print_block_start
== -1)
1389 block_start
= block_end
;
1391 block_start
= print_block_start
;
1392 xlog_print_lseek(log
, fd
, block_start
, SEEK_SET
);
1393 blkno
= block_start
;
1396 if (read(fd
, hbuf
, 512) == 0) {
1397 printf(_("%s: physical end of log\n"), progname
);
1398 print_xlog_record_line();
1401 if (print_only_data
) {
1402 printf(_("BLKNO: %lld\n"), (long long)blkno
);
1403 xlog_recover_print_data(hbuf
, 512);
1407 num_ops
= xlog_print_rec_head(hdr
, &len
, first_hdr_found
);
1410 if (zeroed
&& num_ops
!= ZEROED_LOG
) {
1411 printf(_("%s: after %d zeroed blocks\n"), progname
, zeroed
);
1412 /* once we find zeroed blocks - that's all we expect */
1413 print_xlog_bad_zeroed(blkno
-1);
1414 /* reset count since we're assuming previous zeroed blocks
1420 if (num_ops
== ZEROED_LOG
||
1421 num_ops
== CLEARED_BLKS
||
1422 num_ops
== BAD_HEADER
) {
1423 if (num_ops
== ZEROED_LOG
) {
1425 zeroed_blkno
= blkno
-1;
1428 else if (num_ops
== CLEARED_BLKS
) {
1430 cleared_blkno
= blkno
-1;
1433 if (!first_hdr_found
)
1434 block_start
= blkno
;
1436 print_xlog_bad_header(blkno
-1, hbuf
);
1442 if (be32_to_cpu(hdr
->h_version
) == 2) {
1443 if (xlog_print_extended_headers(fd
, len
, &blkno
, hdr
, &num_hdrs
, &xhdrs
) != 0)
1447 error
= xlog_print_record(log
, fd
, num_ops
, len
, &read_type
, &partial_buf
,
1448 hdr
, xhdrs
, first_hdr_found
);
1452 blkno
+= BTOBB(len
);
1453 if (print_block_start
!= -1 &&
1454 blkno
>= block_end
) /* If start specified, we */
1455 goto end
; /* end early */
1459 print_xlog_bad_data(blkno
-1);
1460 if (print_block_start
!= -1 &&
1461 blkno
>= block_end
) /* If start specified, */
1462 goto end
; /* we end early */
1463 xlog_print_lseek(log
, fd
, blkno
, SEEK_SET
);
1466 case PARTIAL_READ
: {
1467 print_xlog_record_line();
1468 printf(_("%s: physical end of log\n"), progname
);
1469 print_xlog_record_line();
1471 xlog_print_lseek(log
, fd
, 0, SEEK_SET
);
1473 * We may have hit the end of the log when we started at 0.
1474 * In this case, just end.
1476 if (block_start
== 0)
1478 goto partial_log_read
;
1480 default: xlog_panic(_("illegal value"));
1482 print_xlog_record_line();
1484 if (blkno
>= logBBsize
) {
1486 printf(_("%s: skipped %d cleared blocks in range: %lld - %lld\n"),
1488 (long long)(cleared_blkno
),
1489 (long long)(cleared
+ cleared_blkno
- 1));
1490 if (cleared
== logBBsize
)
1491 printf(_("%s: totally cleared log\n"), progname
);
1496 printf(_("%s: skipped %d zeroed blocks in range: %lld - %lld\n"),
1498 (long long)(zeroed_blkno
),
1499 (long long)(zeroed
+ zeroed_blkno
- 1));
1500 if (zeroed
== logBBsize
)
1501 printf(_("%s: totally zeroed log\n"), progname
);
1505 printf(_("%s: physical end of log\n"), progname
);
1506 print_xlog_record_line();
1511 /* Do we need to print the first part of physical log? */
1512 if (block_start
!= 0) {
1514 xlog_print_lseek(log
, fd
, 0, SEEK_SET
);
1516 if (read(fd
, hbuf
, 512) == 0) {
1517 xlog_panic(_("xlog_find_head: bad read"));
1519 if (print_only_data
) {
1520 printf(_("BLKNO: %lld\n"), (long long)blkno
);
1521 xlog_recover_print_data(hbuf
, 512);
1525 num_ops
= xlog_print_rec_head(hdr
, &len
, first_hdr_found
);
1528 if (num_ops
== ZEROED_LOG
||
1529 num_ops
== CLEARED_BLKS
||
1530 num_ops
== BAD_HEADER
) {
1531 /* we only expect zeroed log entries or cleared log
1532 * entries at the end of the _physical_ log,
1533 * so treat them the same as bad blocks here
1535 print_xlog_bad_header(blkno
-1, hbuf
);
1537 if (blkno
>= block_end
)
1542 if (be32_to_cpu(hdr
->h_version
) == 2) {
1543 if (xlog_print_extended_headers(fd
, len
, &blkno
, hdr
, &num_hdrs
, &xhdrs
) != 0)
1548 error
= xlog_print_record(log
, fd
, num_ops
, len
, &read_type
,
1549 &partial_buf
, (xlog_rec_header_t
*)hbuf
,
1550 xhdrs
, first_hdr_found
);
1551 if (read_type
!= FULL_READ
)
1553 read_type
= FULL_READ
;
1555 blkno
+= BTOBB(len
);
1557 print_xlog_bad_data(blkno
-1);
1558 xlog_print_lseek(log
, fd
, blkno
, SEEK_SET
);
1561 print_xlog_record_line();
1563 if (blkno
>= block_end
)
1569 printf(_("%s: logical end of log\n"), progname
);
1570 print_xlog_record_line();
1574 * if necessary, convert an xfs_inode_log_format struct from 32bit or 64 bit versions
1575 * (which can have different field alignments) to the native version
1577 xfs_inode_log_format_t
*
1578 xfs_inode_item_format_convert(char *src_buf
, uint len
, xfs_inode_log_format_t
*in_f
)
1580 /* if we have native format then just return buf without copying data */
1581 if (len
== sizeof(xfs_inode_log_format_t
)) {
1582 return (xfs_inode_log_format_t
*)src_buf
;
1585 if (len
== sizeof(xfs_inode_log_format_32_t
)) {
1586 xfs_inode_log_format_32_t
*in_f32
;
1588 in_f32
= (xfs_inode_log_format_32_t
*)src_buf
;
1589 in_f
->ilf_type
= in_f32
->ilf_type
;
1590 in_f
->ilf_size
= in_f32
->ilf_size
;
1591 in_f
->ilf_fields
= in_f32
->ilf_fields
;
1592 in_f
->ilf_asize
= in_f32
->ilf_asize
;
1593 in_f
->ilf_dsize
= in_f32
->ilf_dsize
;
1594 in_f
->ilf_ino
= in_f32
->ilf_ino
;
1596 memcpy(&in_f
->ilf_u
.ilfu_uuid
, &in_f32
->ilf_u
.ilfu_uuid
, sizeof(uuid_t
));
1597 in_f
->ilf_blkno
= in_f32
->ilf_blkno
;
1598 in_f
->ilf_len
= in_f32
->ilf_len
;
1599 in_f
->ilf_boffset
= in_f32
->ilf_boffset
;
1601 xfs_inode_log_format_64_t
*in_f64
;
1603 ASSERT(len
== sizeof(xfs_inode_log_format_64_t
));
1604 in_f64
= (xfs_inode_log_format_64_t
*)src_buf
;
1605 in_f
->ilf_type
= in_f64
->ilf_type
;
1606 in_f
->ilf_size
= in_f64
->ilf_size
;
1607 in_f
->ilf_fields
= in_f64
->ilf_fields
;
1608 in_f
->ilf_asize
= in_f64
->ilf_asize
;
1609 in_f
->ilf_dsize
= in_f64
->ilf_dsize
;
1610 in_f
->ilf_ino
= in_f64
->ilf_ino
;
1612 memcpy(&in_f
->ilf_u
.ilfu_uuid
, &in_f64
->ilf_u
.ilfu_uuid
, sizeof(uuid_t
));
1613 in_f
->ilf_blkno
= in_f64
->ilf_blkno
;
1614 in_f
->ilf_len
= in_f64
->ilf_len
;
1615 in_f
->ilf_boffset
= in_f64
->ilf_boffset
;
1621 xfs_efi_copy_format(
1624 struct xfs_efi_log_format
*dst_efi_fmt
,
1628 uint nextents
= ((xfs_efi_log_format_t
*)buf
)->efi_nextents
;
1629 uint dst_len
= sizeof(xfs_efi_log_format_t
) + (nextents
- 1) * sizeof(xfs_extent_t
);
1630 uint len32
= sizeof(xfs_efi_log_format_32_t
) + (nextents
- 1) * sizeof(xfs_extent_32_t
);
1631 uint len64
= sizeof(xfs_efi_log_format_64_t
) + (nextents
- 1) * sizeof(xfs_extent_64_t
);
1633 if (len
== dst_len
|| continued
) {
1634 memcpy((char *)dst_efi_fmt
, buf
, len
);
1636 } else if (len
== len32
) {
1637 xfs_efi_log_format_32_t
*src_efi_fmt_32
= (xfs_efi_log_format_32_t
*)buf
;
1639 dst_efi_fmt
->efi_type
= src_efi_fmt_32
->efi_type
;
1640 dst_efi_fmt
->efi_size
= src_efi_fmt_32
->efi_size
;
1641 dst_efi_fmt
->efi_nextents
= src_efi_fmt_32
->efi_nextents
;
1642 dst_efi_fmt
->efi_id
= src_efi_fmt_32
->efi_id
;
1643 for (i
= 0; i
< dst_efi_fmt
->efi_nextents
; i
++) {
1644 dst_efi_fmt
->efi_extents
[i
].ext_start
=
1645 src_efi_fmt_32
->efi_extents
[i
].ext_start
;
1646 dst_efi_fmt
->efi_extents
[i
].ext_len
=
1647 src_efi_fmt_32
->efi_extents
[i
].ext_len
;
1650 } else if (len
== len64
) {
1651 xfs_efi_log_format_64_t
*src_efi_fmt_64
= (xfs_efi_log_format_64_t
*)buf
;
1653 dst_efi_fmt
->efi_type
= src_efi_fmt_64
->efi_type
;
1654 dst_efi_fmt
->efi_size
= src_efi_fmt_64
->efi_size
;
1655 dst_efi_fmt
->efi_nextents
= src_efi_fmt_64
->efi_nextents
;
1656 dst_efi_fmt
->efi_id
= src_efi_fmt_64
->efi_id
;
1657 for (i
= 0; i
< dst_efi_fmt
->efi_nextents
; i
++) {
1658 dst_efi_fmt
->efi_extents
[i
].ext_start
=
1659 src_efi_fmt_64
->efi_extents
[i
].ext_start
;
1660 dst_efi_fmt
->efi_extents
[i
].ext_len
=
1661 src_efi_fmt_64
->efi_extents
[i
].ext_len
;
1665 fprintf(stderr
, _("%s: bad size of efi format: %u; expected %u or %u; nextents = %u\n"),
1666 progname
, len
, len32
, len64
, nextents
);