]>
git.saurik.com Git - hfs.git/blob - fsck_hfs/dfalib/fsck_journal.h
2 * Copyright (c) 2000-2012 Apple Inc. All rights reserved.
4 * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. The rights granted to you under the License
10 * may not be used to create, or enable the creation or redistribution of,
11 * unlawful or unlicensed copies of an Apple operating system, or to
12 * circumvent, violate, or enable the circumvention or violation of, any
13 * terms of an Apple operating system software license agreement.
15 * Please obtain a copy of the License at
16 * http://www.opensource.apple.com/apsl/ and read it before using this file.
18 * The Original Code and all software distributed under the License are
19 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
20 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
21 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
22 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
23 * Please see the License for the specific language governing rights and
24 * limitations under the License.
26 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
29 #ifndef _FSCK_JOURNAL_H
30 #define _FSCK_JOURNAL_H
32 #include <sys/cdefs.h>
34 #include <sys/types.h>
37 * The guts of the journal: a descriptor for which
38 * block number on the data disk is to be written.
40 typedef struct block_info
{
44 } __attribute__((__packed__
)) block_info
;
47 * A "transaction," for want of a better word.
48 * This contains a series of block_info, in the
49 * binfo array, which are used to modify the
52 typedef struct block_list_header
{
59 } __attribute__((__packed__
)) block_list_header
;
62 * This is written to block zero of the journal and it
63 * maintains overall state about the journal.
65 typedef struct journal_header
{
68 off_t start
; // zero-based byte offset of the start of the first transaction
69 off_t end
; // zero-based byte offset of where free space begins
70 off_t size
; // size in bytes of the entire journal
71 int32_t blhdr_size
; // size in bytes of each block_list_header in the journal
73 int32_t jhdr_size
; // block size (in bytes) of the journal header
74 uint32_t sequence_num
; // NEW FIELD: a monotonically increasing value assigned to all txn's
75 } __attribute__((__packed__
)) journal_header
;
77 #define JOURNAL_HEADER_MAGIC 0x4a4e4c78 // 'JNLx'
78 #define OLD_JOURNAL_HEADER_MAGIC 0x4a484452 // 'JHDR'
79 #define ENDIAN_MAGIC 0x12345678
82 // we only checksum the original size of the journal_header to remain
83 // backwards compatible. the size of the original journal_header is
84 // everything up to the the sequence_num field, hence we use the
85 // offsetof macro to calculate the size.
87 #define JOURNAL_HEADER_CKSUM_SIZE (offsetof(struct journal_header, sequence_num))
89 #define OLD_JOURNAL_HEADER_MAGIC 0x4a484452 // 'JHDR'
92 * The function used by fsck_hfs to replay the journal.
93 * It's modeled on the kernel function.
95 * For the do_write_b block, the offset argument is in bytes --
96 * the journal replay code will convert from journal block to
100 int journal_open(int jdev
,
103 size_t min_fs_block_size
,
105 const char *jdev_name
,
106 int (__lambda_ do_write_b
)(off_t
, void *, size_t));
108 #endif /* !_FSCK_JOURNAL_H */