1/* 2 * ntfs.h - Some generic defines for the NTFS kernel driver. 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_H 39#define _OSX_NTFS_H 40 41#ifdef KERNEL 42 43#include <sys/mount.h> 44 45#include <libkern/OSMalloc.h> 46 47#include <kern/locks.h> 48 49/* The email address of the NTFS developers. */ 50__private_extern__ const char ntfs_dev_email[]; 51__private_extern__ const char ntfs_please_email[]; 52 53/* 54 * Lock group and lock attribute for de-/initialization of locks (defined 55 * in ntfs_vfsops.c). 56 */ 57__private_extern__ lck_grp_t *ntfs_lock_grp; 58__private_extern__ lck_attr_t *ntfs_lock_attr; 59 60/* 61 * A tag for allocation and freeing of memory (defined in ntfs_vfsops.c). 62 */ 63__private_extern__ OSMallocTag ntfs_malloc_tag; 64 65#include "ntfs_volume.h" 66 67/** 68 * NTFS_MP - return the NTFS volume given a vfs mount 69 * @mp: VFS mount 70 * 71 * NTFS_MP() returns the NTFS volume associated with the VFS mount @mp. 72 */ 73static inline ntfs_volume *NTFS_MP(mount_t mp) 74{ 75 return (ntfs_volume*)vfs_fsprivate(mp); 76} 77 78__private_extern__ void ntfs_do_postponed_release(ntfs_volume *vol); 79 80#endif /* KERNEL */ 81 82#include "ntfs_endian.h" 83#include "ntfs_types.h" 84 85/* Some useful constants to do with NTFS. */ 86enum { 87 NTFS_BLOCK_SIZE = 512, 88 NTFS_BLOCK_SIZE_SHIFT = 9, 89 NTFS_MAX_NAME_LEN = 255, 90 NTFS_MAX_ATTR_NAME_LEN = 255, 91 NTFS_MAX_SECTOR_SIZE = 4096, /* 4kiB */ 92 NTFS_MAX_CLUSTER_SIZE = 64 * 1024, /* 64kiB */ 93 NTFS_ALLOC_BLOCK = 1024, 94 NTFS_MAX_HARD_LINKS = 65535, /* 2^16 - 1 */ 95 NTFS_MAX_ATTR_LIST_SIZE = 256 * 1024, /* 256kiB, corresponding to the 96 VACB_MAPPING_GRANULARITY on 97 Windows. */ 98 NTFS_COMPRESSION_UNIT = 4, 99}; 100 101/* 102 * The maximum attribute size on NTFS is 2^63 - 1 bytes as it is stored in a 103 * signed 64 bit type (s64). 104 */ 105#define NTFS_MAX_ATTRIBUTE_SIZE 0x7fffffffffffffffULL 106 107/* 108 * The maximum number of MFT records allowed on NTFS is 2^32 as described in 109 * various documentation to be found on the Microsoft web site. This is an 110 * imposed limit rather than an inherent NTFS format limit. 111 */ 112#define NTFS_MAX_NR_MFT_RECORDS 0x100000000ULL 113 114// TODO: Constants so ntfs_vfsops.c compiles for now... 115enum { 116 /* One of these must be present, default is ON_ERRORS_CONTINUE|ON_ERRORS_FAIL_DIRTY. */ 117 ON_ERRORS_PANIC = 0x01, 118 ON_ERRORS_REMOUNT_RO = 0x02, 119 ON_ERRORS_CONTINUE = 0x04, 120 /* Optional, can be combined with any of the above. */ 121 ON_ERRORS_RECOVER = 0x10, 122 /* If the volume is dirty, and we attempted to mount read/write, */ 123 /* return an error rather than force a read-only mount. */ 124 ON_ERRORS_FAIL_DIRTY = 0x20, 125}; 126 127/* 128 * The NTFS mount options header passed in from user space. 129 */ 130typedef struct { 131#ifndef KERNEL 132 char *fspec; /* Path of device to mount, consumed by mount(2). */ 133#endif /* !KERNEL */ 134 u8 major_ver; /* The major version of the mount options structure. */ 135 u8 minor_ver; /* The minor version of the mount options structure. */ 136} __attribute__((__packed__)) ntfs_mount_options_header; 137 138/* 139 * The NTFS mount options passed in from user space. This follows the 140 * ntfs_mount_options_header aligned to an eight byte boundary. 141 * 142 * This is major version 0, minor version 0, which does not have any options, 143 * i.e. is empty. 144 */ 145typedef struct { 146 /* Mount options version 0.0 does not have any ntfs options. */ 147} __attribute__((__packed__)) ntfs_mount_options_0_0; 148 149/* 150 * The currently defined flags for the ntfs mount options structure. 151 */ 152enum { 153 /* Below flag(s) appeared in mount options version 1.0. */ 154 NTFS_MNT_OPT_CASE_SENSITIVE = const_cpu_to_le32(0x00000001), 155 /* Below flag(s) appeared in mount options version x.y. */ 156 // TODO: Add NTFS specific mount options flags here. 157}; 158 159typedef le32 NTFS_MNT_OPTS; 160 161/* 162 * The NTFS mount options passed in from user space. This follows the 163 * ntfs_mount_options_header aligned to an eight byte boundary. 164 * 165 * This is major version 1, minor version 0, which has only one option, a 166 * little endian, 32-bit flags option. 167 */ 168typedef struct { 169 NTFS_MNT_OPTS flags; 170 // TODO: Add NTFS specific mount options here. 171} __attribute__((__packed__)) ntfs_mount_options_1_0; 172 173#endif /* !_OSX_NTFS_H */ 174