Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 13 Jul 2012 12:39:48 +0000
From:      vbotton@FreeBSD.org
To:        svn-soc-all@FreeBSD.org
Subject:   socsvn commit: r239339 - in soc2012/vbotton/head/sys/fs/ntfs: . test
Message-ID:  <20120713123948.73956106564A@hub.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: vbotton
Date: Fri Jul 13 12:39:47 2012
New Revision: 239339
URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=239339

Log:
  Attempt to mount ntfs in VFS

Added:
  soc2012/vbotton/head/sys/fs/ntfs/ntfs_attr.h
  soc2012/vbotton/head/sys/fs/ntfs/ntfs_attr_list.h
  soc2012/vbotton/head/sys/fs/ntfs/ntfs_bitmap.h
  soc2012/vbotton/head/sys/fs/ntfs/ntfs_collate.h
  soc2012/vbotton/head/sys/fs/ntfs/ntfs_compress.h
  soc2012/vbotton/head/sys/fs/ntfs/ntfs_debug.h
  soc2012/vbotton/head/sys/fs/ntfs/ntfs_dir.h
  soc2012/vbotton/head/sys/fs/ntfs/ntfs_endian.h
  soc2012/vbotton/head/sys/fs/ntfs/ntfs_hash.h
  soc2012/vbotton/head/sys/fs/ntfs/ntfs_index.h
  soc2012/vbotton/head/sys/fs/ntfs/ntfs_layout.h
  soc2012/vbotton/head/sys/fs/ntfs/ntfs_lcnalloc.h
  soc2012/vbotton/head/sys/fs/ntfs/ntfs_logfile.h
  soc2012/vbotton/head/sys/fs/ntfs/ntfs_mft.h
  soc2012/vbotton/head/sys/fs/ntfs/ntfs_mst.h
  soc2012/vbotton/head/sys/fs/ntfs/ntfs_original.h
  soc2012/vbotton/head/sys/fs/ntfs/ntfs_page.h
  soc2012/vbotton/head/sys/fs/ntfs/ntfs_quota.h
  soc2012/vbotton/head/sys/fs/ntfs/ntfs_runlist.h
  soc2012/vbotton/head/sys/fs/ntfs/ntfs_secure.h
  soc2012/vbotton/head/sys/fs/ntfs/ntfs_time.h
  soc2012/vbotton/head/sys/fs/ntfs/ntfs_types.h
  soc2012/vbotton/head/sys/fs/ntfs/ntfs_unistr.h
  soc2012/vbotton/head/sys/fs/ntfs/ntfs_usnjrnl.h
  soc2012/vbotton/head/sys/fs/ntfs/ntfs_vnops.h
  soc2012/vbotton/head/sys/fs/ntfs/ntfs_volume.h
  soc2012/vbotton/head/sys/fs/ntfs/test/
  soc2012/vbotton/head/sys/fs/ntfs/test/ntfs_attr.c
  soc2012/vbotton/head/sys/fs/ntfs/test/ntfs_attr_list.c
  soc2012/vbotton/head/sys/fs/ntfs/test/ntfs_bitmap.c
  soc2012/vbotton/head/sys/fs/ntfs/test/ntfs_collate.c
  soc2012/vbotton/head/sys/fs/ntfs/test/ntfs_compress.c
  soc2012/vbotton/head/sys/fs/ntfs/test/ntfs_debug.c
  soc2012/vbotton/head/sys/fs/ntfs/test/ntfs_dir.c
  soc2012/vbotton/head/sys/fs/ntfs/test/ntfs_hash.c
  soc2012/vbotton/head/sys/fs/ntfs/test/ntfs_index.c
  soc2012/vbotton/head/sys/fs/ntfs/test/ntfs_inode.c
  soc2012/vbotton/head/sys/fs/ntfs/test/ntfs_lcnalloc.c
  soc2012/vbotton/head/sys/fs/ntfs/test/ntfs_logfile.c
  soc2012/vbotton/head/sys/fs/ntfs/test/ntfs_mft.c
  soc2012/vbotton/head/sys/fs/ntfs/test/ntfs_mst.c
  soc2012/vbotton/head/sys/fs/ntfs/test/ntfs_page.c
  soc2012/vbotton/head/sys/fs/ntfs/test/ntfs_quota.c
  soc2012/vbotton/head/sys/fs/ntfs/test/ntfs_runlist.c
  soc2012/vbotton/head/sys/fs/ntfs/test/ntfs_secure.c
  soc2012/vbotton/head/sys/fs/ntfs/test/ntfs_unistr.c
  soc2012/vbotton/head/sys/fs/ntfs/test/ntfs_usnjrnl.c
  soc2012/vbotton/head/sys/fs/ntfs/test/ntfs_vnops.c
Replaced:
  soc2012/vbotton/head/sys/fs/ntfs/ntfs.h
  soc2012/vbotton/head/sys/fs/ntfs/ntfs_compr.c
  soc2012/vbotton/head/sys/fs/ntfs/ntfs_iconv.c
  soc2012/vbotton/head/sys/fs/ntfs/ntfs_ihash.c
  soc2012/vbotton/head/sys/fs/ntfs/ntfs_ihash.h
  soc2012/vbotton/head/sys/fs/ntfs/ntfs_inode.h
  soc2012/vbotton/head/sys/fs/ntfs/ntfs_subr.c   (contents, props changed)
  soc2012/vbotton/head/sys/fs/ntfs/ntfs_subr.h
  soc2012/vbotton/head/sys/fs/ntfs/ntfs_vfsops.c
  soc2012/vbotton/head/sys/fs/ntfs/ntfs_vfsops.h
  soc2012/vbotton/head/sys/fs/ntfs/ntfs_vnops.c
  soc2012/vbotton/head/sys/fs/ntfs/ntfsmount.h
Deleted:
  soc2012/vbotton/head/sys/fs/ntfs/ntfs_compr.h

Added: soc2012/vbotton/head/sys/fs/ntfs/ntfs.h
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ soc2012/vbotton/head/sys/fs/ntfs/ntfs.h	Fri Jul 13 12:39:47 2012	(r239339)
@@ -0,0 +1,167 @@
+/*
+ * ntfs.h - Some generic defines for the NTFS kernel driver.
+ *
+ * Copyright (c) 2006-2008 Anton Altaparmakov.  All Rights Reserved.
+ * Portions Copyright (c) 2006-2008 Apple Inc.  All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ *    this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ *    this list of conditions and the following disclaimer in the documentation
+ *    and/or other materials provided with the distribution. 
+ * 3. Neither the name of Apple Inc. ("Apple") nor the names of its
+ *    contributors may be used to endorse or promote products derived from this
+ *    software without specific prior written permission. 
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * ALTERNATIVELY, provided that this notice and licensing terms are retained in
+ * full, this file may be redistributed and/or modified under the terms of the
+ * GNU General Public License (GPL) Version 2, in which case the provisions of
+ * that version of the GPL will apply to you instead of the license terms
+ * above.  You can obtain a copy of the GPL Version 2 at
+ * http://developer.apple.com/opensource/licenses/gpl-2.txt.
+ */
+
+#ifndef _OSX_NTFS_H
+#define _OSX_NTFS_H
+
+#ifdef KERNEL
+
+#include <sys/mount.h>
+#include <kern/locks.h>
+
+/* The email address of the NTFS developers. */
+__private_extern__ const char ntfs_dev_email[];
+__private_extern__ const char ntfs_please_email[];
+
+/*
+ * Lock group and lock attribute for de-/initialization of locks (defined
+ * in ntfs_vfsops.c).
+ */
+__private_extern__ lck_grp_t *ntfs_lock_grp;
+__private_extern__ lck_attr_t *ntfs_lock_attr;
+
+/*
+ * A tag for allocation and freeing of memory (defined in ntfs_vfsops.c).
+ */
+__private_extern__ OSMallocTag ntfs_malloc_tag;
+#endif /* KERNEL */
+
+#include "ntfs_volume.h"
+
+/**
+ * NTFS_MP - return the NTFS volume given a vfs mount
+ * @mp:		VFS mount
+ *
+ * NTFS_MP() returns the NTFS volume associated with the VFS mount @mp.
+ */
+static inline ntfs_volume *NTFS_MP(mount_t mp)
+{
+	return (ntfs_volume*)mp->mnt_data;
+}
+
+__private_extern__ void ntfs_do_postponed_release(ntfs_volume *vol);
+
+
+#include "ntfs_endian.h"
+#include "ntfs_types.h"
+
+/* Some useful constants to do with NTFS. */
+enum {
+	NTFS_BLOCK_SIZE		= 512,
+	NTFS_BLOCK_SIZE_SHIFT	= 9,
+	NTFS_MAX_NAME_LEN	= 255,
+	NTFS_MAX_ATTR_NAME_LEN	= 255,
+	NTFS_MAX_SECTOR_SIZE	= 4096,		/* 4kiB */
+	NTFS_MAX_CLUSTER_SIZE	= 64 * 1024,	/* 64kiB */
+	NTFS_ALLOC_BLOCK	= 1024,
+	NTFS_MAX_HARD_LINKS	= 65535,	/* 2^16 - 1 */
+	NTFS_MAX_ATTR_LIST_SIZE	= 256 * 1024,	/* 256kiB, corresponding to the
+						   VACB_MAPPING_GRANULARITY on
+						   Windows. */
+	NTFS_COMPRESSION_UNIT	= 4,
+};
+
+/*
+ * The maximum attribute size on NTFS is 2^63 - 1 bytes as it is stored in a
+ * signed 64 bit type (s64).
+ */
+#define NTFS_MAX_ATTRIBUTE_SIZE 0x7fffffffffffffffULL
+
+/*
+ * The maximum number of MFT records allowed on NTFS is 2^32 as described in
+ * various documentation to be found on the Microsoft web site.  This is an
+ * imposed limit rather than an inherent NTFS format limit.
+ */
+#define NTFS_MAX_NR_MFT_RECORDS 0x100000000ULL
+
+// TODO: Constants so ntfs_vfsops.c compiles for now...
+enum {
+	/* One of these must be present, default is ON_ERRORS_CONTINUE. */
+	ON_ERRORS_PANIC		= 0x01,
+	ON_ERRORS_REMOUNT_RO	= 0x02,
+	ON_ERRORS_CONTINUE	= 0x04,
+	/* Optional, can be combined with any of the above. */
+	ON_ERRORS_RECOVER	= 0x10,
+};
+
+/*
+ * The NTFS mount options header passed in from user space.
+ */
+typedef struct {
+#ifndef KERNEL
+	char *fspec;	/* Path of device to mount, consumed by mount(2). */
+#endif /* !KERNEL */
+	u8 major_ver;	/* The major version of the mount options structure. */
+	u8 minor_ver;	/* The minor version of the mount options structure. */
+} __attribute__((__packed__)) ntfs_mount_options_header;
+
+/*
+ * The NTFS mount options passed in from user space.  This follows the
+ * ntfs_mount_options_header aligned to an eight byte boundary.
+ *
+ * This is major version 0, minor version 0, which does not have any options,
+ * i.e. is empty.
+ */
+typedef struct {
+	/* Mount options version 0.0 does not have any ntfs options. */
+} __attribute__((__packed__)) ntfs_mount_options_0_0;
+
+/*
+ * The currently defined flags for the ntfs mount options structure.
+ */
+enum {
+	/* Below flag(s) appeared in mount options version 1.0. */
+	NTFS_MNT_OPT_CASE_SENSITIVE = htole32(0x00000001),
+	/* Below flag(s) appeared in mount options version x.y. */
+	// TODO: Add NTFS specific mount options flags here.
+};
+
+typedef le32 NTFS_MNT_OPTS;
+
+/*
+ * The NTFS mount options passed in from user space.  This follows the
+ * ntfs_mount_options_header aligned to an eight byte boundary.
+ *
+ * This is major version 1, minor version 0, which has only one option, a
+ * little endian, 32-bit flags option.
+ */
+typedef struct {
+	NTFS_MNT_OPTS flags;
+	// TODO: Add NTFS specific mount options here.
+} __attribute__((__packed__)) ntfs_mount_options_1_0;
+
+#endif /* !_OSX_NTFS_H */

Added: soc2012/vbotton/head/sys/fs/ntfs/ntfs_attr.h
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ soc2012/vbotton/head/sys/fs/ntfs/ntfs_attr.h	Fri Jul 13 12:39:47 2012	(r239339)
@@ -0,0 +1,245 @@
+/*
+ * ntfs_attr.h - Defines for attribute handling in the NTFS kernel driver.
+ *
+ * Copyright (c) 2006-2008 Anton Altaparmakov.  All Rights Reserved.
+ * Portions Copyright (c) 2006-2008 Apple Inc.  All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ *    this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ *    this list of conditions and the following disclaimer in the documentation
+ *    and/or other materials provided with the distribution. 
+ * 3. Neither the name of Apple Inc. ("Apple") nor the names of its
+ *    contributors may be used to endorse or promote products derived from this
+ *    software without specific prior written permission. 
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * ALTERNATIVELY, provided that this notice and licensing terms are retained in
+ * full, this file may be redistributed and/or modified under the terms of the
+ * GNU General Public License (GPL) Version 2, in which case the provisions of
+ * that version of the GPL will apply to you instead of the license terms
+ * above.  You can obtain a copy of the GPL Version 2 at
+ * http://developer.apple.com/opensource/licenses/gpl-2.txt.
+ */
+
+#ifndef _OSX_NTFS_ATTR_H
+#define _OSX_NTFS_ATTR_H
+
+#include <sys/errno.h>
+
+/* Forward declaration. */
+typedef struct _ntfs_attr_search_ctx ntfs_attr_search_ctx;
+
+#include "ntfs_endian.h"
+#include "ntfs_index.h"
+#include "ntfs_inode.h"
+#include "ntfs_layout.h"
+#include "ntfs_types.h"
+
+/*
+ * The little endian Unicode empty string as a global constant.  This is used
+ * when looking up attributes to specify that we want the unnamed attribute as
+ * opposed to any attribute or a specific named attribute.
+ */
+__private_extern__ ntfschar AT_UNNAMED[1];
+
+__private_extern__ errno_t ntfs_attr_map_runlist(ntfs_inode *ni);
+
+__private_extern__ errno_t ntfs_map_runlist_nolock(ntfs_inode *ni, VCN vcn,
+		ntfs_attr_search_ctx *ctx);
+
+__private_extern__ LCN ntfs_attr_vcn_to_lcn_nolock(ntfs_inode *ni,
+		const VCN vcn, const BOOL write_locked, s64 *clusters);
+
+__private_extern__ errno_t ntfs_attr_find_vcn_nolock(ntfs_inode *ni,
+		const VCN vcn, ntfs_rl_element **run,
+		ntfs_attr_search_ctx *ctx);
+
+static inline s64 ntfs_attr_size(const ATTR_RECORD *a)
+{
+	if (!a->non_resident)
+		return (s64)le32toh(a->value_length);
+	return le64toh(a->data_size);
+}
+
+/**
+ * ntfs_attr_search_ctx - used in attribute search functions
+ * @m:			buffer containing mft record to search
+ * @a:			attribute record in @m where to begin/continue search
+ * @is_first:		if 1 the search begins search with @a, else after
+ * @is_iteration:	if 1 this is not a search but an iteration
+ * @is_error:		if 1 this search context is invalid and must be released
+ * @is_mft_locked:	if 1 the mft is locked (@mft_ni->lock)
+ *
+ * Structure must be initialized to zero before the first call to one of the
+ * attribute search functions.  Initialize @m to point to the mft record to
+ * search, and @a to point to the first attribute within @m and set @is_first
+ * to 1.
+ *
+ * If @is_first is 1, the search begins with @a.  If @is_first is 0, the search
+ * begins after @a.  This is so that, after the first call to one of the search
+ * attribute functions, we can call the function again, without any
+ * modification of the search context, to automagically get the next matching
+ * attribute.
+ *
+ * If @is_iteration is 1, all attributes are returned one after the other with
+ * each call to ntfs_attr_find_in_mft_record().  Note this only works with
+ * ntfs_attr_find_in_mft_record() and not with ntfs_attr_lookup() or
+ * ntfs_attr_find_in_attribute_list().
+ *
+ * If @is_error is 1 this attribute search context has become invalid and must
+ * either be reinitialized via ntfs_attr_search_ctx_reinit() or released via
+ * ntfs_attr_search_ctx_put().  Functions to which you pass an attribute search
+ * context may require you to check @is_error after calling the function.  If
+ * this is the case the function will explicictly say so in the function
+ * description.
+ *
+ * If @is_error is 1 you can see what the error code was that caused the
+ * context to become invalid by looking at the @error member of the search
+ * context.
+ *
+ * If @is_mft_locked is true the owner of the search context holds the mft lock
+ * (@mft_ni->lock) thus ntfs_attr_lookup() will make sure to pass this fact
+ * onto ntfs_extent_mft_record_map_ext() so that it will not try to take the
+ * same lock.  It is then the responsibility of the caller that the mft is
+ * consistent and stable for the duration of the life of the search context.
+ */
+struct _ntfs_attr_search_ctx {
+	union {
+		MFT_RECORD *m;
+		errno_t error;
+	};
+	ATTR_RECORD *a;
+	struct {
+		unsigned is_first:1;	/* If 1 this is the first search. */
+		unsigned is_iteration:1;/* If 1 this is an iteration of all
+					   attributes in the mft record. */
+		unsigned is_error:1;
+		unsigned is_mft_locked:1;
+	};
+	ntfs_inode *ni;
+	ATTR_LIST_ENTRY *al_entry;
+	ntfs_inode *base_ni;
+	MFT_RECORD *base_m;
+	ATTR_RECORD *base_a;
+};
+
+/**
+ * ntfs_attr_search_ctx_init - initialize an attribute search context
+ * @ctx:	attribute search context to initialize
+ * @ni:		ntfs inode with which to initialize the search context
+ * @m:		mft record with which to initialize the search context
+ *
+ * Initialize the attribute search context @ctx with @ni and @m.
+ */
+static inline void ntfs_attr_search_ctx_init(ntfs_attr_search_ctx *ctx,
+		ntfs_inode *ni, MFT_RECORD *m)
+{
+	/*
+	 * Gcc is broken so it fails to see both the members of the anonymous
+	 * union and the bitfield inside the C99 initializer.  Work around this
+	 * by setting @m and @is_first afterwards.
+	 */
+	*ctx = (ntfs_attr_search_ctx) {
+		/* Sanity checks are performed elsewhere. */
+		.a = (ATTR_RECORD*)((u8*)m + le16toh(m->attrs_offset)),
+		.ni = ni,
+	};
+	ctx->m = m,
+	ctx->is_first = 1;
+}
+
+__private_extern__ void ntfs_attr_search_ctx_reinit(ntfs_attr_search_ctx *ctx);
+__private_extern__ ntfs_attr_search_ctx *ntfs_attr_search_ctx_get(
+		ntfs_inode *ni, MFT_RECORD *m);
+__private_extern__ void ntfs_attr_search_ctx_put(ntfs_attr_search_ctx *ctx);
+
+__private_extern__ errno_t ntfs_attr_find_in_mft_record(const ATTR_TYPE type,
+		const ntfschar *name, const u32 name_len,
+		const void *val, const u32 val_len, ntfs_attr_search_ctx *ctx);
+
+__private_extern__ errno_t ntfs_attr_lookup(const ATTR_TYPE type,
+		const ntfschar *name, const u32 name_len, const VCN lowest_vcn,
+		const void *val, const u32 val_len, ntfs_attr_search_ctx *ctx);
+
+__private_extern__ errno_t ntfs_attr_size_bounds_check(const ntfs_volume *vol,
+		const ATTR_TYPE type, const s64 size);
+
+__private_extern__ errno_t ntfs_attr_can_be_resident(const ntfs_volume *vol,
+		const ATTR_TYPE type);
+
+__private_extern__ BOOL ntfs_attr_record_is_only_one(MFT_RECORD *m,
+		ATTR_RECORD *a);
+
+__private_extern__ void ntfs_attr_record_delete_internal(MFT_RECORD *m,
+		ATTR_RECORD *a);
+__private_extern__ errno_t ntfs_attr_record_delete(ntfs_inode *base_ni,
+		ntfs_attr_search_ctx *ctx);
+
+__private_extern__ errno_t ntfs_attr_record_make_space(MFT_RECORD *m,
+		ATTR_RECORD *a, u32 size);
+
+__private_extern__ errno_t ntfs_attr_record_resize(MFT_RECORD *m,
+		ATTR_RECORD *a, u32 new_size);
+
+__private_extern__ errno_t ntfs_attr_mapping_pairs_update(ntfs_inode *base_ni,
+		ntfs_inode *ni, VCN first_vcn, VCN last_vcn,
+		ntfs_attr_search_ctx *ctx);
+
+__private_extern__ errno_t ntfs_resident_attr_record_insert_internal(
+		MFT_RECORD *m, ATTR_RECORD *a, const ATTR_TYPE type,
+		const ntfschar *name, const u8 name_len, const u32 val_len);
+__private_extern__ errno_t ntfs_resident_attr_record_insert(ntfs_inode *ni,
+		ntfs_attr_search_ctx *ctx, const ATTR_TYPE type,
+		const ntfschar *name, const u8 name_len,
+		const void *val, const u32 val_len);
+
+__private_extern__ errno_t ntfs_resident_attr_value_resize(MFT_RECORD *m,
+		ATTR_RECORD *a, const u32 new_size);
+
+__private_extern__ errno_t ntfs_attr_make_non_resident(ntfs_inode *ni);
+
+__private_extern__ errno_t ntfs_attr_record_move_for_attr_list_attribute(
+		ntfs_attr_search_ctx *al_ctx, ATTR_LIST_ENTRY *al_entry,
+		ntfs_attr_search_ctx *ctx, BOOL *remap_needed);
+
+__private_extern__ errno_t ntfs_attr_record_move(ntfs_attr_search_ctx *ctx);
+
+__private_extern__ errno_t ntfs_attr_set_initialized_size(ntfs_inode *ni,
+		s64 new_init_size);
+
+__private_extern__ errno_t ntfs_attr_extend_initialized(ntfs_inode *ni,
+		const s64 new_init_size);
+
+__private_extern__ errno_t ntfs_attr_instantiate_holes(ntfs_inode *ni,
+		s64 start, s64 end, s64 *new_end, BOOL atomic);
+
+__private_extern__ errno_t ntfs_attr_extend_allocation(ntfs_inode *ni,
+		s64 new_alloc_size, const s64 new_data_size,
+		const s64 data_start, ntfs_index_context *ictx,
+		s64 *dst_alloc_size, const BOOL atomic);
+
+__private_extern__ errno_t ntfs_attr_resize(ntfs_inode *ni, s64 new_size,
+		int ioflags, ntfs_index_context *ictx);
+
+__private_extern__ errno_t ntfs_attr_set(ntfs_inode *ni, s64 ofs,
+		const s64 cnt, const u8 val);
+
+__private_extern__ errno_t ntfs_resident_attr_read(ntfs_inode *ni,
+		const s64 ofs, const u32 cnt, u8 *buf);
+__private_extern__ errno_t ntfs_resident_attr_write(ntfs_inode *ni, u8 *buf,
+		u32 cnt, const s64 ofs);
+#endif /* !_OSX_NTFS_ATTR_H */

Added: soc2012/vbotton/head/sys/fs/ntfs/ntfs_attr_list.h
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ soc2012/vbotton/head/sys/fs/ntfs/ntfs_attr_list.h	Fri Jul 13 12:39:47 2012	(r239339)
@@ -0,0 +1,112 @@
+/*
+ * ntfs_attr_list.h - Defines for attribute list attribute handling in the NTFS
+ *		      kernel driver.
+ *
+ * Copyright (c) 2006-2008 Anton Altaparmakov.  All Rights Reserved.
+ * Portions Copyright (c) 2006-2008 Apple Inc.  All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ *    this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ *    this list of conditions and the following disclaimer in the documentation
+ *    and/or other materials provided with the distribution. 
+ * 3. Neither the name of Apple Inc. ("Apple") nor the names of its
+ *    contributors may be used to endorse or promote products derived from this
+ *    software without specific prior written permission. 
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * ALTERNATIVELY, provided that this notice and licensing terms are retained in
+ * full, this file may be redistributed and/or modified under the terms of the
+ * GNU General Public License (GPL) Version 2, in which case the provisions of
+ * that version of the GPL will apply to you instead of the license terms
+ * above.  You can obtain a copy of the GPL Version 2 at
+ * http://developer.apple.com/opensource/licenses/gpl-2.txt.
+ */
+
+#ifndef _OSX_NTFS_ATTR_LIST_H
+#define _OSX_NTFS_ATTR_LIST_H
+
+#include <sys/errno.h>
+
+#include "ntfs_attr.h"
+#include "ntfs_endian.h"
+#include "ntfs_inode.h"
+#include "ntfs_layout.h"
+#include "ntfs_types.h"
+
+__private_extern__ errno_t ntfs_attr_list_is_needed(ntfs_inode *ni,
+		ATTR_LIST_ENTRY *skip_entry, BOOL *attr_list_is_needed);
+
+__private_extern__ errno_t ntfs_attr_list_delete(ntfs_inode *ni,
+		ntfs_attr_search_ctx *ctx);
+
+__private_extern__ errno_t ntfs_attr_list_add(ntfs_inode *ni, MFT_RECORD *m,
+		ntfs_attr_search_ctx *ctx);
+
+__private_extern__ errno_t ntfs_attr_list_sync_shrink(ntfs_inode *ni,
+		const unsigned start_ofs, ntfs_attr_search_ctx *ctx);
+
+__private_extern__ errno_t ntfs_attr_list_sync_extend(ntfs_inode *base_ni,
+		MFT_RECORD *base_m, unsigned al_ofs,
+		ntfs_attr_search_ctx *ctx);
+
+/**
+ * ntfs_attr_list_sync - update the attribute list content of an ntfs inode
+ * @ni:		base ntfs inode whose attribute list attribugte to update
+ * @start_ofs:	byte offset into attribute list attribute from which to write
+ * @ctx:	initialized attribute search context
+ *
+ * Write the attribute list attribute value cached in @ni starting at byte
+ * offset @start_ofs into it to the attribute list attribute record (if the
+ * attribute list attribute is resident) or to disk as specified by the runlist
+ * of the attribute list attribute.
+ *
+ * This function only works when the attribute list content but not its size
+ * has changed.
+ *
+ * @ctx is an initialized, ready to use attribute search context that we use to
+ * look up the attribute list attribute in the mapped, base mft record.
+ *
+ * Return 0 on success and -errno on error.
+ */
+static inline int ntfs_attr_list_sync(ntfs_inode *ni, const unsigned start_ofs,
+		ntfs_attr_search_ctx *ctx)
+{
+	return ntfs_attr_list_sync_shrink(ni, start_ofs, ctx);
+}
+
+__private_extern__ void ntfs_attr_list_entries_delete(ntfs_inode *ni,
+		ATTR_LIST_ENTRY *start_entry, ATTR_LIST_ENTRY *end_entry);
+
+/**
+ * ntfs_attr_list_entry_delete - delete an attribute list entry
+ * @ni:			base ntfs inode whose attribute list to delete from
+ * @target_entry:	attribute list entry to be deleted
+ *
+ * Delete the attribute list attribute entry @target_entry from the attribute
+ * list attribute belonging to the base ntfs inode @ni.
+ *
+ * This function cannot fail.
+ */
+static inline void ntfs_attr_list_entry_delete(ntfs_inode *ni,
+		ATTR_LIST_ENTRY *target_entry)
+{
+	ntfs_attr_list_entries_delete(ni, target_entry,
+			(ATTR_LIST_ENTRY*)((u8*)target_entry +
+			le16toh(target_entry->length)));
+}
+
+#endif /* !_OSX_NTFS_ATTR_LIST_H */

Added: soc2012/vbotton/head/sys/fs/ntfs/ntfs_bitmap.h
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ soc2012/vbotton/head/sys/fs/ntfs/ntfs_bitmap.h	Fri Jul 13 12:39:47 2012	(r239339)
@@ -0,0 +1,141 @@
+/*
+ * ntfs_bitmap.h - Defines for bitmap handling in the NTFS kernel driver.
+ *
+ * Copyright (c) 2006-2008 Anton Altaparmakov.  All Rights Reserved.
+ * Portions Copyright (c) 2006-2008 Apple Inc.  All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ *    this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ *    this list of conditions and the following disclaimer in the documentation
+ *    and/or other materials provided with the distribution. 
+ * 3. Neither the name of Apple Inc. ("Apple") nor the names of its
+ *    contributors may be used to endorse or promote products derived from this
+ *    software without specific prior written permission. 
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * ALTERNATIVELY, provided that this notice and licensing terms are retained in
+ * full, this file may be redistributed and/or modified under the terms of the
+ * GNU General Public License (GPL) Version 2, in which case the provisions of
+ * that version of the GPL will apply to you instead of the license terms
+ * above.  You can obtain a copy of the GPL Version 2 at
+ * http://developer.apple.com/opensource/licenses/gpl-2.txt.
+ */
+
+#ifndef _OSX_NTFS_BITMAP_H
+#define _OSX_NTFS_BITMAP_H
+
+#include <sys/errno.h>
+
+#include "ntfs_inode.h"
+#include "ntfs_types.h"
+
+__private_extern__ errno_t __ntfs_bitmap_set_bits_in_run(ntfs_inode *ni,
+		const s64 start_bit, const s64 count, const u8 value,
+		const BOOL is_rollback);
+
+/**
+ * ntfs_bitmap_set_bits_in_run - set a run of bits in a bitmap to a value
+ * @ni:			ntfs inode describing the bitmap
+ * @start_bit:		first bit to set
+ * @count:		number of bits to set
+ * @value:		value to set the bits to (i.e. 0 or 1)
+ *
+ * Set @count bits starting at bit @start_bit in the bitmap described by the
+ * ntfs inode @ni to @value, where @value is either 0 or 1.
+ *
+ * Return 0 on success and errno on error.
+ *
+ * Locking: The caller must hold @ni->lock.
+ */
+static inline errno_t ntfs_bitmap_set_bits_in_run(ntfs_inode *ni,
+		const s64 start_bit, const s64 count, const u8 value)
+{
+	return __ntfs_bitmap_set_bits_in_run(ni, start_bit, count, value,
+			FALSE);
+}
+
+/**
+ * ntfs_bitmap_set_run - set a run of bits in a bitmap
+ * @ni:		ntfs inode describing the bitmap
+ * @start_bit:	first bit to set
+ * @count:	number of bits to set
+ *
+ * Set @count bits starting at bit @start_bit in the bitmap described by the
+ * ntfs inode @ni.
+ *
+ * Return 0 on success and errno on error.
+ *
+ * Locking: The caller must hold @ni->lock.
+ */
+static inline errno_t ntfs_bitmap_set_run(ntfs_inode *ni, const s64 start_bit,
+		const s64 count)
+{
+	return ntfs_bitmap_set_bits_in_run(ni, start_bit, count, 1);
+}
+
+/**
+ * ntfs_bitmap_clear_run - clear a run of bits in a bitmap
+ * @ni:		ntfs inode describing the bitmap
+ * @start_bit:	first bit to clear
+ * @count:	number of bits to clear
+ *
+ * Clear @count bits starting at bit @start_bit in the bitmap described by the
+ * ntfs inode @ni.
+ *
+ * Return 0 on success and errno on error.
+ *
+ * Locking: The caller must hold @ni->lock.
+ */
+static inline errno_t ntfs_bitmap_clear_run(ntfs_inode *ni,
+		const s64 start_bit, const s64 count)
+{
+	return ntfs_bitmap_set_bits_in_run(ni, start_bit, count, 0);
+}
+
+/**
+ * ntfs_bitmap_set_bit - set a bit in a bitmap
+ * @ni:		ntfs inode describing the bitmap
+ * @bit:	bit to set
+ *
+ * Set bit @bit in the bitmap described by the ntfs inode @ni.
+ *
+ * Return 0 on success and errno on error.
+ *
+ * Locking: The caller must hold @ni->lock.
+ */
+static inline errno_t ntfs_bitmap_set_bit(ntfs_inode *ni, const s64 bit)
+{
+	return ntfs_bitmap_set_run(ni, bit, 1);
+}
+
+/**
+ * ntfs_bitmap_clear_bit - clear a bit in a bitmap
+ * @ni:		ntfs inode describing the bitmap
+ * @bit:	bit to clear
+ *
+ * Clear bit @bit in the bitmap described by the ntfs inode @ni.
+ *
+ * Return 0 on success and errno on error.
+ *
+ * Locking: The caller must hold @ni->lock.
+ */
+static inline errno_t ntfs_bitmap_clear_bit(ntfs_inode *ni, const s64 bit)
+{
+	return ntfs_bitmap_clear_run(ni, bit, 1);
+}
+
+#endif /* !_OSX_NTFS_BITMAP_H */

Added: soc2012/vbotton/head/sys/fs/ntfs/ntfs_collate.h
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ soc2012/vbotton/head/sys/fs/ntfs/ntfs_collate.h	Fri Jul 13 12:39:47 2012	(r239339)
@@ -0,0 +1,65 @@
+/*
+ * ntfs_collate.h - Defines for collation handling in the NTFS kernel driver.
+ *
+ * Copyright (c) 2006-2008 Anton Altaparmakov.  All Rights Reserved.
+ * Portions Copyright (c) 2006-2008 Apple Inc.  All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ *    this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ *    this list of conditions and the following disclaimer in the documentation
+ *    and/or other materials provided with the distribution. 
+ * 3. Neither the name of Apple Inc. ("Apple") nor the names of its
+ *    contributors may be used to endorse or promote products derived from this
+ *    software without specific prior written permission. 
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * ALTERNATIVELY, provided that this notice and licensing terms are retained in
+ * full, this file may be redistributed and/or modified under the terms of the
+ * GNU General Public License (GPL) Version 2, in which case the provisions of
+ * that version of the GPL will apply to you instead of the license terms
+ * above.  You can obtain a copy of the GPL Version 2 at
+ * http://developer.apple.com/opensource/licenses/gpl-2.txt.
+ */
+
+#ifndef _OSX_NTFS_COLLATE_H
+#define _OSX_NTFS_COLLATE_H
+
+#include "ntfs_layout.h"
+#include "ntfs_types.h"
+#include "ntfs_volume.h"
+
+static inline BOOL ntfs_is_collation_rule_supported(COLLATION_RULE cr) {
+	int i;
+
+	/*
+	 * TODO: We support everything other than COLLATION_UNICODE_STRING at
+	 * present but we do a range check in case new collation rules turn up
+	 * in later ntfs releases.
+	 */
+	if (cr == COLLATION_UNICODE_STRING)
+		return FALSE;
+	i = le32toh(cr);
+	if (((i >= 0) && (i <= 0x02)) || ((i >= 0x10) && (i <= 0x13)))
+		return TRUE;
+	return FALSE;
+}
+
+__private_extern__ int ntfs_collate(ntfs_volume *vol, COLLATION_RULE cr,
+		const void *data1, const int data1_len,
+		const void *data2, const int data2_len);
+
+#endif /* _OSX_NTFS_COLLATE_H */

Added: soc2012/vbotton/head/sys/fs/ntfs/ntfs_compr.c
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ soc2012/vbotton/head/sys/fs/ntfs/ntfs_compr.c	Fri Jul 13 12:39:47 2012	(r239339)
@@ -0,0 +1,2 @@
+
+

Added: soc2012/vbotton/head/sys/fs/ntfs/ntfs_compress.h
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ soc2012/vbotton/head/sys/fs/ntfs/ntfs_compress.h	Fri Jul 13 12:39:47 2012	(r239339)
@@ -0,0 +1,52 @@
+/*
+ * ntfs_compress.h - Defines for compressed attribute handling in the NTFS
+ *		     kernel driver.
+ *
+ * Copyright (c) 2006-2008 Anton Altaparmakov.  All Rights Reserved.
+ * Portions Copyright (c) 2006-2008 Apple Inc.  All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ *    this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ *    this list of conditions and the following disclaimer in the documentation
+ *    and/or other materials provided with the distribution. 
+ * 3. Neither the name of Apple Inc. ("Apple") nor the names of its
+ *    contributors may be used to endorse or promote products derived from this
+ *    software without specific prior written permission. 
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * ALTERNATIVELY, provided that this notice and licensing terms are retained in
+ * full, this file may be redistributed and/or modified under the terms of the
+ * GNU General Public License (GPL) Version 2, in which case the provisions of
+ * that version of the GPL will apply to you instead of the license terms
+ * above.  You can obtain a copy of the GPL Version 2 at
+ * http://developer.apple.com/opensource/licenses/gpl-2.txt.
+ */
+
+#ifndef _OSX_NTFS_COMPRESS_H
+#define _OSX_NTFS_COMPRESS_H
+
+#include <sys/errno.h>
+
+
+#include "ntfs_inode.h"
+#include "ntfs_types.h"
+
+/*__private_extern__ errno_t ntfs_read_compressed(ntfs_inode *ni,
+		ntfs_inode *raw_ni, s64 ofs, const int start_count,
+		u8 *dst_start, upl_page_info_t *pl, int ioflags);*/
+
+#endif /* !_OSX_NTFS_COMPRESS_H */

Added: soc2012/vbotton/head/sys/fs/ntfs/ntfs_debug.h
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ soc2012/vbotton/head/sys/fs/ntfs/ntfs_debug.h	Fri Jul 13 12:39:47 2012	(r239339)
@@ -0,0 +1,89 @@
+/*
+ * ntfs_debug.h - Defines for NTFS kernel debug support.
+ *
+ * Copyright (c) 2006-2008 Anton Altaparmakov.  All Rights Reserved.
+ * Portions Copyright (c) 2006-2008 Apple Inc.  All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ *    this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ *    this list of conditions and the following disclaimer in the documentation
+ *    and/or other materials provided with the distribution. 
+ * 3. Neither the name of Apple Inc. ("Apple") nor the names of its
+ *    contributors may be used to endorse or promote products derived from this
+ *    software without specific prior written permission. 
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * ALTERNATIVELY, provided that this notice and licensing terms are retained in
+ * full, this file may be redistributed and/or modified under the terms of the
+ * GNU General Public License (GPL) Version 2, in which case the provisions of
+ * that version of the GPL will apply to you instead of the license terms
+ * above.  You can obtain a copy of the GPL Version 2 at
+ * http://developer.apple.com/opensource/licenses/gpl-2.txt.
+ */
+
+#ifndef _OSX_NTFS_DEBUG_H
+#define _OSX_NTFS_DEBUG_H
+
+#include <sys/cdefs.h>
+
+#include "ntfs_runlist.h"
+
+/* Forward declaration so we do not have to include <sys/mount.h> here. */
+struct mount;
+
+__private_extern__ void ntfs_debug_init(void);
+__private_extern__ void ntfs_debug_deinit(void);
+
+__private_extern__ void __ntfs_warning(const char *function,
+		struct mount *mp, const char *fmt, ...) __printflike(3, 4);
+#define ntfs_warning(mp, fmt, a...)	\
+		__ntfs_warning(__FUNCTION__, mp, fmt, ##a)
+
+__private_extern__ void __ntfs_error(const char *function,
+		struct mount *mp, const char *fmt, ...) __printflike(3, 4);
+#define ntfs_error(mp, fmt, a...)	\
+		__ntfs_error(__FUNCTION__, mp, fmt, ##a)
+
+#ifdef DEBUG
+
+/**
+ * ntfs_debug - write a debug message to the console
+ * @fmt:	a printf format string containing the message
+ * @...:	the variables to substitute into @fmt
+ *
+ * ntfs_debug() writes a message to the console but only if the driver was
+ * compiled with -DDEBUG.  Otherwise, the call turns into a NOP.
+ */
+__private_extern__ void __ntfs_debug(const char *file, int line,
+		const char *function, const char *fmt, ...)
+		__printflike(4, 5);
+#define ntfs_debug(fmt, a...)		\
+		__ntfs_debug(__FILE__, __LINE__, __FUNCTION__, fmt, ##a)
+
+__private_extern__ void ntfs_debug_runlist_dump(const ntfs_runlist *rl);
+__private_extern__ void ntfs_debug_attr_list_dump(const u8 *al,
+		const unsigned size);
+
+#else /* !DEBUG */
+
+#define ntfs_debug(fmt, a...)			do {} while (0)
+#define ntfs_debug_runlist_dump(rl)		do {} while (0)
+#define ntfs_debug_attr_list_dump(al, size)	do {} while (0)
+
+#endif /* !DEBUG */
+
+#endif /* !_OSX_NTFS_DEBUG_H */

Added: soc2012/vbotton/head/sys/fs/ntfs/ntfs_dir.h
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ soc2012/vbotton/head/sys/fs/ntfs/ntfs_dir.h	Fri Jul 13 12:39:47 2012	(r239339)
@@ -0,0 +1,110 @@
+/*
+ * ntfs_dir.h - Defines for directory handling in the NTFS kernel driver.
+ *
+ * Copyright (c) 2006-2008 Anton Altaparmakov.  All Rights Reserved.
+ * Portions Copyright (c) 2006-2008 Apple Inc.  All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ *    this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ *    this list of conditions and the following disclaimer in the documentation
+ *    and/or other materials provided with the distribution. 
+ * 3. Neither the name of Apple Inc. ("Apple") nor the names of its
+ *    contributors may be used to endorse or promote products derived from this
+ *    software without specific prior written permission. 
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * ALTERNATIVELY, provided that this notice and licensing terms are retained in
+ * full, this file may be redistributed and/or modified under the terms of the
+ * GNU General Public License (GPL) Version 2, in which case the provisions of
+ * that version of the GPL will apply to you instead of the license terms
+ * above.  You can obtain a copy of the GPL Version 2 at
+ * http://developer.apple.com/opensource/licenses/gpl-2.txt.
+ */
+
+#ifndef _OSX_NTFS_DIR_H
+#define _OSX_NTFS_DIR_H
+
+#include <sys/errno.h>
+#include <sys/uio.h>
+
+#include "ntfs.h"
+#include "ntfs_inode.h"
+#include "ntfs_layout.h"
+#include "ntfs_types.h"
+
+/*
+ * ntfs_name is used to return the actual found filename to the caller of
+ * ntfs_lookup_inode_by_name() in order for the caller
+ * (ntfs_vnops.c::ntfs_vnop_lookup()) to be able to deal with the case
+ * sensitive name cache effectively.
+ */
+typedef struct {
+	MFT_REF mref;
+	FILENAME_TYPE_FLAGS type;
+	u8 len;
+	ntfschar name[NTFS_MAX_NAME_LEN];
+} ntfs_dir_lookup_name;
+
+/* The little endian Unicode string $I30 as a global constant. */
+__private_extern__ ntfschar I30[5];
+
+__private_extern__ errno_t ntfs_lookup_inode_by_name(ntfs_inode *dir_ni,
+		const ntfschar *uname, const signed uname_len,
+		MFT_REF *res_mref, ntfs_dir_lookup_name **res_name);
+
+//__private_extern__ errno_t ntfs_readdir(ntfs_inode *dir_ni, uio_t uio,
+//		int *eofflag, int *numdirent);
+
+__private_extern__ errno_t ntfs_dir_is_empty(ntfs_inode *dir_ni);
+
+__private_extern__ errno_t ntfs_dir_entry_delete(ntfs_inode *dir_ni,
+		ntfs_inode *ni, const FILENAME_ATTR *fn, const u32 fn_len);
+
+__private_extern__ errno_t ntfs_dir_entry_add(ntfs_inode *dir_ni,
+		const FILENAME_ATTR *fn, const u32 fn_len,
+		const leMFT_REF mref);
+
+/**
+ * struct _ntfs_dirhint - directory hint structure
+ *
+ * This is used to store state across directory enumerations, i.e. across calls
+ * to ntfs_readdir().
+ */
+struct _ntfs_dirhint {
+	TAILQ_ENTRY(_ntfs_dirhint) link;
+	unsigned ofs;
+	unsigned time;
+	unsigned fn_size;
+	FILENAME_ATTR *fn;
+};
+typedef struct _ntfs_dirhint ntfs_dirhint;
+
+/*
+ * NTFS_MAX_DIRHINTS cannot be larger than 63 without reducing
+ * NTFS_DIR_POS_MASK, because given the 6-bit tag, at most 63 different tags
+ * can exist.  When NTFS_MAX_DIRHINTS is larger than 63, the same list may
+ * contain dirhints of the same tag, and a staled dirhint may be returned.

*** DIFF OUTPUT TRUNCATED AT 1000 LINES ***



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20120713123948.73956106564A>