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
18 #include "xfs/libxfs.h"
19 #include "xfs/libxlog.h"
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_tid
== 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
;
248 xfs_disk_dquot_t
*dq
;
249 xlog_op_header_t
*head
= NULL
;
252 int bucket
, col
, buckets
;
254 xfs_buf_log_format_t lbuf
;
255 int size
, blen
, map_size
, struct_size
;
260 * memmove to ensure 8-byte alignment for the long longs in
261 * buf_log_format_t structure
263 memmove(&lbuf
, *ptr
, MIN(sizeof(xfs_buf_log_format_t
), len
));
267 ASSERT(f
->blf_type
== XFS_LI_BUF
);
269 blkno
= f
->blf_blkno
;
272 map_size
= f
->blf_map_size
;
273 flags
= f
->blf_flags
;
276 * size of the format header is dependent on the size of the bitmap, not
277 * the size of the in-memory structure. Hence the slightly obtuse
280 struct_size
= offsetof(struct xfs_buf_log_format
, blf_map_size
) + map_size
;
282 if (len
>= struct_size
) {
283 ASSERT((len
- sizeof(struct_size
)) % sizeof(int) == 0);
284 printf(_("#regs: %d start blkno: %lld (0x%llx) len: %d bmap size: %d flags: 0x%x\n"),
285 size
, (long long)blkno
, (unsigned long long)blkno
, blen
, map_size
, flags
);
289 ASSERT(len
>= 4); /* must have at least 4 bytes if != 0 */
290 printf(_("#regs: %d Not printing rest of data\n"), f
->blf_size
);
295 /* Check if all regions in this log item were in the given LR ptr */
296 if (*i
+num
> num_ops
-1) {
297 skip
= num
- (num_ops
-1-*i
);
304 head
= (xlog_op_header_t
*)*ptr
;
305 xlog_print_op_header(head
, *i
, ptr
);
307 printf(_("SUPER BLOCK Buffer: "));
308 if (be32_to_cpu(head
->oh_len
) < 4*8) {
309 printf(_("Out of space\n"));
313 * memmove because *ptr may not be 8-byte aligned
315 memmove(&x
, *ptr
, sizeof(__be64
));
316 memmove(&y
, *ptr
+8, sizeof(__be64
));
317 printf(_("icount: %llu ifree: %llu "),
318 (unsigned long long) be64_to_cpu(x
),
319 (unsigned long long) be64_to_cpu(y
));
320 memmove(&x
, *ptr
+16, sizeof(__be64
));
321 memmove(&y
, *ptr
+24, sizeof(__be64
));
322 printf(_("fdblks: %llu frext: %llu\n"),
323 (unsigned long long) be64_to_cpu(x
),
324 (unsigned long long) be64_to_cpu(y
));
327 } else if (be32_to_cpu(*(__be32
*)(*ptr
)) == XFS_AGI_MAGIC
) {
328 agi
= (xfs_agi_t
*)(*ptr
);
329 printf(_("AGI Buffer: XAGI "));
331 * v4 filesystems only contain the fields before the uuid.
332 * Even v5 filesystems don't log any field beneath it. That
333 * means that the size that is logged is almost always going to
334 * be smaller than the structure itself. Hence we need to make
335 * sure that the buffer contains all the data we want to print
336 * rather than just check against the structure size.
338 if (be32_to_cpu(head
->oh_len
) < offsetof(xfs_agi_t
, agi_uuid
) -
339 XFS_AGI_UNLINKED_BUCKETS
*sizeof(xfs_agino_t
)) {
340 printf(_("out of space\n"));
343 printf(_("ver: %d "),
344 be32_to_cpu(agi
->agi_versionnum
));
345 printf(_("seq#: %d len: %d cnt: %d root: %d\n"),
346 be32_to_cpu(agi
->agi_seqno
),
347 be32_to_cpu(agi
->agi_length
),
348 be32_to_cpu(agi
->agi_count
),
349 be32_to_cpu(agi
->agi_root
));
350 printf(_("level: %d free#: 0x%x newino: 0x%x\n"),
351 be32_to_cpu(agi
->agi_level
),
352 be32_to_cpu(agi
->agi_freecount
),
353 be32_to_cpu(agi
->agi_newino
));
354 if (be32_to_cpu(head
->oh_len
) == 128) {
356 } else if (be32_to_cpu(head
->oh_len
) == 256) {
359 if (head
->oh_flags
& XLOG_CONTINUE_TRANS
) {
360 printf(_("AGI unlinked data skipped "));
361 printf(_("(CONTINUE set, no space)\n"));
364 buckets
= XFS_AGI_UNLINKED_BUCKETS
;
366 for (bucket
= 0; bucket
< buckets
;) {
367 printf(_("bucket[%d - %d]: "), bucket
, bucket
+3);
368 for (col
= 0; col
< 4; col
++, bucket
++) {
369 if (bucket
< buckets
) {
371 be32_to_cpu(agi
->agi_unlinked
[bucket
]));
377 } else if (be32_to_cpu(*(__be32
*)(*ptr
)) == XFS_AGF_MAGIC
) {
378 agf
= (xfs_agf_t
*)(*ptr
);
379 printf(_("AGF Buffer: XAGF "));
381 * v4 filesystems only contain the fields before the uuid.
382 * Even v5 filesystems don't log any field beneath it. That
383 * means that the size that is logged is almost always going to
384 * be smaller than the structure itself. Hence we need to make
385 * sure that the buffer contains all the data we want to print
386 * rather than just check against the structure size.
388 if (be32_to_cpu(head
->oh_len
) < offsetof(xfs_agf_t
, agf_uuid
)) {
389 printf(_("Out of space\n"));
392 printf(_("ver: %d seq#: %d len: %d \n"),
393 be32_to_cpu(agf
->agf_versionnum
),
394 be32_to_cpu(agf
->agf_seqno
),
395 be32_to_cpu(agf
->agf_length
));
396 printf(_("root BNO: %d CNT: %d\n"),
397 be32_to_cpu(agf
->agf_roots
[XFS_BTNUM_BNOi
]),
398 be32_to_cpu(agf
->agf_roots
[XFS_BTNUM_CNTi
]));
399 printf(_("level BNO: %d CNT: %d\n"),
400 be32_to_cpu(agf
->agf_levels
[XFS_BTNUM_BNOi
]),
401 be32_to_cpu(agf
->agf_levels
[XFS_BTNUM_CNTi
]));
402 printf(_("1st: %d last: %d cnt: %d "
403 "freeblks: %d longest: %d\n"),
404 be32_to_cpu(agf
->agf_flfirst
),
405 be32_to_cpu(agf
->agf_fllast
),
406 be32_to_cpu(agf
->agf_flcount
),
407 be32_to_cpu(agf
->agf_freeblks
),
408 be32_to_cpu(agf
->agf_longest
));
410 } else if (be32_to_cpu(*(__be32
*)(*ptr
)) == XFS_DQUOT_MAGIC
) {
411 dq
= (xfs_disk_dquot_t
*)(*ptr
);
412 printf(_("DQUOT Buffer: DQ "));
413 if (be32_to_cpu(head
->oh_len
) <
414 sizeof(xfs_disk_dquot_t
)) {
415 printf(_("Out of space\n"));
419 printf(_("ver: %d flags: 0x%x id: %d \n"),
420 dq
->d_version
, dq
->d_flags
,
421 be32_to_cpu(dq
->d_id
));
422 printf(_("blk limits hard: %llu soft: %llu\n"),
424 be64_to_cpu(dq
->d_blk_hardlimit
),
426 be64_to_cpu(dq
->d_blk_softlimit
));
427 printf(_("blk count: %llu warns: %d timer: %d\n"),
428 (unsigned long long) be64_to_cpu(dq
->d_bcount
),
429 (int) be16_to_cpu(dq
->d_bwarns
),
430 be32_to_cpu(dq
->d_btimer
));
431 printf(_("ino limits hard: %llu soft: %llu\n"),
433 be64_to_cpu(dq
->d_ino_hardlimit
),
435 be64_to_cpu(dq
->d_ino_softlimit
));
436 printf(_("ino count: %llu warns: %d timer: %d\n"),
437 (unsigned long long) be64_to_cpu(dq
->d_icount
),
438 (int) be16_to_cpu(dq
->d_iwarns
),
439 be32_to_cpu(dq
->d_itimer
));
442 printf(_("BUF DATA\n"));
444 uint
*dp
= (uint
*)*ptr
;
445 int nums
= be32_to_cpu(head
->oh_len
) >> 2;
460 *ptr
+= be32_to_cpu(head
->oh_len
);
462 if (head
&& head
->oh_flags
& XLOG_CONTINUE_TRANS
)
465 } /* xlog_print_trans_buffer */
469 xlog_print_trans_efd(char **ptr
, uint len
)
471 xfs_efd_log_format_t
*f
;
472 xfs_efd_log_format_t lbuf
;
473 /* size without extents at end */
474 uint core_size
= sizeof(xfs_efd_log_format_t
) - sizeof(xfs_extent_t
);
477 * memmove to ensure 8-byte alignment for the long longs in
478 * xfs_efd_log_format_t structure
480 memmove(&lbuf
, *ptr
, MIN(core_size
, len
));
483 if (len
>= core_size
) {
484 printf(_("EFD: #regs: %d num_extents: %d id: 0x%llx\n"),
485 f
->efd_size
, f
->efd_nextents
, (unsigned long long)f
->efd_efi_id
);
487 /* don't print extents as they are not used */
491 printf(_("EFD: Not enough data to decode further\n"));
494 } /* xlog_print_trans_efd */
498 xlog_print_trans_efi(
503 xfs_efi_log_format_t
*src_f
, *f
= NULL
;
508 int core_size
= offsetof(xfs_efi_log_format_t
, efi_extents
);
511 * memmove to ensure 8-byte alignment for the long longs in
512 * xfs_efi_log_format_t structure
514 if ((src_f
= (xfs_efi_log_format_t
*)malloc(src_len
)) == NULL
) {
515 fprintf(stderr
, _("%s: xlog_print_trans_efi: malloc failed\n"), progname
);
518 memmove((char*)src_f
, *ptr
, src_len
);
521 /* convert to native format */
522 dst_len
= sizeof(xfs_efi_log_format_t
) + (src_f
->efi_nextents
- 1) * sizeof(xfs_extent_t
);
524 if (continued
&& src_len
< core_size
) {
525 printf(_("EFI: Not enough data to decode further\n"));
530 if ((f
= (xfs_efi_log_format_t
*)malloc(dst_len
)) == NULL
) {
531 fprintf(stderr
, _("%s: xlog_print_trans_efi: malloc failed\n"), progname
);
534 if (xfs_efi_copy_format((char*)src_f
, src_len
, f
, continued
)) {
539 printf(_("EFI: #regs: %d num_extents: %d id: 0x%llx\n"),
540 f
->efi_size
, f
->efi_nextents
, (unsigned long long)f
->efi_id
);
543 printf(_("EFI free extent data skipped (CONTINUE set, no space)\n"));
548 for (i
=0; i
< f
->efi_nextents
; i
++) {
549 printf("(s: 0x%llx, l: %d) ",
550 (unsigned long long)ex
->ext_start
, ex
->ext_len
);
551 if (i
% 4 == 3) printf("\n");
554 if (i
% 4 != 0) printf("\n");
559 } /* xlog_print_trans_efi */
563 xlog_print_trans_qoff(char **ptr
, uint len
)
565 xfs_qoff_logformat_t
*f
;
566 xfs_qoff_logformat_t lbuf
;
568 memmove(&lbuf
, *ptr
, MIN(sizeof(xfs_qoff_logformat_t
), len
));
571 if (len
>= sizeof(xfs_qoff_logformat_t
)) {
572 printf(_("QOFF: #regs: %d flags: 0x%x\n"), f
->qf_size
, f
->qf_flags
);
575 printf(_("QOFF: Not enough data to decode further\n"));
578 } /* xlog_print_trans_qoff */
582 xlog_print_trans_inode_core(xfs_icdinode_t
*ip
)
584 printf(_("INODE CORE\n"));
585 printf(_("magic 0x%hx mode 0%ho version %d format %d\n"),
586 ip
->di_magic
, ip
->di_mode
, (int)ip
->di_version
,
588 printf(_("nlink %hd uid %d gid %d\n"),
589 ip
->di_nlink
, ip
->di_uid
, ip
->di_gid
);
590 printf(_("atime 0x%x mtime 0x%x ctime 0x%x\n"),
591 ip
->di_atime
.t_sec
, ip
->di_mtime
.t_sec
, ip
->di_ctime
.t_sec
);
592 printf(_("size 0x%llx nblocks 0x%llx extsize 0x%x nextents 0x%x\n"),
593 (unsigned long long)ip
->di_size
, (unsigned long long)ip
->di_nblocks
,
594 ip
->di_extsize
, ip
->di_nextents
);
595 printf(_("naextents 0x%x forkoff %d dmevmask 0x%x dmstate 0x%hx\n"),
596 ip
->di_anextents
, (int)ip
->di_forkoff
, ip
->di_dmevmask
,
598 printf(_("flags 0x%x gen 0x%x\n"),
599 ip
->di_flags
, ip
->di_gen
);
605 xfs_dir2_sf_hdr_t
*sfp
,
612 xfs_dir2_sf_entry_t
*sfep
;
614 printf(_("SHORTFORM DIRECTORY size %d\n"),
616 /* bail out for now */
620 printf(_("SHORTFORM DIRECTORY size %d count %d\n"),
622 memmove(&ino
, &(sfp
->parent
), sizeof(ino
));
623 printf(_(".. ino 0x%llx\n"), (unsigned long long) be64_to_cpu(ino
));
626 sfep
= xfs_dir2_sf_firstentry(sfp
);
627 for (i
= 0; i
< count
; i
++) {
628 ino
= M_DIROPS(log
->l_mp
)->sf_get_ino(sfp
, sfep
);
629 memmove(namebuf
, (sfep
->name
), sfep
->namelen
);
630 namebuf
[sfep
->namelen
] = '\0';
631 printf(_("%s ino 0x%llx namelen %d\n"),
632 namebuf
, (unsigned long long)ino
, sfep
->namelen
);
633 sfep
= M_DIROPS(log
->l_mp
)->sf_nextentry(sfp
, sfep
);
638 xlog_print_trans_inode(
647 xlog_op_header_t
*op_head
;
648 xfs_inode_log_format_t dst_lbuf
;
649 xfs_inode_log_format_64_t src_lbuf
; /* buffer of biggest one */
650 xfs_inode_log_format_t
*f
;
655 * print inode type header region
657 * memmove to ensure 8-byte alignment for the long longs in
658 * xfs_inode_log_format_t structure
660 * len can be smaller than xfs_inode_log_format_32|64_t
661 * if format data is split over operations
663 memmove(&src_lbuf
, *ptr
, MIN(sizeof(xfs_inode_log_format_64_t
), len
));
664 (*i
)++; /* bump index */
667 (len
== sizeof(xfs_inode_log_format_32_t
) ||
668 len
== sizeof(xfs_inode_log_format_64_t
))) {
669 f
= xfs_inode_item_format_convert((char*)&src_lbuf
, len
, &dst_lbuf
);
670 printf(_("INODE: "));
671 printf(_("#regs: %d ino: 0x%llx flags: 0x%x dsize: %d\n"),
672 f
->ilf_size
, (unsigned long long)f
->ilf_ino
,
673 f
->ilf_fields
, f
->ilf_dsize
);
674 printf(_(" blkno: %lld len: %d boff: %d\n"),
675 (long long)f
->ilf_blkno
, f
->ilf_len
, f
->ilf_boffset
);
677 ASSERT(len
>= 4); /* must have at least 4 bytes if != 0 */
678 f
= (xfs_inode_log_format_t
*)&src_lbuf
;
679 printf(_("INODE: #regs: %d Not printing rest of data\n"),
684 if (*i
>= num_ops
) /* end of LR */
685 return f
->ilf_size
-1;
687 /* core inode comes 2nd */
688 op_head
= (xlog_op_header_t
*)*ptr
;
689 xlog_print_op_header(op_head
, *i
, ptr
);
691 if (op_head
->oh_flags
& XLOG_CONTINUE_TRANS
) {
692 return f
->ilf_size
-1;
695 memmove(&dino
, *ptr
, sizeof(dino
));
696 mode
= dino
.di_mode
& S_IFMT
;
697 size
= (int)dino
.di_size
;
698 xlog_print_trans_inode_core(&dino
);
699 *ptr
+= xfs_icdinode_size(dino
.di_version
);
701 if (*i
== num_ops
-1 && f
->ilf_size
== 3) {
705 /* does anything come next */
706 op_head
= (xlog_op_header_t
*)*ptr
;
708 switch (f
->ilf_fields
& (XFS_ILOG_DEV
| XFS_ILOG_UUID
)) {
710 printf(_("DEV inode: no extra region\n"));
713 printf(_("UUID inode: no extra region\n"));
717 /* Only the inode core is logged */
718 if (f
->ilf_size
== 2)
721 ASSERT(f
->ilf_size
<= 4);
722 ASSERT((f
->ilf_size
== 3) || (f
->ilf_fields
& XFS_ILOG_AFORK
));
724 if (f
->ilf_fields
& XFS_ILOG_DFORK
) {
726 xlog_print_op_header(op_head
, *i
, ptr
);
728 switch (f
->ilf_fields
& XFS_ILOG_DFORK
) {
730 printf(_("EXTENTS inode data\n"));
732 case XFS_ILOG_DBROOT
:
733 printf(_("BTREE inode data\n"));
736 printf(_("LOCAL inode data\n"));
738 xlog_print_dir2_sf(log
, (xfs_dir2_sf_hdr_t
*)*ptr
, size
);
741 ASSERT((f
->ilf_fields
& XFS_ILOG_DFORK
) == 0);
745 *ptr
+= be32_to_cpu(op_head
->oh_len
);
746 if (op_head
->oh_flags
& XLOG_CONTINUE_TRANS
)
748 op_head
= (xlog_op_header_t
*)*ptr
;
751 if (f
->ilf_fields
& XFS_ILOG_AFORK
) {
753 xlog_print_op_header(op_head
, *i
, ptr
);
755 switch (f
->ilf_fields
& XFS_ILOG_AFORK
) {
757 printf(_("EXTENTS attr data\n"));
759 case XFS_ILOG_ABROOT
:
760 printf(_("BTREE attr data\n"));
763 printf(_("LOCAL attr data\n"));
765 xlog_print_dir2_sf(log
, (xfs_dir2_sf_hdr_t
*)*ptr
, size
);
768 ASSERT((f
->ilf_fields
& XFS_ILOG_AFORK
) == 0);
771 *ptr
+= be32_to_cpu(op_head
->oh_len
);
772 if (op_head
->oh_flags
& XLOG_CONTINUE_TRANS
)
777 } /* xlog_print_trans_inode */
781 xlog_print_trans_dquot(char **ptr
, int len
, int *i
, int num_ops
)
783 xfs_dq_logformat_t
*f
;
784 xfs_dq_logformat_t lbuf
= {0};
785 xfs_disk_dquot_t ddq
;
786 xlog_op_header_t
*head
= NULL
;
790 * print dquot header region
792 * memmove to ensure 8-byte alignment for the long longs in
793 * xfs_dq_logformat_t structure
795 memmove(&lbuf
, *ptr
, MIN(sizeof(xfs_dq_logformat_t
), len
));
797 (*i
)++; /* bump index */
800 if (len
== sizeof(xfs_dq_logformat_t
)) {
801 printf(_("#regs: %d id: 0x%x"), f
->qlf_size
, f
->qlf_id
);
802 printf(_(" blkno: %lld len: %d boff: %d\n"),
803 (long long)f
->qlf_blkno
, f
->qlf_len
, f
->qlf_boffset
);
805 ASSERT(len
>= 4); /* must have at least 4 bytes if != 0 */
806 printf(_("DQUOT: #regs: %d Not printing rest of data\n"),
812 /* Check if all regions in this log item were in the given LR ptr */
813 if (*i
+num
> num_ops
-1) {
814 skip
= num
- (num_ops
-1-*i
);
821 head
= (xlog_op_header_t
*)*ptr
;
822 xlog_print_op_header(head
, *i
, ptr
);
823 ASSERT(be32_to_cpu(head
->oh_len
) == sizeof(xfs_disk_dquot_t
));
824 memmove(&ddq
, *ptr
, sizeof(xfs_disk_dquot_t
));
825 printf(_("DQUOT: magic 0x%hx flags 0%ho\n"),
826 be16_to_cpu(ddq
.d_magic
), ddq
.d_flags
);
827 *ptr
+= be32_to_cpu(head
->oh_len
);
829 if (head
&& head
->oh_flags
& XLOG_CONTINUE_TRANS
)
832 } /* xlog_print_trans_dquot */
836 xlog_print_trans_icreate(
842 struct xfs_icreate_log icl_buf
= {0};
843 struct xfs_icreate_log
*icl
;
845 memmove(&icl_buf
, *ptr
, MIN(sizeof(struct xfs_icreate_log
), len
));
849 /* handle complete header only */
850 if (len
!= sizeof(struct xfs_icreate_log
)) {
851 printf(_("ICR: split header, not printing\n"));
852 return 1; /* to skip leftover in next region */
855 printf(_("ICR: #ag: %d agbno: 0x%x len: %d\n"
856 " cnt: %d isize: %d gen: 0x%x\n"),
857 be32_to_cpu(icl
->icl_ag
), be32_to_cpu(icl
->icl_agbno
),
858 be32_to_cpu(icl
->icl_length
), be32_to_cpu(icl
->icl_count
),
859 be32_to_cpu(icl
->icl_isize
), be32_to_cpu(icl
->icl_gen
));
863 /******************************************************************************
867 ******************************************************************************
871 xlog_print_lseek(struct xlog
*log
, int fd
, xfs_daddr_t blkno
, int whence
)
873 #define BBTOOFF64(bbs) (((xfs_off_t)(bbs)) << BBSHIFT)
876 if (whence
== SEEK_SET
)
877 offset
= BBTOOFF64(blkno
+log
->l_logBBstart
);
879 offset
= BBTOOFF64(blkno
);
880 if (lseek64(fd
, offset
, whence
) < 0) {
881 fprintf(stderr
, _("%s: lseek64 to %lld failed: %s\n"),
882 progname
, (long long)offset
, strerror(errno
));
885 } /* xlog_print_lseek */
889 print_lsn(char *string
,
892 printf("%s: %u,%u", string
,
893 CYCLE_LSN(be64_to_cpu(*lsn
)), BLOCK_LSN(be64_to_cpu(*lsn
)));
905 xlog_rec_header_t
*rhead
,
906 xlog_rec_ext_header_t
*xhdrs
,
910 int read_len
, skip
, lost_context
= 0;
921 /* read_len must read up to some block boundary */
922 read_len
= (int) BBTOB(BTOBB(len
));
924 /* read_type => don't malloc() new buffer, use old one */
925 if (*read_type
== FULL_READ
) {
926 if ((ptr
= buf
= malloc(read_len
)) == NULL
) {
927 fprintf(stderr
, _("%s: xlog_print_record: malloc failed\n"), progname
);
931 read_len
-= *read_type
;
932 buf
= (char *)((intptr_t)(*partial_buf
) + (intptr_t)(*read_type
));
935 if ((ret
= (int) read(fd
, buf
, read_len
)) == -1) {
936 fprintf(stderr
, _("%s: xlog_print_record: read error\n"), progname
);
939 /* Did we overflow the end? */
940 if (*read_type
== FULL_READ
&&
941 BLOCK_LSN(be64_to_cpu(rhead
->h_lsn
)) + BTOBB(read_len
) >=
943 *read_type
= BBTOB(logBBsize
- BLOCK_LSN(be64_to_cpu(rhead
->h_lsn
))-1);
948 /* Did we read everything? */
949 if ((ret
== 0 && read_len
!= 0) || ret
!= read_len
) {
954 if (*read_type
!= FULL_READ
)
955 read_len
+= *read_type
;
957 /* Everything read in. Start from beginning of buffer
958 * Unpack the data, by putting the saved cycle-data back
959 * into the first word of each BB.
963 for (i
= 0; ptr
< buf
+ read_len
; ptr
+= BBSIZE
, i
++) {
964 xlog_rec_header_t
*rechead
= (xlog_rec_header_t
*)ptr
;
967 if (be32_to_cpu(rechead
->h_magicno
) == XLOG_HEADER_MAGIC_NUM
) {
968 /* data should not have magicno as first word
969 * as it should by cycle#
975 * FIXME: cycle+1 should be a macro pv#900369
977 if (be32_to_cpu(rhead
->h_cycle
) !=
978 be32_to_cpu(*(__be32
*)ptr
)) {
979 if ((*read_type
== FULL_READ
) ||
980 (be32_to_cpu(rhead
->h_cycle
) + 1 !=
981 be32_to_cpu(*(__be32
*)ptr
))) {
988 /* copy back the data from the header */
989 if (i
< XLOG_HEADER_CYCLE_SIZE
/ BBSIZE
) {
990 /* from 1st header */
991 *(__be32
*)ptr
= rhead
->h_cycle_data
[i
];
994 ASSERT(xhdrs
!= NULL
);
995 /* from extra headers */
996 j
= i
/ (XLOG_HEADER_CYCLE_SIZE
/ BBSIZE
);
997 k
= i
% (XLOG_HEADER_CYCLE_SIZE
/ BBSIZE
);
998 *(__be32
*)ptr
= xhdrs
[j
-1].xh_cycle_data
[k
];
1004 for (i
=0; i
<num_ops
; i
++) {
1007 xlog_op_header_t
*op_head
= (xlog_op_header_t
*)ptr
;
1009 print_xlog_op_line();
1010 xlog_print_op_header(op_head
, i
, &ptr
);
1011 continued
= ((op_head
->oh_flags
& XLOG_WAS_CONT_TRANS
) ||
1012 (op_head
->oh_flags
& XLOG_CONTINUE_TRANS
));
1014 if (continued
&& be32_to_cpu(op_head
->oh_len
) == 0)
1017 if (print_no_data
) {
1018 for (n
= 0; n
< be32_to_cpu(op_head
->oh_len
); n
++) {
1019 printf("0x%02x ", (unsigned int)*ptr
);
1028 /* print transaction data */
1029 if (xlog_print_find_tid(be32_to_cpu(op_head
->oh_tid
),
1030 op_head
->oh_flags
& XLOG_WAS_CONT_TRANS
)) {
1031 printf(_("Left over region from split log item\n"));
1032 /* Skip this leftover bit */
1033 ptr
+= be32_to_cpu(op_head
->oh_len
);
1034 /* We've lost context; don't complain if next one looks bad too */
1039 if (be32_to_cpu(op_head
->oh_len
) != 0) {
1040 if (*(uint
*)ptr
== XFS_TRANS_HEADER_MAGIC
) {
1041 skip
= xlog_print_trans_header(&ptr
,
1042 be32_to_cpu(op_head
->oh_len
));
1044 switch (*(unsigned short *)ptr
) {
1046 skip
= xlog_print_trans_buffer(&ptr
,
1047 be32_to_cpu(op_head
->oh_len
),
1051 case XFS_LI_ICREATE
: {
1052 skip
= xlog_print_trans_icreate(&ptr
,
1053 be32_to_cpu(op_head
->oh_len
),
1057 case XFS_LI_INODE
: {
1058 skip
= xlog_print_trans_inode(log
, &ptr
,
1059 be32_to_cpu(op_head
->oh_len
),
1060 &i
, num_ops
, continued
);
1063 case XFS_LI_DQUOT
: {
1064 skip
= xlog_print_trans_dquot(&ptr
,
1065 be32_to_cpu(op_head
->oh_len
),
1070 skip
= xlog_print_trans_efi(&ptr
,
1071 be32_to_cpu(op_head
->oh_len
),
1076 skip
= xlog_print_trans_efd(&ptr
,
1077 be32_to_cpu(op_head
->oh_len
));
1080 case XFS_LI_QUOTAOFF
: {
1081 skip
= xlog_print_trans_qoff(&ptr
,
1082 be32_to_cpu(op_head
->oh_len
));
1085 case XLOG_UNMOUNT_TYPE
: {
1086 printf(_("Unmount filesystem\n"));
1091 if (bad_hdr_warn
&& !lost_context
) {
1093 _("%s: unknown log operation type (%x)\n"),
1094 progname
, *(unsigned short *)ptr
);
1101 _("Left over region from split log item\n"));
1104 ptr
+= be32_to_cpu(op_head
->oh_len
);
1110 xlog_print_add_to_trans(be32_to_cpu(op_head
->oh_tid
), skip
);
1116 } /* xlog_print_record */
1120 xlog_print_rec_head(xlog_rec_header_t
*head
, int *len
, int bad_hdr_warn
)
1127 return be32_to_cpu(head
->h_num_logops
);
1129 if (!head
->h_magicno
)
1132 if (be32_to_cpu(head
->h_magicno
) != XLOG_HEADER_MAGIC_NUM
) {
1134 printf(_("Header 0x%x wanted 0x%x\n"),
1135 be32_to_cpu(head
->h_magicno
),
1136 XLOG_HEADER_MAGIC_NUM
);
1140 /* check for cleared blocks written by xlog_clear_stale_blocks() */
1141 if (!head
->h_len
&& !head
->h_crc
&& !head
->h_prev_block
&&
1142 !head
->h_num_logops
&& !head
->h_size
)
1143 return CLEARED_BLKS
;
1145 datalen
=be32_to_cpu(head
->h_len
);
1148 printf(_("cycle: %d version: %d "),
1149 be32_to_cpu(head
->h_cycle
),
1150 be32_to_cpu(head
->h_version
));
1151 print_lsn(" lsn", &head
->h_lsn
);
1152 print_lsn(" tail_lsn", &head
->h_tail_lsn
);
1154 printf(_("length of Log Record: %d prev offset: %d num ops: %d\n"),
1156 be32_to_cpu(head
->h_prev_block
),
1157 be32_to_cpu(head
->h_num_logops
));
1159 if (print_overwrite
) {
1160 printf(_("cycle num overwrites: "));
1161 for (i
=0; i
< MIN(bbs
, XLOG_HEADER_CYCLE_SIZE
/ BBSIZE
); i
++)
1162 printf("%d - 0x%x ",
1164 be32_to_cpu(head
->h_cycle_data
[i
]));
1168 platform_uuid_unparse(&head
->h_fs_uuid
, uub
);
1169 printf(_("uuid: %s format: "), uub
);
1170 switch (be32_to_cpu(head
->h_fmt
)) {
1171 case XLOG_FMT_UNKNOWN
:
1172 printf(_("unknown\n"));
1174 case XLOG_FMT_LINUX_LE
:
1175 printf(_("little endian linux\n"));
1177 case XLOG_FMT_LINUX_BE
:
1178 printf(_("big endian linux\n"));
1180 case XLOG_FMT_IRIX_BE
:
1181 printf(_("big endian irix\n"));
1184 printf("? (%d)\n", be32_to_cpu(head
->h_fmt
));
1187 printf(_("h_size: %d\n"), be32_to_cpu(head
->h_size
));
1189 *len
= be32_to_cpu(head
->h_len
);
1190 return(be32_to_cpu(head
->h_num_logops
));
1191 } /* xlog_print_rec_head */
1194 xlog_print_rec_xhead(xlog_rec_ext_header_t
*head
, int coverage
)
1198 print_xlog_xhdr_line();
1199 printf(_("extended-header: cycle: %d\n"), be32_to_cpu(head
->xh_cycle
));
1201 if (print_overwrite
) {
1202 printf(_("cycle num overwrites: "));
1203 for (i
= 0; i
< coverage
; i
++)
1204 printf("%d - 0x%x ",
1206 be32_to_cpu(head
->xh_cycle_data
[i
]));
1209 } /* xlog_print_rec_xhead */
1212 print_xlog_bad_zeroed(xfs_daddr_t blkno
)
1215 printf(_("* ERROR: found data after zeroed blocks block=%-21lld *\n"),
1219 xlog_exit("Bad log - data after zeroed blocks");
1220 } /* print_xlog_bad_zeroed */
1223 print_xlog_bad_header(xfs_daddr_t blkno
, char *buf
)
1226 printf(_("* ERROR: header cycle=%-11d block=%-21lld *\n"),
1227 xlog_get_cycle(buf
), (long long)blkno
);
1230 xlog_exit("Bad log record header");
1231 } /* print_xlog_bad_header */
1234 print_xlog_bad_data(xfs_daddr_t blkno
)
1237 printf(_("* ERROR: data block=%-21lld *\n"),
1241 xlog_exit("Bad data in log");
1242 } /* print_xlog_bad_data */
1245 print_xlog_bad_reqd_hdrs(xfs_daddr_t blkno
, int num_reqd
, int num_hdrs
)
1248 printf(_("* ERROR: for header block=%lld\n"
1249 "* not enough hdrs for data length, "
1250 "required num = %d, hdr num = %d\n"),
1251 (long long)blkno
, num_reqd
, num_hdrs
);
1254 xlog_exit(_("Not enough headers for data length."));
1255 } /* print_xlog_bad_reqd_hdrs */
1258 xlog_reallocate_xhdrs(int num_hdrs
, xlog_rec_ext_header_t
**ret_xhdrs
)
1260 int len
= (num_hdrs
-1) * sizeof(xlog_rec_ext_header_t
);
1262 *ret_xhdrs
= (xlog_rec_ext_header_t
*)realloc(*ret_xhdrs
, len
);
1263 if (*ret_xhdrs
== NULL
) {
1264 fprintf(stderr
, _("%s: xlog_print: malloc failed for ext hdrs\n"), progname
);
1269 /* for V2 logs read each extra hdr and print it out */
1271 xlog_print_extended_headers(
1275 xlog_rec_header_t
*hdr
,
1277 xlog_rec_ext_header_t
**ret_xhdrs
)
1283 char xhbuf
[XLOG_HEADER_SIZE
];
1284 xlog_rec_ext_header_t
*x
;
1286 num_required
= howmany(len
, XLOG_HEADER_CYCLE_SIZE
);
1287 num_hdrs
= be32_to_cpu(hdr
->h_size
) / XLOG_HEADER_CYCLE_SIZE
;
1289 if (num_required
> num_hdrs
) {
1290 print_xlog_bad_reqd_hdrs((*blkno
)-1, num_required
, num_hdrs
);
1293 if (num_hdrs
== 1) {
1300 if (*ret_xhdrs
== NULL
|| num_hdrs
> *ret_num_hdrs
) {
1301 xlog_reallocate_xhdrs(num_hdrs
, ret_xhdrs
);
1304 *ret_num_hdrs
= num_hdrs
;
1306 /* don't include 1st header */
1307 for (i
= 1, x
= *ret_xhdrs
; i
< num_hdrs
; i
++, (*blkno
)++, x
++) {
1308 /* read one extra header blk */
1309 if (read(fd
, xhbuf
, 512) == 0) {
1310 printf(_("%s: physical end of log\n"), progname
);
1311 print_xlog_record_line();
1312 /* reached the end so return 1 */
1315 if (print_only_data
) {
1316 printf(_("BLKNO: %lld\n"), (long long)*blkno
);
1317 xlog_recover_print_data(xhbuf
, 512);
1320 if (i
== num_hdrs
- 1) {
1322 coverage_bb
= BTOBB(len
) %
1323 (XLOG_HEADER_CYCLE_SIZE
/ BBSIZE
);
1326 /* earliear header */
1327 coverage_bb
= XLOG_HEADER_CYCLE_SIZE
/ BBSIZE
;
1329 xlog_print_rec_xhead((xlog_rec_ext_header_t
*)xhbuf
, coverage_bb
);
1332 /* Copy from buffer into xhdrs array for later.
1333 * Could endian convert here but then code later on
1334 * will look asymmetric with the 1 hdr normal case
1335 * which does endian coversion on access.
1337 x
->xh_cycle
= ((xlog_rec_ext_header_t
*)xhbuf
)->xh_cycle
;
1338 for (j
= 0; j
< XLOG_HEADER_CYCLE_SIZE
/ BBSIZE
; j
++) {
1339 x
->xh_cycle_data
[j
] =
1340 ((xlog_rec_ext_header_t
*)xhbuf
)->xh_cycle_data
[j
];
1348 * This code is gross and needs to be rewritten.
1350 void xfs_log_print(struct xlog
*log
,
1352 int print_block_start
)
1354 char hbuf
[XLOG_HEADER_SIZE
];
1355 xlog_rec_header_t
*hdr
= (xlog_rec_header_t
*)&hbuf
[0];
1356 xlog_rec_ext_header_t
*xhdrs
= NULL
;
1357 int num_ops
, len
, num_hdrs
= 1;
1358 xfs_daddr_t block_end
= 0, block_start
, blkno
, error
;
1359 xfs_daddr_t zeroed_blkno
= 0, cleared_blkno
= 0;
1360 int read_type
= FULL_READ
;
1364 int first_hdr_found
= 0;
1366 logBBsize
= log
->l_logBBsize
;
1369 * Normally, block_start and block_end are the same value since we
1370 * are printing the entire log. However, if the start block is given,
1371 * we still end at the end of the logical log.
1373 if ((error
= xlog_print_find_oldest(log
, &block_end
))) {
1374 fprintf(stderr
, _("%s: problem finding oldest LR\n"), progname
);
1377 if (print_block_start
== -1)
1378 block_start
= block_end
;
1380 block_start
= print_block_start
;
1381 xlog_print_lseek(log
, fd
, block_start
, SEEK_SET
);
1382 blkno
= block_start
;
1385 if (read(fd
, hbuf
, 512) == 0) {
1386 printf(_("%s: physical end of log\n"), progname
);
1387 print_xlog_record_line();
1390 if (print_only_data
) {
1391 printf(_("BLKNO: %lld\n"), (long long)blkno
);
1392 xlog_recover_print_data(hbuf
, 512);
1396 num_ops
= xlog_print_rec_head(hdr
, &len
, first_hdr_found
);
1399 if (zeroed
&& num_ops
!= ZEROED_LOG
) {
1400 printf(_("%s: after %d zeroed blocks\n"), progname
, zeroed
);
1401 /* once we find zeroed blocks - that's all we expect */
1402 print_xlog_bad_zeroed(blkno
-1);
1403 /* reset count since we're assuming previous zeroed blocks
1409 if (num_ops
== ZEROED_LOG
||
1410 num_ops
== CLEARED_BLKS
||
1411 num_ops
== BAD_HEADER
) {
1412 if (num_ops
== ZEROED_LOG
) {
1414 zeroed_blkno
= blkno
-1;
1417 else if (num_ops
== CLEARED_BLKS
) {
1419 cleared_blkno
= blkno
-1;
1422 if (!first_hdr_found
)
1423 block_start
= blkno
;
1425 print_xlog_bad_header(blkno
-1, hbuf
);
1431 if (be32_to_cpu(hdr
->h_version
) == 2) {
1432 if (xlog_print_extended_headers(fd
, len
, &blkno
, hdr
, &num_hdrs
, &xhdrs
) != 0)
1436 error
= xlog_print_record(log
, fd
, num_ops
, len
, &read_type
, &partial_buf
,
1437 hdr
, xhdrs
, first_hdr_found
);
1441 blkno
+= BTOBB(len
);
1442 if (print_block_start
!= -1 &&
1443 blkno
>= block_end
) /* If start specified, we */
1444 goto end
; /* end early */
1448 print_xlog_bad_data(blkno
-1);
1449 if (print_block_start
!= -1 &&
1450 blkno
>= block_end
) /* If start specified, */
1451 goto end
; /* we end early */
1452 xlog_print_lseek(log
, fd
, blkno
, SEEK_SET
);
1455 case PARTIAL_READ
: {
1456 print_xlog_record_line();
1457 printf(_("%s: physical end of log\n"), progname
);
1458 print_xlog_record_line();
1460 xlog_print_lseek(log
, fd
, 0, SEEK_SET
);
1462 * We may have hit the end of the log when we started at 0.
1463 * In this case, just end.
1465 if (block_start
== 0)
1467 goto partial_log_read
;
1469 default: xlog_panic(_("illegal value"));
1471 print_xlog_record_line();
1473 if (blkno
>= logBBsize
) {
1475 printf(_("%s: skipped %d cleared blocks in range: %lld - %lld\n"),
1477 (long long)(cleared_blkno
),
1478 (long long)(cleared
+ cleared_blkno
- 1));
1479 if (cleared
== logBBsize
)
1480 printf(_("%s: totally cleared log\n"), progname
);
1485 printf(_("%s: skipped %d zeroed blocks in range: %lld - %lld\n"),
1487 (long long)(zeroed_blkno
),
1488 (long long)(zeroed
+ zeroed_blkno
- 1));
1489 if (zeroed
== logBBsize
)
1490 printf(_("%s: totally zeroed log\n"), progname
);
1494 printf(_("%s: physical end of log\n"), progname
);
1495 print_xlog_record_line();
1500 /* Do we need to print the first part of physical log? */
1501 if (block_start
!= 0) {
1503 xlog_print_lseek(log
, fd
, 0, SEEK_SET
);
1505 if (read(fd
, hbuf
, 512) == 0) {
1506 xlog_panic(_("xlog_find_head: bad read"));
1508 if (print_only_data
) {
1509 printf(_("BLKNO: %lld\n"), (long long)blkno
);
1510 xlog_recover_print_data(hbuf
, 512);
1514 num_ops
= xlog_print_rec_head(hdr
, &len
, first_hdr_found
);
1517 if (num_ops
== ZEROED_LOG
||
1518 num_ops
== CLEARED_BLKS
||
1519 num_ops
== BAD_HEADER
) {
1520 /* we only expect zeroed log entries or cleared log
1521 * entries at the end of the _physical_ log,
1522 * so treat them the same as bad blocks here
1524 print_xlog_bad_header(blkno
-1, hbuf
);
1526 if (blkno
>= block_end
)
1531 if (be32_to_cpu(hdr
->h_version
) == 2) {
1532 if (xlog_print_extended_headers(fd
, len
, &blkno
, hdr
, &num_hdrs
, &xhdrs
) != 0)
1537 error
= xlog_print_record(log
, fd
, num_ops
, len
, &read_type
,
1538 &partial_buf
, (xlog_rec_header_t
*)hbuf
,
1539 xhdrs
, first_hdr_found
);
1540 if (read_type
!= FULL_READ
)
1542 read_type
= FULL_READ
;
1544 blkno
+= BTOBB(len
);
1546 print_xlog_bad_data(blkno
-1);
1547 xlog_print_lseek(log
, fd
, blkno
, SEEK_SET
);
1550 print_xlog_record_line();
1552 if (blkno
>= block_end
)
1558 printf(_("%s: logical end of log\n"), progname
);
1559 print_xlog_record_line();
1563 * if necessary, convert an xfs_inode_log_format struct from 32bit or 64 bit versions
1564 * (which can have different field alignments) to the native version
1566 xfs_inode_log_format_t
*
1567 xfs_inode_item_format_convert(char *src_buf
, uint len
, xfs_inode_log_format_t
*in_f
)
1569 /* if we have native format then just return buf without copying data */
1570 if (len
== sizeof(xfs_inode_log_format_t
)) {
1571 return (xfs_inode_log_format_t
*)src_buf
;
1574 if (len
== sizeof(xfs_inode_log_format_32_t
)) {
1575 xfs_inode_log_format_32_t
*in_f32
;
1577 in_f32
= (xfs_inode_log_format_32_t
*)src_buf
;
1578 in_f
->ilf_type
= in_f32
->ilf_type
;
1579 in_f
->ilf_size
= in_f32
->ilf_size
;
1580 in_f
->ilf_fields
= in_f32
->ilf_fields
;
1581 in_f
->ilf_asize
= in_f32
->ilf_asize
;
1582 in_f
->ilf_dsize
= in_f32
->ilf_dsize
;
1583 in_f
->ilf_ino
= in_f32
->ilf_ino
;
1585 memcpy(&in_f
->ilf_u
.ilfu_uuid
, &in_f32
->ilf_u
.ilfu_uuid
, sizeof(uuid_t
));
1586 in_f
->ilf_blkno
= in_f32
->ilf_blkno
;
1587 in_f
->ilf_len
= in_f32
->ilf_len
;
1588 in_f
->ilf_boffset
= in_f32
->ilf_boffset
;
1590 xfs_inode_log_format_64_t
*in_f64
;
1592 ASSERT(len
== sizeof(xfs_inode_log_format_64_t
));
1593 in_f64
= (xfs_inode_log_format_64_t
*)src_buf
;
1594 in_f
->ilf_type
= in_f64
->ilf_type
;
1595 in_f
->ilf_size
= in_f64
->ilf_size
;
1596 in_f
->ilf_fields
= in_f64
->ilf_fields
;
1597 in_f
->ilf_asize
= in_f64
->ilf_asize
;
1598 in_f
->ilf_dsize
= in_f64
->ilf_dsize
;
1599 in_f
->ilf_ino
= in_f64
->ilf_ino
;
1601 memcpy(&in_f
->ilf_u
.ilfu_uuid
, &in_f64
->ilf_u
.ilfu_uuid
, sizeof(uuid_t
));
1602 in_f
->ilf_blkno
= in_f64
->ilf_blkno
;
1603 in_f
->ilf_len
= in_f64
->ilf_len
;
1604 in_f
->ilf_boffset
= in_f64
->ilf_boffset
;
1610 xfs_efi_copy_format(
1613 struct xfs_efi_log_format
*dst_efi_fmt
,
1617 uint nextents
= ((xfs_efi_log_format_t
*)buf
)->efi_nextents
;
1618 uint dst_len
= sizeof(xfs_efi_log_format_t
) + (nextents
- 1) * sizeof(xfs_extent_t
);
1619 uint len32
= sizeof(xfs_efi_log_format_32_t
) + (nextents
- 1) * sizeof(xfs_extent_32_t
);
1620 uint len64
= sizeof(xfs_efi_log_format_64_t
) + (nextents
- 1) * sizeof(xfs_extent_64_t
);
1622 if (len
== dst_len
|| continued
) {
1623 memcpy((char *)dst_efi_fmt
, buf
, len
);
1625 } else if (len
== len32
) {
1626 xfs_efi_log_format_32_t
*src_efi_fmt_32
= (xfs_efi_log_format_32_t
*)buf
;
1628 dst_efi_fmt
->efi_type
= src_efi_fmt_32
->efi_type
;
1629 dst_efi_fmt
->efi_size
= src_efi_fmt_32
->efi_size
;
1630 dst_efi_fmt
->efi_nextents
= src_efi_fmt_32
->efi_nextents
;
1631 dst_efi_fmt
->efi_id
= src_efi_fmt_32
->efi_id
;
1632 for (i
= 0; i
< dst_efi_fmt
->efi_nextents
; i
++) {
1633 dst_efi_fmt
->efi_extents
[i
].ext_start
=
1634 src_efi_fmt_32
->efi_extents
[i
].ext_start
;
1635 dst_efi_fmt
->efi_extents
[i
].ext_len
=
1636 src_efi_fmt_32
->efi_extents
[i
].ext_len
;
1639 } else if (len
== len64
) {
1640 xfs_efi_log_format_64_t
*src_efi_fmt_64
= (xfs_efi_log_format_64_t
*)buf
;
1642 dst_efi_fmt
->efi_type
= src_efi_fmt_64
->efi_type
;
1643 dst_efi_fmt
->efi_size
= src_efi_fmt_64
->efi_size
;
1644 dst_efi_fmt
->efi_nextents
= src_efi_fmt_64
->efi_nextents
;
1645 dst_efi_fmt
->efi_id
= src_efi_fmt_64
->efi_id
;
1646 for (i
= 0; i
< dst_efi_fmt
->efi_nextents
; i
++) {
1647 dst_efi_fmt
->efi_extents
[i
].ext_start
=
1648 src_efi_fmt_64
->efi_extents
[i
].ext_start
;
1649 dst_efi_fmt
->efi_extents
[i
].ext_len
=
1650 src_efi_fmt_64
->efi_extents
[i
].ext_len
;
1654 fprintf(stderr
, _("%s: bad size of efi format: %u; expected %u or %u; nextents = %u\n"),
1655 progname
, len
, len32
, len64
, nextents
);