1/*
2 * ntfs_types.h - Defines for NTFS kernel driver specific types.
3 *
4 * Copyright (c) 2006-2008 Anton Altaparmakov.  All Rights Reserved.
5 * Portions Copyright (c) 2006-2008 Apple Inc.  All Rights Reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions are met:
9 *
10 * 1. Redistributions of source code must retain the above copyright notice,
11 *    this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright notice,
13 *    this list of conditions and the following disclaimer in the documentation
14 *    and/or other materials provided with the distribution.
15 * 3. Neither the name of Apple Inc. ("Apple") nor the names of its
16 *    contributors may be used to endorse or promote products derived from this
17 *    software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
20 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
21 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22 * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
23 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
24 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
25 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
26 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
28 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 *
30 * ALTERNATIVELY, provided that this notice and licensing terms are retained in
31 * full, this file may be redistributed and/or modified under the terms of the
32 * GNU General Public License (GPL) Version 2, in which case the provisions of
33 * that version of the GPL will apply to you instead of the license terms
34 * above.  You can obtain a copy of the GPL Version 2 at
35 * http://developer.apple.com/opensource/licenses/gpl-2.txt.
36 */
37
38#ifndef _OSX_NTFS_TYPES_H
39#define _OSX_NTFS_TYPES_H
40
41#include <sys/types.h>
42
43#include <mach/boolean.h>
44
45/* Define our fixed size types. */
46typedef u_int8_t u8;
47typedef u_int16_t u16;
48typedef u_int32_t u32;
49typedef u_int64_t u64;
50typedef int8_t s8;
51typedef int16_t s16;
52typedef int32_t s32;
53typedef int64_t s64;
54
55/*
56 * Define our fixed size, little-endian types.  Note we define the signed types
57 * to be unsigned so we do not get sign extension on endianness conversions.
58 * We do not bother with eight-bit, little-endian types as endianness does not
59 * apply for eight-bit types.
60 */
61typedef u_int16_t le16;
62typedef u_int32_t le32;
63typedef u_int64_t le64;
64typedef u_int16_t sle16;
65typedef u_int32_t sle32;
66typedef u_int64_t sle64;
67
68/*
69 * Define our fixed size, big-endian types.  Note we define the signed types to
70 * be unsigned so we do not get sign extension on endianness conversions.  We
71 * do not bother with eight-bit, big-endian types as endianness does not apply
72 * for eight-bit types.
73 */
74typedef u_int16_t be16;
75typedef u_int32_t be32;
76typedef u_int64_t be64;
77typedef u_int16_t sbe16;
78typedef u_int32_t sbe32;
79typedef u_int64_t sbe64;
80
81/* 2-byte Unicode character type. */
82typedef le16 ntfschar;
83#define NTFSCHAR_SIZE_SHIFT 1
84
85/*
86 * Clusters are signed 64-bit values on NTFS volumes.  We define two types, LCN
87 * and VCN, to allow for type checking and better code readability.
88 */
89typedef s64 VCN;
90typedef sle64 leVCN;
91typedef s64 LCN;
92typedef sle64 leLCN;
93
94/*
95 * The NTFS journal $LogFile uses log sequence numbers which are signed 64-bit
96 * values.  We define our own type LSN, to allow for type checking and better
97 * code readability.
98 */
99typedef s64 LSN;
100typedef sle64 leLSN;
101
102/*
103 * The NTFS transaction log $UsnJrnl uses usns which are signed 64-bit values.
104 * We define our own type USN, to allow for type checking and better code
105 * readability.
106 */
107typedef s64 USN;
108typedef sle64 leUSN;
109
110/* Our boolean type. */
111typedef boolean_t BOOL;
112
113#endif /* !_OSX_NTFS_TYPES_H */
114