socsvn commit: r237468 - soc2012/vbotton/ntfs_apple

vbotton at FreeBSD.org vbotton at FreeBSD.org
Mon Jun 11 15:04:37 UTC 2012


Author: vbotton
Date: Mon Jun 11 15:04:34 2012
New Revision: 237468
URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=237468

Log:
  Endianness function, and first allocation changed

Modified:
  soc2012/vbotton/ntfs_apple/ntfs_dir.c
  soc2012/vbotton/ntfs_apple/ntfs_index.h
  soc2012/vbotton/ntfs_apple/ntfs_inode.h
  soc2012/vbotton/ntfs_apple/ntfs_types.h

Modified: soc2012/vbotton/ntfs_apple/ntfs_dir.c
==============================================================================
--- soc2012/vbotton/ntfs_apple/ntfs_dir.c	Mon Jun 11 14:02:02 2012	(r237467)
+++ soc2012/vbotton/ntfs_apple/ntfs_dir.c	Mon Jun 11 15:04:34 2012	(r237468)
@@ -168,10 +168,10 @@
 	 * ntfs_index_inode_read()).
 	 */
 	ir = (INDEX_ROOT*)((u8*)ctx->a + le16toh(ctx->a->value_offset));
-	index_end = (u8*)&ir->index + le32_to_cpu(ir->index.index_length);
+	index_end = (u8*)&ir->index + le32toh(ir->index.index_length);
 	/* The first index entry. */
 	ie = (INDEX_ENTRY*)((u8*)&ir->index +
-			le32_to_cpu(ir->index.entries_offset));
+			le32toh(ir->index.entries_offset));
 	/*
 	 * Loop until we exceed valid memory (corruption case) or until we
 	 * reach the last entry.
@@ -220,9 +220,8 @@
 				u8 len;
 
 				if (!name) {
-					*res_name = name = OSMalloc(
-							sizeof(*name),
-							ntfs_malloc_tag);
+					*res_name = name = malloc(
+							sizeof(*name));
 					if (!name) {
 						err = ENOMEM;
 						goto put_err;
@@ -236,8 +235,7 @@
 						len * sizeof(ntfschar));
 			} else {
 				if (name)
-					OSFree(name, sizeof(*name),
-							ntfs_malloc_tag);
+					free(name);
 				*res_name = NULL;
 			}
 			*res_mref = le64toh(ie->indexed_file);
@@ -271,9 +269,8 @@
 				u8 len;
 
 				if (!name) {
-					*res_name = name = OSMalloc(
-							sizeof(*name),
-							ntfs_malloc_tag);
+					*res_name = name = malloc(
+							sizeof(*name));
 					if (!name) {
 						err = ENOMEM;
 						goto put_err;
@@ -347,7 +344,7 @@
 		goto put_err;
 	}
 	/* Get the starting vcn of the index block holding the child node. */
-	vcn = sle64tohp((sle64*)((u8*)ie + le16toh(ie->length) - 8));
+	vcn = le64toh(*(sle64*)((u8*)ie + le16toh(ie->length) - 8));
 	/*
 	 * We are done with the index root and the mft record.  Release them,
 	 * otherwise we deadlock with ntfs_page_map().
@@ -398,7 +395,7 @@
 		goto page_err;
 	}
 	if (offsetof(INDEX_BLOCK, index) +
-			le32_to_cpu(ia->index.allocated_size) !=
+			le32toh(ia->index.allocated_size) !=
 			ia_ni->block_size) {
 		ntfs_error(mp, "Index buffer (VCN 0x%llx) of directory inode "
 				"0x%llx has a size (%u) differing from the "
@@ -407,7 +404,7 @@
 				(unsigned long long)vcn,
 				(unsigned long long)dir_ni->mft_no, (unsigned)
 				(offsetof(INDEX_BLOCK, index) +
-				le32_to_cpu(ia->index.allocated_size)),
+				le32toh(ia->index.allocated_size)),
 				(unsigned)ia_ni->block_size);
 		goto page_err;
 	}
@@ -420,7 +417,7 @@
 				(unsigned long long)dir_ni->mft_no);
 		goto page_err;
 	}
-	index_end = (u8*)&ia->index + le32_to_cpu(ia->index.index_length);
+	index_end = (u8*)&ia->index + le32toh(ia->index.index_length);
 	if (index_end > (u8*)ia + ia_ni->block_size) {
 		ntfs_error(mp, "Size of index buffer (VCN 0x%llx) of directory "
 				"inode 0x%llx exceeds maximum size.",
@@ -430,7 +427,7 @@
 	}
 	/* The first index entry. */
 	ie = (INDEX_ENTRY*)((u8*)&ia->index +
-			le32_to_cpu(ia->index.entries_offset));
+			le32toh(ia->index.entries_offset));
 	/*
 	 * Iterate similar to above big loop but applied to index buffer, thus
 	 * loop until we exceed valid memory (corruption case) or until we
@@ -482,9 +479,8 @@
 				u8 len;
 
 				if (!name) {
-					*res_name = name = OSMalloc(
-							sizeof(*name),
-							ntfs_malloc_tag);
+					*res_name = name = malloc(
+							sizeof(*name));
 					if (!name) {
 						err = ENOMEM;
 						goto page_err;
@@ -498,8 +494,7 @@
 						len * sizeof(ntfschar));
 			} else {
 				if (name)
-					OSFree(name, sizeof(*name),
-							ntfs_malloc_tag);
+					free(name);
 				*res_name = NULL;
 			}
 			*res_mref = le64toh(ie->indexed_file);
@@ -1582,10 +1577,10 @@
 	 * ntfs_inode_read()).
 	 */
 	ir = (INDEX_ROOT*)((u8*)ctx->a + le16toh(ctx->a->value_offset));
-	index_end = (u8*)&ir->index + le32_to_cpu(ir->index.index_length);
+	index_end = (u8*)&ir->index + le32toh(ir->index.index_length);
 	/* The first index entry. */
 	ie = (INDEX_ENTRY*)((u8*)&ir->index +
-			le32_to_cpu(ir->index.entries_offset));
+			le32toh(ir->index.entries_offset));
 	/* Bounds checks. */
 	if ((u8*)ie < (u8*)&ir->index ||
 			(u8*)ie + sizeof(INDEX_ENTRY_HEADER) > index_end ||
@@ -1713,7 +1708,7 @@
 		goto vol_err;
 	}
 	if (offsetof(INDEX_BLOCK, index) +
-			le32_to_cpu(ia->index.allocated_size) !=
+			le32toh(ia->index.allocated_size) !=
 			ia_ni->block_size) {
 		ntfs_error(vol->mp, "Index buffer (VCN 0x%llx) has a size "
 				"(%u) differing from the directory specified "
@@ -1721,7 +1716,7 @@
 				(unsigned long long)
 				sle64toh(ia->index_block_vcn),
 				(unsigned)(offsetof(INDEX_BLOCK, index) +
-				le32_to_cpu(ia->index.allocated_size)),
+				le32toh(ia->index.allocated_size)),
 				(unsigned)ia_ni->block_size, es1,
 				(unsigned long long)dir_ni->mft_no, es2);
 		goto vol_err;
@@ -1737,7 +1732,7 @@
 				(unsigned long long)dir_ni->mft_no);
 		goto vol_err;
 	}
-	index_end = (u8*)&ia->index + le32_to_cpu(ia->index.index_length);
+	index_end = (u8*)&ia->index + le32toh(ia->index.index_length);
 	if (index_end > (u8*)ia + ia_ni->block_size) {
 		ntfs_error(vol->mp, "Size of index block (VCN 0x%llx) "
 				"exceeds maximum size%s%llx%s",
@@ -1748,7 +1743,7 @@
 	}
 	/* The first index entry. */
 	ie = (INDEX_ENTRY*)((u8*)&ia->index +
-			le32_to_cpu(ia->index.entries_offset));
+			le32toh(ia->index.entries_offset));
 	/* Bounds checks. */
 	if ((u8*)ie < (u8*)&ia->index ||
 			(u8*)ie + sizeof(INDEX_ENTRY_HEADER) > index_end ||

Modified: soc2012/vbotton/ntfs_apple/ntfs_index.h
==============================================================================
--- soc2012/vbotton/ntfs_apple/ntfs_index.h	Mon Jun 11 14:02:02 2012	(r237467)
+++ soc2012/vbotton/ntfs_apple/ntfs_index.h	Mon Jun 11 15:04:34 2012	(r237468)
@@ -39,6 +39,9 @@
 #define _OSX_NTFS_INDEX_H
 
 #include <sys/errno.h>
+#include <sys/param.h>
+#include <sys/malloc.h>
+#include <sys/kernel.h>
 
 /* Foward declaration. */
 typedef struct _ntfs_index_context ntfs_index_context;
@@ -48,7 +51,6 @@
 #include "ntfs_layout.h"
 #include "ntfs_types.h"
 
-#include <stdlib.h>
 /**
  * @up:		pointer to index context located directly above in the tree
  * @down:	pointer to index context located directly below in the tree
@@ -234,6 +236,8 @@
 	u8 *right_addr;
 };
 
+MALLOC_DECLARE(M_INDEX_NTFS_CONTEXT);
+MALLOC_DEFINE(M_INDEX_NTFS_CONTEXT, "indexcontext", "index context");
 
 /**
  * ntfs_index_ctx_alloc - allocate an index context
@@ -242,7 +246,7 @@
  */
 inline ntfs_index_context *ntfs_index_ctx_alloc(void)
 {
-	return malloc(sizeof(ntfs_index_context));
+	return malloc(sizeof(ntfs_index_context), M_INDEX_NTFS_CONTEXT, M_WAITOK);
 }
 
 /**
@@ -316,7 +320,7 @@
  */
 static inline void ntfs_index_ctx_free(ntfs_index_context *ictx)
 {
-	free(ictx);
+	free(ictx, M_INDEX_NTFS_CONTEXT);
 }
 
 /**

Modified: soc2012/vbotton/ntfs_apple/ntfs_inode.h
==============================================================================
--- soc2012/vbotton/ntfs_apple/ntfs_inode.h	Mon Jun 11 14:02:02 2012	(r237467)
+++ soc2012/vbotton/ntfs_apple/ntfs_inode.h	Mon Jun 11 15:04:34 2012	(r237468)
@@ -38,15 +38,18 @@
 #ifndef _OSX_NTFS_INODE_H
 #define _OSX_NTFS_INODE_H
 
+#include <sys/types.h>
+#include <sys/systm.h>
 #include <sys/buf.h>
 #include <sys/errno.h>
 #include <sys/proc.h>
 #include <sys/queue.h>
 #include <sys/time.h>
-#include <sys/types.h>
 #include <sys/ucred.h>
 #include <sys/vnode.h>
 #include <sys/mutex.h>
+#include <sys/proc.h>
+#include <sys/param.h>
 
 /* Forward declarations. */
 typedef struct _ntfs_inode ntfs_inode;
@@ -464,7 +467,8 @@
  */
 static inline ntfs_inode *NTFS_I(struct vnode *vn)
 {
-	return vnode_fsnode(vn);
+	return (ntfs_inode*)vn->v_data;
+	//return vnode_fsnode(vn);
 }
 
 /**

Modified: soc2012/vbotton/ntfs_apple/ntfs_types.h
==============================================================================
--- soc2012/vbotton/ntfs_apple/ntfs_types.h	Mon Jun 11 14:02:02 2012	(r237467)
+++ soc2012/vbotton/ntfs_apple/ntfs_types.h	Mon Jun 11 15:04:34 2012	(r237468)
@@ -113,7 +113,7 @@
 
 typedef int errno_t;
 typedef unsigned int	lck_rw_type_t;
-typedef struct mount 	mount_t;
-typedef struct vnode	vnode_t;
+typedef struct mount* 	mount_t;
+typedef struct vnode*	vnode_t;
 
 #endif /* !_OSX_NTFS_TYPES_H */


More information about the svn-soc-all mailing list