2 * Copyright (c) 2000-2004 Apple Computer, 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 #include <sys/param.h>
30 #include <sys/systm.h>
32 #include <sys/kernel.h>
33 #include <sys/malloc.h>
34 #include <sys/mount.h>
35 #include <sys/vnode.h>
39 #include "hfs_cnode.h"
41 #include "hfs_endian.h"
43 #include "hfscommon/headers/FileMgrInternal.h"
44 #include "hfscommon/headers/BTreesPrivate.h"
46 #define FORCESYNCBTREEWRITES 0
49 static int ClearBTNodes(struct vnode
*vp
, long blksize
, off_t offset
, off_t amount
);
53 OSStatus
SetBTreeBlockSize(FileReference vp
, ByteCount blockSize
, ItemCount minBlockCount
)
55 BTreeControlBlockPtr bTreePtr
;
57 DBG_ASSERT(vp
!= NULL
);
58 DBG_ASSERT(blockSize
>= kMinNodeSize
);
59 if (blockSize
> MAXBSIZE
)
60 return (fsBTBadNodeSize
);
62 bTreePtr
= (BTreeControlBlockPtr
)VTOF(vp
)->fcbBTCBPtr
;
63 bTreePtr
->nodeSize
= blockSize
;
70 OSStatus
GetBTreeBlock(FileReference vp
, UInt32 blockNum
, GetBlockOptions options
, BlockDescriptor
*block
)
72 OSStatus retval
= E_NONE
;
73 struct buf
*bp
= NULL
;
75 if (options
& kGetEmptyBlock
) {
79 offset
= (daddr64_t
)blockNum
* (daddr64_t
)block
->blockSize
;
80 bp
= buf_getblk(vp
, (daddr64_t
)blockNum
, block
->blockSize
, 0, 0, BLK_META
);
82 VNOP_BLOCKMAP(vp
, offset
, block
->blockSize
, &blkno
, NULL
, NULL
, 0, NULL
) == 0) {
83 buf_setblkno(bp
, blkno
);
86 retval
= buf_meta_bread(vp
, (daddr64_t
)blockNum
, block
->blockSize
, NOCRED
, &bp
);
89 retval
= -1; //XXX need better error
91 if (retval
== E_NONE
) {
92 block
->blockHeader
= bp
;
93 block
->buffer
= (char *)buf_dataptr(bp
);
94 block
->blockNum
= buf_lblkno(bp
);
95 block
->blockReadFromDisk
= (buf_fromcache(bp
) == 0); /* not found in cache ==> came from disk */
98 block
->isModified
= 0;
100 /* Check and endian swap B-Tree node (only if it's a valid block) */
101 if (!(options
& kGetEmptyBlock
)) {
102 /* This happens when we first open the b-tree, we might not have all the node data on hand */
103 if ((((BTNodeDescriptor
*)block
->buffer
)->kind
== kBTHeaderNode
) &&
104 (((BTHeaderRec
*)((char *)block
->buffer
+ 14))->nodeSize
!= buf_count(bp
)) &&
105 (SWAP_BE16 (((BTHeaderRec
*)((char *)block
->buffer
+ 14))->nodeSize
) != buf_count(bp
))) {
108 * Don't swap the node descriptor, record offsets, or other records.
109 * This record will be invalidated and re-read with the correct node
110 * size once the B-tree control block is set up with the node size
111 * from the header record.
113 retval
= hfs_swap_BTNode (block
, vp
, kSwapBTNodeHeaderRecordOnly
);
115 } else if (block
->blockReadFromDisk
) {
117 * The node was just read from disk, so always swap/check it.
118 * This is necessary on big endian since the test below won't trigger.
120 retval
= hfs_swap_BTNode (block
, vp
, kSwapBTNodeBigToHost
);
121 } else if (*((UInt16
*)((char *)block
->buffer
+ (block
->blockSize
- sizeof (UInt16
)))) == 0x0e00) {
123 * The node was left in the cache in non-native order, so swap it.
124 * This only happens on little endian, after the node is written
127 retval
= hfs_swap_BTNode (block
, vp
, kSwapBTNodeBigToHost
);
131 * If we got an error, then the node is only partially swapped.
132 * We mark the buffer invalid so that the next attempt to get the
133 * node will read it and attempt to swap again, and will notice
134 * the error again. If we didn't do this, the next attempt to get
135 * the node might use the partially swapped node as-is.
145 block
->blockHeader
= NULL
;
146 block
->buffer
= NULL
;
154 void ModifyBlockStart(FileReference vp
, BlockDescPtr blockPtr
)
156 struct hfsmount
*hfsmp
= VTOHFS(vp
);
157 struct buf
*bp
= NULL
;
159 if (hfsmp
->jnl
== NULL
) {
163 bp
= (struct buf
*) blockPtr
->blockHeader
;
165 panic("ModifyBlockStart: null bp for blockdescptr 0x%x?!?\n", blockPtr
);
169 journal_modify_block_start(hfsmp
->jnl
, bp
);
170 blockPtr
->isModified
= 1;
174 btree_journal_modify_block_end(struct hfsmount
*hfsmp
, struct buf
*bp
)
177 struct vnode
*vp
= buf_vnode(bp
);
178 BlockDescriptor block
;
180 /* Prepare the block pointer */
181 block
.blockHeader
= bp
;
182 block
.buffer
= (char *)buf_dataptr(bp
);
183 block
.blockNum
= buf_lblkno(bp
);
184 /* not found in cache ==> came from disk */
185 block
.blockReadFromDisk
= (buf_fromcache(bp
) == 0);
186 block
.blockSize
= buf_count(bp
);
188 // XXXdbg have to swap the data before it goes in the journal
189 retval
= hfs_swap_BTNode (&block
, vp
, kSwapBTNodeHostToBig
);
191 panic("btree_journal_modify_block_end: about to write corrupt node!\n");
193 return journal_modify_block_end(hfsmp
->jnl
, bp
);
198 OSStatus
ReleaseBTreeBlock(FileReference vp
, BlockDescPtr blockPtr
, ReleaseBlockOptions options
)
200 struct hfsmount
*hfsmp
= VTOHFS(vp
);
201 extern int bdwrite_internal(struct buf
*, int);
202 OSStatus retval
= E_NONE
;
203 struct buf
*bp
= NULL
;
205 bp
= (struct buf
*) blockPtr
->blockHeader
;
212 if (options
& kTrashBlock
) {
215 if (hfsmp
->jnl
&& (buf_flags(bp
) & B_LOCKED
)) {
216 journal_kill_block(hfsmp
->jnl
, bp
);
218 buf_brelse(bp
); /* note: B-tree code will clear blockPtr->blockHeader and blockPtr->buffer */
221 if (options
& kForceWriteBlock
) {
223 if (blockPtr
->isModified
== 0) {
224 panic("hfs: releaseblock: modified is 0 but forcewrite set! bp 0x%x\n", bp
);
227 retval
= btree_journal_modify_block_end(hfsmp
, bp
);
228 blockPtr
->isModified
= 0;
230 retval
= VNOP_BWRITE(bp
);
232 } else if (options
& kMarkBlockDirty
) {
235 if ((options
& kLockTransaction
) && hfsmp
->jnl
== NULL
) {
238 * Set the B_LOCKED flag and unlock the buffer, causing buf_brelse to move
239 * the buffer onto the LOCKED free list. This is necessary, otherwise
240 * getnewbuf() would try to reclaim the buffers using buf_bawrite, which
241 * isn't going to work.
244 extern int count_lock_queue(void);
246 /* Don't hog all the buffers... */
247 if (count_lock_queue() > kMaxLockedMetaBuffers
) {
248 hfs_btsync(vp
, HFS_SYNCTRANS
);
249 /* Rollback sync time to cause a sync on lock release... */
250 (void) BTSetLastSync(VTOF(vp
), tv
.tv_sec
- (kMaxSecsForFsync
+ 1));
252 buf_setflags(bp
, B_LOCKED
);
256 * Delay-write this block.
257 * If the maximum delayed buffers has been exceeded then
258 * free up some buffers and fall back to an asynchronous write.
261 if (blockPtr
->isModified
== 0) {
262 panic("hfs: releaseblock: modified is 0 but markdirty set! bp 0x%x\n", bp
);
264 retval
= btree_journal_modify_block_end(hfsmp
, bp
);
265 blockPtr
->isModified
= 0;
266 } else if (bdwrite_internal(bp
, 1) != 0) {
268 /* Rollback sync time to cause a sync on lock release... */
269 (void) BTSetLastSync(VTOF(vp
), tv
.tv_sec
- (kMaxSecsForFsync
+ 1));
271 buf_clearflags(bp
, B_LOCKED
);
275 // check if we had previously called journal_modify_block_start()
276 // on this block and if so, abort it (which will call buf_brelse()).
277 if (hfsmp
->jnl
&& blockPtr
->isModified
) {
278 // XXXdbg - I don't want to call modify_block_abort()
279 // because I think it may be screwing up the
280 // journal and blowing away a block that has
283 // journal_modify_block_abort(hfsmp->jnl, bp);
284 //panic("hfs: releaseblock called for 0x%x but mod_block_start previously called.\n", bp);
285 btree_journal_modify_block_end(hfsmp
, bp
);
286 blockPtr
->isModified
= 0;
288 buf_brelse(bp
); /* note: B-tree code will clear blockPtr->blockHeader and blockPtr->buffer */
298 #define HFS_CLUMP_ADJ_LIMIT (200*1024*1024)
301 OSStatus
ExtendBTreeFile(FileReference vp
, FSSize minEOF
, FSSize maxEOF
)
303 #pragma unused (maxEOF)
305 OSStatus retval
= 0, ret
= 0;
306 UInt64 actualBytesAdded
, origSize
;
308 u_int32_t startAllocation
;
309 u_int32_t fileblocks
;
313 struct proc
*p
= NULL
;
317 filePtr
= GetFileControlBlock(vp
);
319 if ( minEOF
> filePtr
->fcbEOF
)
321 bytesToAdd
= minEOF
- filePtr
->fcbEOF
;
323 if (bytesToAdd
< filePtr
->ff_clumpsize
)
324 bytesToAdd
= filePtr
->ff_clumpsize
; //XXX why not always be a mutiple of clump size?
333 /* Take past growth into account when extending the catalog file. */
334 if ((VTOC(vp
)->c_fileid
== kHFSCatalogFileID
) &&
335 (bytesToAdd
/ vcb
->blockSize
) < filePtr
->fcbExtents
[0].blockCount
) {
336 bytesToAdd
= filePtr
->fcbExtents
[0].blockCount
* (UInt64
)vcb
->blockSize
;
337 bytesToAdd
= MIN(bytesToAdd
, HFS_CLUMP_ADJ_LIMIT
);
340 * The Extents B-tree can't have overflow extents. ExtendFileC will
341 * return an error if an attempt is made to extend the Extents B-tree
342 * when the resident extents are exhausted.
345 /* Protect allocation bitmap and extents overflow file. */
346 lockflags
= SFL_BITMAP
;
347 if (VTOC(vp
)->c_fileid
!= kHFSExtentsFileID
)
348 lockflags
|= SFL_EXTENTS
;
349 lockflags
= hfs_systemfile_lock(vcb
, lockflags
, HFS_EXCLUSIVE_LOCK
);
351 (void) BTGetInformation(filePtr
, 0, &btInfo
);
355 * The b-tree code expects nodes to be contiguous. So when
356 * the allocation block size is less than the b-tree node
357 * size, we need to force disk allocations to be contiguous.
359 if (vcb
->blockSize
>= btInfo
.nodeSize
) {
362 /* Ensure that all b-tree nodes are contiguous on disk */
363 extendFlags
= kEFContigMask
;
367 origSize
= filePtr
->fcbEOF
;
368 fileblocks
= filePtr
->ff_blocks
;
369 startAllocation
= vcb
->nextAllocation
;
371 // loop trying to get a contiguous chunk that's an integer multiple
372 // of the btree node size. if we can't get a contiguous chunk that
373 // is at least the node size then we break out of the loop and let
374 // the error propagate back up.
376 retval
= ExtendFileC(vcb
, filePtr
, bytesToAdd
, 0,
377 kEFContigMask
| kEFMetadataMask
,
379 if (retval
== dskFulErr
&& actualBytesAdded
== 0) {
381 if (bytesToAdd
== btInfo
.nodeSize
|| bytesToAdd
< (minEOF
- origSize
)) {
382 // if we're here there's nothing else to try, we're out
383 // of space so we break and bail out.
387 if (bytesToAdd
< btInfo
.nodeSize
) {
388 bytesToAdd
= btInfo
.nodeSize
;
389 } else if ((bytesToAdd
% btInfo
.nodeSize
) != 0) {
390 // make sure it's an integer multiple of the nodeSize
391 bytesToAdd
-= (bytesToAdd
% btInfo
.nodeSize
);
395 } while (retval
== dskFulErr
&& actualBytesAdded
== 0);
398 * If a new extent was added then move the roving allocator
399 * reference forward by the current b-tree file size so
400 * there's plenty of room to grow.
403 ((VCBTOHFS(vcb
)->hfs_flags
& HFS_METADATA_ZONE
) == 0) &&
404 (vcb
->nextAllocation
> startAllocation
) &&
405 ((vcb
->nextAllocation
+ fileblocks
) < vcb
->totalBlocks
)) {
406 vcb
->nextAllocation
+= fileblocks
;
409 filePtr
->fcbEOF
= (u_int64_t
)filePtr
->ff_blocks
* (u_int64_t
)vcb
->blockSize
;
411 // XXXdbg ExtendFileC() could have returned an error even though
412 // it grew the file to be big enough for our needs. If this is
413 // the case, we don't care about retval so we blow it away.
415 if (filePtr
->fcbEOF
>= minEOF
&& retval
!= 0) {
419 // XXXdbg if the file grew but isn't large enough or isn't an
420 // even multiple of the nodeSize then trim things back. if
421 // the file isn't large enough we trim back to the original
422 // size. otherwise we trim back to be an even multiple of the
425 if ((filePtr
->fcbEOF
< minEOF
) || (actualBytesAdded
% btInfo
.nodeSize
) != 0) {
427 if (filePtr
->fcbEOF
< minEOF
) {
430 if (filePtr
->fcbEOF
< origSize
) {
431 panic("hfs: btree file eof %lld less than orig size %lld!\n",
432 filePtr
->fcbEOF
, origSize
);
435 trim
= filePtr
->fcbEOF
- origSize
;
436 if (trim
!= actualBytesAdded
) {
437 panic("hfs: trim == %lld but actualBytesAdded == %lld\n",
438 trim
, actualBytesAdded
);
441 trim
= (actualBytesAdded
% btInfo
.nodeSize
);
444 ret
= TruncateFileC(vcb
, filePtr
, filePtr
->fcbEOF
- trim
, 0);
445 filePtr
->fcbEOF
= (u_int64_t
)filePtr
->ff_blocks
* (u_int64_t
)vcb
->blockSize
;
447 // XXXdbg - panic if the file didn't get trimmed back properly
448 if ((filePtr
->fcbEOF
% btInfo
.nodeSize
) != 0) {
449 panic("hfs: truncate file didn't! fcbEOF %lld nsize %d fcb 0x%x\n",
450 filePtr
->fcbEOF
, btInfo
.nodeSize
, filePtr
);
454 // XXXdbg - this probably doesn't need to be a panic()
455 panic("hfs: error truncating btree files (sz 0x%llx, trim %lld, ret %d)\n",
456 filePtr
->fcbEOF
, trim
, ret
);
459 actualBytesAdded
-= trim
;
462 if(VTOC(vp
)->c_fileid
!= kHFSExtentsFileID
) {
464 * Get any extents overflow b-tree changes to disk ASAP!
466 (void) BTFlushPath(VTOF(vcb
->extentsRefNum
));
467 (void) hfs_fsync(vcb
->extentsRefNum
, MNT_WAIT
, 0, p
);
469 hfs_systemfile_unlock(vcb
, lockflags
);
472 if ((filePtr
->fcbEOF
% btInfo
.nodeSize
) != 0) {
473 panic("hfs: extendbtree: fcb 0x%x has eof 0x%llx not a multiple of 0x%x (trim %llx)\n",
474 filePtr
, filePtr
->fcbEOF
, btInfo
.nodeSize
, trim
);
478 * Update the Alternate MDB or Alternate VolumeHeader
480 if ((VTOC(vp
)->c_fileid
== kHFSExtentsFileID
) ||
481 (VTOC(vp
)->c_fileid
== kHFSCatalogFileID
) ||
482 (VTOC(vp
)->c_fileid
== kHFSAttributesFileID
)
484 VTOC(vp
)->c_flag
|= C_MODIFIED
;
486 ret
= hfs_flushvolumeheader(VCBTOHFS(vcb
), MNT_WAIT
, HFS_ALTFLUSH
);
488 VTOC(vp
)->c_touch_chgtime
= TRUE
;
489 VTOC(vp
)->c_touch_modtime
= TRUE
;
490 (void) hfs_update(vp
, TRUE
);
493 ret
= ClearBTNodes(vp
, btInfo
.nodeSize
, filePtr
->fcbEOF
- actualBytesAdded
, actualBytesAdded
);
499 hfs_systemfile_unlock(vcb
, lockflags
);
506 * Clear out (zero) new b-tree nodes on disk.
509 ClearBTNodes(struct vnode
*vp
, long blksize
, off_t offset
, off_t amount
)
511 struct hfsmount
*hfsmp
= VTOHFS(vp
);
512 struct buf
*bp
= NULL
;
516 blk
= offset
/ blksize
;
517 blkcnt
= amount
/ blksize
;
520 bp
= buf_getblk(vp
, blk
, blksize
, 0, 0, BLK_META
);
526 // XXXdbg -- skipping this for now since it makes a transaction
527 // become *way* too large
528 //journal_modify_block_start(hfsmp->jnl, bp);
530 bzero((char *)buf_dataptr(bp
), blksize
);
536 // XXXdbg -- skipping this for now since it makes a transaction
537 // become *way* too large
538 //journal_modify_block_end(hfsmp->jnl, bp);
540 // XXXdbg - remove this once we decide what to do with the
541 // writes to the journal
547 /* wait/yield every 32 blocks so we don't hog all the buffers */
561 extern char hfs_attrname
[];
563 extern int hfs_attrkeycompare(HFSPlusAttrKey
*searchKey
, HFSPlusAttrKey
*trialKey
);
565 int hfs_create_attr_btree(struct hfsmount
*hfsmp
, uint32_t nodesize
, uint32_t nodecnt
);
568 * Create an HFS+ Attribute B-tree File.
570 * A journal transaction must be already started.
573 hfs_create_attr_btree(struct hfsmount
*hfsmp
, uint32_t nodesize
, uint32_t nodecnt
)
575 struct vnode
* vp
= NULL
;
576 struct cat_desc cndesc
;
577 struct cat_attr cnattr
;
578 struct cat_fork cfork
;
579 BlockDescriptor blkdesc
;
580 BTNodeDescriptor
*ndp
;
582 BTreeControlBlockPtr btcb
= NULL
;
583 struct buf
*bp
= NULL
;
589 printf("Creating HFS+ Attribute B-tree File (%d nodes) on %s\n", nodecnt
, hfsmp
->vcbVN
);
592 * Set up Attribute B-tree vnode
594 bzero(&cndesc
, sizeof(cndesc
));
595 cndesc
.cd_parentcnid
= kHFSRootParentID
;
596 cndesc
.cd_flags
|= CD_ISMETA
;
597 cndesc
.cd_nameptr
= hfs_attrname
;
598 cndesc
.cd_namelen
= strlen(hfs_attrname
);
599 cndesc
.cd_cnid
= kHFSAttributesFileID
;
601 bzero(&cnattr
, sizeof(cnattr
));
603 cnattr
.ca_mode
= S_IFREG
;
604 cnattr
.ca_fileid
= cndesc
.cd_cnid
;
606 bzero(&cfork
, sizeof(cfork
));
607 cfork
.cf_clump
= nodesize
* nodecnt
;
609 result
= hfs_getnewvnode(hfsmp
, NULL
, NULL
, &cndesc
, 0, &cnattr
, &cfork
, &vp
);
614 * Set up Attribute B-tree control block
616 MALLOC(btcb
, BTreeControlBlock
*, sizeof(BTreeControlBlock
), M_TEMP
, M_WAITOK
);
617 bzero(btcb
, sizeof(BTreeControlBlock
));
619 btcb
->nodeSize
= nodesize
;
620 btcb
->maxKeyLength
= kHFSPlusAttrKeyMaximumLength
;
621 btcb
->btreeType
= 0xFF;
622 btcb
->attributes
= kBTVariableIndexKeysMask
| kBTBigKeysMask
;
623 btcb
->version
= kBTreeVersion
;
624 btcb
->writeCount
= 1;
625 btcb
->flags
= 0; /* kBTHeaderDirty */
626 btcb
->fileRefNum
= vp
;
627 btcb
->getBlockProc
= GetBTreeBlock
;
628 btcb
->releaseBlockProc
= ReleaseBTreeBlock
;
629 btcb
->setEndOfForkProc
= ExtendBTreeFile
;
630 btcb
->keyCompareProc
= (KeyCompareProcPtr
)hfs_attrkeycompare
;
631 VTOF(vp
)->fcbBTCBPtr
= btcb
;
634 * Allocate some space
636 result
= ExtendBTreeFile(vp
, nodesize
, cfork
.cf_clump
);
640 btcb
->totalNodes
= VTOF(vp
)->ff_size
/ nodesize
;
641 btcb
->freeNodes
= btcb
->totalNodes
- 1;
644 * Initialize the b-tree header on disk
646 bp
= buf_getblk(vp
, 0, nodesize
, 0, 0, BLK_META
);
652 buffer
= (void *)buf_dataptr(bp
);
653 blkdesc
.buffer
= buffer
;
654 blkdesc
.blockHeader
= (void *)bp
;
655 blkdesc
.blockReadFromDisk
= 0;
656 blkdesc
.isModified
= 0;
658 ModifyBlockStart(vp
, &blkdesc
);
660 if (buf_size(bp
) != nodesize
)
661 panic("hfs_create_attr_btree: bad buffer size (%d)\n", buf_size(bp
));
663 bzero(buffer
, nodesize
);
664 index
= (int16_t *)buffer
;
666 /* FILL IN THE NODE DESCRIPTOR: */
667 ndp
= (BTNodeDescriptor
*)buffer
;
668 ndp
->kind
= kBTHeaderNode
;
670 offset
= sizeof(BTNodeDescriptor
);
671 index
[(nodesize
/ 2) - 1] = offset
;
673 /* FILL IN THE HEADER RECORD: */
674 bthp
= (BTHeaderRec
*)((UInt8
*)buffer
+ offset
);
675 bthp
->nodeSize
= nodesize
;
676 bthp
->totalNodes
= btcb
->totalNodes
;
677 bthp
->freeNodes
= btcb
->freeNodes
;
678 bthp
->clumpSize
= cfork
.cf_clump
;
679 bthp
->btreeType
= 0xFF;
680 bthp
->attributes
= kBTVariableIndexKeysMask
| kBTBigKeysMask
;
681 bthp
->maxKeyLength
= kHFSPlusAttrKeyMaximumLength
;
682 bthp
->keyCompareType
= kHFSBinaryCompare
;
683 offset
+= sizeof(BTHeaderRec
);
684 index
[(nodesize
/ 2) - 2] = offset
;
686 /* FILL IN THE USER RECORD: */
687 offset
+= kBTreeHeaderUserBytes
;
688 index
[(nodesize
/ 2) - 3] = offset
;
690 /* FILL IN THE MAP RECORD (only one node in use). */
691 *((u_int8_t
*)buffer
+ offset
) = 0x80;
692 offset
+= nodesize
- sizeof(BTNodeDescriptor
) - sizeof(BTHeaderRec
)
693 - kBTreeHeaderUserBytes
- (4 * sizeof(int16_t));
694 index
[(nodesize
/ 2) - 4] = offset
;
697 result
= btree_journal_modify_block_end(hfsmp
, bp
);
699 result
= VNOP_BWRITE(bp
);
704 /* Publish new btree file */
705 hfsmp
->hfs_attribute_vp
= vp
;
706 (void) hfs_flushvolumeheader(hfsmp
, MNT_WAIT
, HFS_ALTFLUSH
);
709 hfs_unlock(VTOC(vp
));
715 // hfs_truncate(); /* XXX need to give back blocks */